X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fresolve.c;h=041c15620b1585c56f84dd45c8fa7a17f55b0c1a;hp=a128694bab19f06033dff4da93737f32bb0094b6;hb=22fa782be7840dae825be43e9ac8d8476d80f08c;hpb=2f6d7a649cf2428991cba3b9d2250b95a5904675 diff --git a/src/ngircd/resolve.c b/src/ngircd/resolve.c index a128694b..041c1562 100644 --- a/src/ngircd/resolve.c +++ b/src/ngircd/resolve.c @@ -45,6 +45,10 @@ static void Do_ResolveAddr PARAMS(( const ng_ipaddr_t *Addr, int Sock, int w_fd static void Do_ResolveName PARAMS(( const char *Host, int w_fd )); static bool register_callback PARAMS((RES_STAT *s, void (*cbfunc)(int, short))); +#ifdef WANT_IPV6 +extern bool Conf_ConnectIPv4; +extern bool Conf_ConnectIPv6; +#endif static pid_t Resolver_fork(int *pipefds) @@ -270,7 +274,7 @@ ForwardLookup(const char *hostname, array *IpAddr) #ifdef HAVE_GETADDRINFO int res; struct addrinfo *a, *ai_results; - static const struct addrinfo hints = { + static struct addrinfo hints = { #ifndef WANT_IPV6 .ai_family = AF_INET, #endif @@ -280,6 +284,14 @@ ForwardLookup(const char *hostname, array *IpAddr) .ai_socktype = SOCK_STREAM, .ai_protocol = IPPROTO_TCP }; +#ifdef WANT_IPV6 + assert(Conf_ConnectIPv6 || Conf_ConnectIPv4); + + if (!Conf_ConnectIPv6) + hints.ai_family = AF_INET; + if (!Conf_ConnectIPv4) + hints.ai_family = AF_INET6; +#endif res = getaddrinfo(hostname, NULL, &hints, &ai_results); switch (res) { case 0: break;