Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http/client: support dns ipv6 #141

Merged
merged 1 commit into from
Aug 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/http/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <re_types.h>
#include <re_mem.h>
#include <re_mbuf.h>
#include <re_net.h>
#include <re_sa.h>
#include <re_list.h>
#include <re_hash.h>
Expand Down Expand Up @@ -62,6 +63,7 @@ struct http_req {
struct http_cli *cli;
struct http_msg *msg;
struct dns_query *dq;
struct dns_query *dq6;
struct conn *conn;
struct mbuf *mbreq;
struct mbuf *mb;
Expand Down Expand Up @@ -132,6 +134,7 @@ static void req_destructor(void *arg)
list_unlink(&req->le);
mem_deref(req->msg);
mem_deref(req->dq);
mem_deref(req->dq6);
mem_deref(req->conn);
mem_deref(req->mbreq);
mem_deref(req->mb);
Expand Down Expand Up @@ -178,6 +181,7 @@ static void req_close(struct http_req *req, int err,
{
list_unlink(&req->le);
req->dq = mem_deref(req->dq);
req->dq6 = mem_deref(req->dq6);
req->datah = NULL;

if (req->conn) {
Expand Down Expand Up @@ -584,6 +588,11 @@ 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);

/* wait for other (A/AAAA) query to complete */
if (req->dq || req->dq6)
return;

if (req->srvc == 0) {
err = err ? err : EDESTADDRREQ;
goto fail;
Expand Down Expand Up @@ -782,11 +791,25 @@ int http_request(struct http_req **reqp, struct http_cli *cli, const char *met,
goto out;
}
else {
#ifdef HAVE_INET6
struct sa tmp;
#endif
err = dnsc_query(&req->dq, cli->dnsc, req->host,
DNS_TYPE_A, DNS_CLASS_IN, true,
query_handler, req);
if (err)
goto out;
sreimers marked this conversation as resolved.
Show resolved Hide resolved

#ifdef HAVE_INET6
if (0 == net_default_source_addr_get(AF_INET6, &tmp)) {

err = dnsc_query(&req->dq6, cli->dnsc, req->host,
DNS_TYPE_AAAA, DNS_CLASS_IN, true,
query_handler, req);
if (err)
goto out;
}
#endif
}

out:
Expand Down