X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/e7eb3a2744aa45179daea235800753d3d1955338..e41a99999ec696e848b8ea1c8953ae7dc88f9d6d:/lib/client-common.c diff --git a/lib/client-common.c b/lib/client-common.c index 946cab7..aa43124 100644 --- a/lib/client-common.c +++ b/lib/client-common.c @@ -15,6 +15,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +/** @file lib/client-common.c + * @brief Common code to client APIs + */ #include "common.h" @@ -42,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 { @@ -70,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;