]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3760: squidclient ignores --disable-ipv6
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 3 Jan 2015 08:01:50 +0000 (00:01 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 3 Jan 2015 08:01:50 +0000 (00:01 -0800)
src/ip/Address.cc
tools/squidclient/Transport.cc

index 1cf2d1e8929f8a47ceb1c14911f6b00a54660a54..88d0723e57b8d843759f8c681c7e58b22edb1d15 100644 (file)
@@ -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.
index 5b821ac834349c8678bc26e97b985e5d06cf1ce0..c5adf31a3ba317612b773990665208715c63b086 100644 (file)
@@ -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 << " ...");