Thread (1 message) 1 message, 1 author, 2016-06-16

Re: git 2.8.1 not working with socks5h https proxy anymore

From: Junio C Hamano <hidden>
Date: 2016-06-16 02:18:44
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Felix Ruess [off-list ref] writes:
Thanks a lot!
Tested the patch and it works as expected :-)
Thanks, lets do this, then.

-- >8 --
Subject: [PATCH] http: differentiate socks5:// and socks5h://

Felix Ruess [off-list ref] noticed that with configuration

    $ git config --global 'http.proxy=socks5h://127.0.0.1:1080'

connections to remote sites time out, waiting for DNS resolution.

The logic to detect various flavours of SOCKS proxy and ask the
libcurl layer to use appropriate one understands the proxy string
that begin with socks5, socks4a, etc., but does not know socks5h,
and we end up using CURLPROXY_SOCKS5.  The correct one to use is
CURLPROXY_SOCKS5_HOSTNAME.

https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html says

  ..., socks5h:// (the last one to enable socks5 and asking the
  proxy to do the resolving, also known as CURLPROXY_SOCKS5_HOSTNAME
  type).

which is consistent with the way the breakage was reported.

Tested-by: Felix Ruess <redacted>
Signed-off-by: Junio C Hamano <redacted>
---
 http.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/http.c b/http.c
index c29ce81..b560c13 100644
--- a/http.c
+++ b/http.c
@@ -466,7 +466,10 @@ static CURL *get_curl_handle(void)
 	if (curl_http_proxy) {
 		curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
 #if LIBCURL_VERSION_NUM >= 0x071800
-		if (starts_with(curl_http_proxy, "socks5"))
+		if (starts_with(curl_http_proxy, "socks5h"))
+			curl_easy_setopt(result,
+				CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);
+		else if (starts_with(curl_http_proxy, "socks5"))
 			curl_easy_setopt(result,
 				CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
 		else if (starts_with(curl_http_proxy, "socks4a"))
-- 
2.8.1-339-gc925d85
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help