]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
connect: change verbose IPv6 address:port to [address]:port
authorJay Satiro <raysatiro@yahoo.com>
Mon, 3 Oct 2022 07:29:32 +0000 (03:29 -0400)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 4 Oct 2022 08:07:41 +0000 (10:07 +0200)
- Use brackets for the IPv6 address shown in verbose message when the
  format is address:port so that it is less confusing.

Before: Trying 2606:4700:4700::1111:443...
After: Trying [2606:4700:4700::1111]:443...

Bug: https://curl.se/mail/archive-2022-02/0041.html
Reported-by: David Hu
Closes #9635

lib/connect.c

index 13491c9817a2976c7ae637964562827e5992d8b5..c1d8cfd39e2ef282c386754f624e77af784051a1 100644 (file)
@@ -1222,7 +1222,11 @@ static CURLcode singleipconnect(struct Curl_easy *data,
     Curl_closesocket(data, conn, sockfd);
     return CURLE_OK;
   }
-  infof(data, "  Trying %s:%d...", ipaddress, port);
+  infof(data, "  Trying %s%s%s:%d...",
+        (addr.family == AF_INET6 ? "[" : ""),
+        ipaddress,
+        (addr.family == AF_INET6 ? "]" : ""),
+        port);
 
 #ifdef ENABLE_IPV6
   is_tcp = (addr.family == AF_INET || addr.family == AF_INET6) &&