mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-27 20:59:00 +08:00
Fix #1532 - improve ipv6 DNS lookup
This commit is contained in:
parent
93ff3e4d1f
commit
a7cbc19755
@ -279,7 +279,8 @@ static void dns_cb(struct mg_connection *c, int ev, void *ev_data,
|
||||
mg_ntoa(&d->c->rem, buf, sizeof(buf))));
|
||||
mg_connect_resolved(d->c);
|
||||
#if MG_ENABLE_IPV6
|
||||
} else if (dm.addr.is_ip6 == false && dm.name[0] != '\0') {
|
||||
} else if (dm.addr.is_ip6 == false && dm.name[0] != '\0' &&
|
||||
c->mgr->use_dns6 == false) {
|
||||
struct mg_str x = mg_str(dm.name);
|
||||
mg_sendnsreq(d->c, &x, c->mgr->dnstimeout, &c->mgr->dns6, true);
|
||||
#endif
|
||||
@ -374,7 +375,8 @@ void mg_resolve(struct mg_connection *c, const char *url) {
|
||||
mg_connect_resolved(c);
|
||||
} else {
|
||||
// host is not an IP, send DNS resolution request
|
||||
mg_sendnsreq(c, &host, c->mgr->dnstimeout, &c->mgr->dns4, false);
|
||||
struct mg_dns *dns = c->mgr->use_dns6 ? &c->mgr->dns6 : &c->mgr->dns4;
|
||||
mg_sendnsreq(c, &host, c->mgr->dnstimeout, dns, c->mgr->use_dns6);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -898,6 +898,7 @@ struct mg_mgr {
|
||||
struct mg_dns dns4; // DNS for IPv4
|
||||
struct mg_dns dns6; // DNS for IPv6
|
||||
int dnstimeout; // DNS resolve timeout in milliseconds
|
||||
bool use_dns6; // Use DNS6 server by default, see #1532
|
||||
unsigned long nextid; // Next connection ID
|
||||
void *userdata; // Arbitrary user data pointer
|
||||
uint16_t mqtt_id; // MQTT IDs for pub/sub
|
||||
|
@ -167,7 +167,8 @@ static void dns_cb(struct mg_connection *c, int ev, void *ev_data,
|
||||
mg_ntoa(&d->c->rem, buf, sizeof(buf))));
|
||||
mg_connect_resolved(d->c);
|
||||
#if MG_ENABLE_IPV6
|
||||
} else if (dm.addr.is_ip6 == false && dm.name[0] != '\0') {
|
||||
} else if (dm.addr.is_ip6 == false && dm.name[0] != '\0' &&
|
||||
c->mgr->use_dns6 == false) {
|
||||
struct mg_str x = mg_str(dm.name);
|
||||
mg_sendnsreq(d->c, &x, c->mgr->dnstimeout, &c->mgr->dns6, true);
|
||||
#endif
|
||||
@ -262,6 +263,7 @@ void mg_resolve(struct mg_connection *c, const char *url) {
|
||||
mg_connect_resolved(c);
|
||||
} else {
|
||||
// host is not an IP, send DNS resolution request
|
||||
mg_sendnsreq(c, &host, c->mgr->dnstimeout, &c->mgr->dns4, false);
|
||||
struct mg_dns *dns = c->mgr->use_dns6 ? &c->mgr->dns6 : &c->mgr->dns4;
|
||||
mg_sendnsreq(c, &host, c->mgr->dnstimeout, dns, c->mgr->use_dns6);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ struct mg_mgr {
|
||||
struct mg_dns dns4; // DNS for IPv4
|
||||
struct mg_dns dns6; // DNS for IPv6
|
||||
int dnstimeout; // DNS resolve timeout in milliseconds
|
||||
bool use_dns6; // Use DNS6 server by default, see #1532
|
||||
unsigned long nextid; // Next connection ID
|
||||
void *userdata; // Arbitrary user data pointer
|
||||
uint16_t mqtt_id; // MQTT IDs for pub/sub
|
||||
|
Loading…
Reference in New Issue
Block a user