Show correct address:port in SOCKS5 proxy connection failure message.
authorAndrej Kacian <ticho@claws-mail.org>
Thu, 6 Sep 2018 21:13:41 +0000 (23:13 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Thu, 6 Sep 2018 21:13:41 +0000 (23:13 +0200)
The address and port contained in the server response
are what the proxy server has bound locally for the
connection, not the destination address and port.

src/common/proxy.c

index e790990..7a30030 100644 (file)
@@ -254,25 +254,8 @@ gint socks5_connect(SockInfo *sock, const gchar *hostname, gushort port,
                return -1;
        }
        if (socks_req[1] != 0) {
-               if (socks_req[3] == 1) { /* IPv4 address */
-                       g_warning("socks5_connect: SOCKS5 connection to %u.%u.%u.%u:%u failed. (%u)", socks_req[4], socks_req[5], socks_req[6], socks_req[7], ntohs(*(gushort *)(socks_req + 8)), socks_req[1]);
-               } else if (socks_req[3] == 3) { /* Domain name */
-                       gint hnlen = socks_req[4];
-                       gchar *hn = malloc(hnlen + 1);
-                       hn[hnlen] = '\0';
-                       memcpy(hn, &socks_req[5], hnlen);
-                       g_warning("socks5_connect: SOCKS5 connection to %s:%u failed. (%u)",
-                                       hn, ntohs(*(gushort *)(socks_req + 5 + hnlen)), socks_req[1]);
-                       g_free(hn);
-               } else if (socks_req[3] == 4) { /* IPv6 address */
-                       gint hnlen = 16;
-                       gchar *hn = malloc(hnlen + 1);
-                       hn[hnlen] = '\0';
-                       memcpy(hn, &socks_req[4], hnlen);
-                       g_warning("socks5_connect: SOCKS5 connection to IPv6 %s:%u failed. (%u)",
-                                       hn, ntohs(*(gushort *)(socks_req + 5 + hnlen)), socks_req[1]);
-                       g_free(hn);
-               }
+               g_warning("socks5_connect: SOCKS5 connection to %s:%u failed. (%u)",
+                               hostname, port, socks_req[1]);
                return -1;
        }