mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-31 13:00:49 +00:00
Change mg_resolve()
This commit is contained in:
1 parent
2f981f9383
commit
3b0a509cae
5 files changed
+18
-18
No files matched your search
@@ -256,12 +256,14 @@ static void mg_sendnsreq(struct mg_connection *c, struct mg_str *name, int ms,
|
||||
}
|
||||
}
|
||||
|
||||
void mg_resolve(struct mg_connection *c, struct mg_str *name, int ms) {
|
||||
if (mg_aton(*name, &c->peer)) {
|
||||
// name is an IP address, do not fire name resolution
|
||||
void mg_resolve(struct mg_connection *c, const char *url) {
|
||||
struct mg_str host = mg_url_host(url);
|
||||
c->peer.port = mg_htons(mg_url_port(url));
|
||||
if (mg_aton(host, &c->peer)) {
|
||||
// host is an IP address, do not fire name resolution
|
||||
mg_connect_resolved(c);
|
||||
} else {
|
||||
// name is not an IP, send DNS resolution request
|
||||
mg_sendnsreq(c, name, ms, &c->mgr->dns4, false);
|
||||
// host is not an IP, send DNS resolution request
|
||||
mg_sendnsreq(c, &host, c->mgr->dnstimeout, &c->mgr->dns4, false);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user