X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/132a5a4a47f9dbc7c52ee15234d70258c59ccf8e..a202463f02ef9fe101e14bd5ca264de34d50a405:/lib/client-common.c diff --git a/lib/client-common.c b/lib/client-common.c index ced82e4..aa43124 100644 --- a/lib/client-common.c +++ b/lib/client-common.c @@ -45,17 +45,11 @@ socklen_t find_server(struct config *c, struct addrinfo *res = 0; char *name; socklen_t len; - - static const struct addrinfo pref = { - .ai_flags = 0, - .ai_family = PF_INET, - .ai_socktype = SOCK_STREAM, - .ai_protocol = IPPROTO_TCP, - }; - if(c->connect.n) { - res = get_address(&c->connect, &pref, &name); - if(!res) return -1; + if(c->connect.af != -1) { + res = netaddress_resolve(&c->connect, 0, IPPROTO_TCP); + if(!res) + return -1; sa = res->ai_addr; len = res->ai_addrlen; } else { @@ -73,7 +67,7 @@ socklen_t find_server(struct config *c, *sap = xmalloc_noptr(len); memcpy(*sap, sa, len); if(namep) - *namep = name; + *namep = format_sockaddr(sa); if(res) freeaddrinfo(res); return len;