Skip to content

Commit 4836720

Browse files
authored
Merge pull request me-no-dev#61 from tve/fix_dns
fix DNS not-found results
2 parents 091802a + 882ef82 commit 4836720

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
@@ -298,10 +298,15 @@ static void _tcp_error(void * arg, int8_t err) {
298298

299299
static void _tcp_dns_found(const char * name, struct ip_addr * ipaddr, void * arg) {
300300
lwip_event_packet_t * e = (lwip_event_packet_t *)malloc(sizeof(lwip_event_packet_t));
301+
//ets_printf("+DNS: name=%s ipaddr=0x%08x arg=%x\n", name, ipaddr, arg);
301302
e->event = LWIP_TCP_DNS;
302303
e->arg = arg;
303304
e->dns.name = name;
304-
memcpy(&e->dns.addr, ipaddr, sizeof(struct ip_addr));
305+
if (ipaddr) {
306+
memcpy(&e->dns.addr, ipaddr, sizeof(struct ip_addr));
307+
} else {
308+
memset(&e->dns.addr, 0, sizeof(e->dns.addr));
309+
}
305310
if (!_send_async_event(&e)) {
306311
free((void*)(e));
307312
}
@@ -923,7 +928,7 @@ int8_t AsyncClient::_poll(tcp_pcb* pcb){
923928
}
924929

925930
void AsyncClient::_dns_found(struct ip_addr *ipaddr){
926-
if(ipaddr){
931+
if(ipaddr && ipaddr->u_addr.ip4.addr){
927932
connect(IPAddress(ipaddr->u_addr.ip4.addr), _connect_port);
928933
} else {
929934
if(_error_cb) {

0 commit comments

Comments
 (0)