From: Amos Jeffries Date: Sat, 3 Jan 2015 08:01:50 +0000 (-0800) Subject: Bug 3760: squidclient ignores --disable-ipv6 X-Git-Tag: merge-candidate-3-v1~386 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=430b5d1593359b586efefdd4c40fff22127f7b2b;p=thirdparty%2Fsquid.git Bug 3760: squidclient ignores --disable-ipv6 --- diff --git a/src/ip/Address.cc b/src/ip/Address.cc index 1cf2d1e892..88d0723e57 100644 --- a/src/ip/Address.cc +++ b/src/ip/Address.cc @@ -393,6 +393,19 @@ Ip::Address::lookupHostIP(const char *s, bool nodns) return false; } + if (!Ip::EnableIpv6) { + // if we are IPv6-disabled, use first-IPv4 instead of first-IP. + struct addrinfo *maybeIpv4 = res; + while (maybeIpv4) { + if (maybeIpv4->ai_family == AF_INET) + break; + maybeIpv4 = maybeIpv4->ai_next; + } + if (maybeIpv4 != NULL) + res = maybeIpv4; + // else IPv6-only host, let the caller deal with first-IP anyway. + } + /* * NP: =(sockaddr_*) may alter the port. we don't want that. * all we have been given as input was an IPA. diff --git a/tools/squidclient/Transport.cc b/tools/squidclient/Transport.cc index 5b821ac834..c5adf31a3b 100644 --- a/tools/squidclient/Transport.cc +++ b/tools/squidclient/Transport.cc @@ -148,6 +148,11 @@ resolveDestination(Ip::Address &iaddr) { struct addrinfo *AI = NULL; + debugVerbose(2, "Transport detected: IPv4" << + ((Ip::EnableIpv6 & IPV6_SPECIAL_V4MAPPING) ? "-mapped " : "") << + (Ip::EnableIpv6 == IPV6_OFF ? "-only" : " and IPv6") << + ((Ip::EnableIpv6 & IPV6_SPECIAL_SPLITSTACK) ? " split-stack" : "")); + if (Transport::Config.localHost) { debugVerbose(2, "Resolving " << Transport::Config.localHost << " ...");