Skip to content

Commit

Permalink
http/client: support dns ipv6 as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
fAuernigg committed Aug 17, 2021
1 parent 8808434 commit 0f70aa0
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/http/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ struct http_req {
bool chunked;
bool secure;
bool close;
bool ipv6fb;
};


Expand Down Expand Up @@ -584,9 +585,24 @@ static void query_handler(int err, const struct dnshdr *hdr, struct list *ansl,

dns_rrlist_apply2(ansl, req->host, DNS_TYPE_A, DNS_TYPE_AAAA,
DNS_CLASS_IN, true, rr_handler, req);

if (req->srvc == 0) {
err = err ? err : EDESTADDRREQ;
goto fail;
#ifdef HAVE_INET6
if (req->ipv6fb) {
req->ipv6fb = false;
err = dnsc_query(&req->dq, req->cli->dnsc, req->host,
DNS_TYPE_AAAA, DNS_CLASS_IN, true,
query_handler, req);
if (err)
goto fail;
return;
}
else
#endif
{
err = err ? err : EDESTADDRREQ;
goto fail;
}
}

err = req_connect(req);
Expand Down Expand Up @@ -782,11 +798,12 @@ int http_request(struct http_req **reqp, struct http_cli *cli, const char *met,
goto out;
}
else {
#ifdef HAVE_INET6
req->ipv6fb = true;
#endif
err = dnsc_query(&req->dq, cli->dnsc, req->host,
DNS_TYPE_A, DNS_CLASS_IN, true,
query_handler, req);
if (err)
goto out;
}

out:
Expand Down

0 comments on commit 0f70aa0

Please sign in to comment.