X-Git-Url: http://git.meshlink.io/?p=meshlink;a=blobdiff_plain;f=src%2Fadns.c;h=01989ac5c71bdeb24602358841cfb5d5555dece6;hp=a04310149f07a76cf3ff7ae2d05db369fb921d23;hb=91169c529883e08d7a0245b709483a22a83245ad;hpb=47a69d3c93a292cf6fe8076e8fe8f3eb23d76da3 diff --git a/src/adns.c b/src/adns.c index a0431014..01989ac5 100644 --- a/src/adns.c +++ b/src/adns.c @@ -138,6 +138,7 @@ struct adns_blocking_info { char *host; char *serv; struct addrinfo *ai; + int socktype; bool done; }; @@ -147,7 +148,12 @@ static void *adns_blocking_handler(void *data) { logger(info->mesh, MESHLINK_DEBUG, "Resolving %s port %s", info->host, info->serv); devtool_adns_resolve_probe(); - if(getaddrinfo(info->host, info->serv, NULL, &info->ai)) { + struct addrinfo hint = { + .ai_family = AF_UNSPEC, + .ai_socktype = info->socktype, + }; + + if(getaddrinfo(info->host, info->serv, &hint, &info->ai)) { info->ai = NULL; } @@ -171,12 +177,13 @@ static void *adns_blocking_handler(void *data) { return NULL; } -struct addrinfo *adns_blocking_request(meshlink_handle_t *mesh, char *host, char *serv, int timeout) { +struct addrinfo *adns_blocking_request(meshlink_handle_t *mesh, char *host, char *serv, int socktype, int timeout) { struct adns_blocking_info *info = xzalloc(sizeof(*info)); info->mesh = mesh; info->host = host; info->serv = serv; + info->socktype = socktype; struct timespec deadline; clock_gettime(CLOCK_REALTIME, &deadline);