Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit 5e2d35e

Browse files
committed
fix DNS not-found results
1 parent d1f28ff commit 5e2d35e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/AsyncTCP.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,15 @@ static void _tcp_error(void * arg, int8_t err) {
294294

295295
static void _tcp_dns_found(const char * name, struct ip_addr * ipaddr, void * arg) {
296296
lwip_event_packet_t * e = (lwip_event_packet_t *)malloc(sizeof(lwip_event_packet_t));
297+
//ets_printf("+DNS: name=%s ipaddr=0x%08x arg=%x\n", name, ipaddr, arg);
297298
e->event = LWIP_TCP_DNS;
298299
e->arg = arg;
299300
e->dns.name = name;
300-
memcpy(&e->dns.addr, ipaddr, sizeof(struct ip_addr));
301+
if (ipaddr) {
302+
memcpy(&e->dns.addr, ipaddr, sizeof(struct ip_addr));
303+
} else {
304+
memset(&e->dns.addr, 0, sizeof(e->dns.addr));
305+
}
301306
if (!_send_async_event(&e)) {
302307
free((void*)(e));
303308
}
@@ -912,7 +917,7 @@ int8_t AsyncClient::_poll(tcp_pcb* pcb){
912917
}
913918

914919
void AsyncClient::_dns_found(struct ip_addr *ipaddr){
915-
if(ipaddr){
920+
if(ipaddr && ipaddr->u_addr.ip4.addr){
916921
connect(IPAddress(ipaddr->u_addr.ip4.addr), _connect_port);
917922
} else {
918923
if(_error_cb) {

0 commit comments

Comments
 (0)