git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git 2.8.1 not working with socks5h https proxy anymore

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 10, 2016, 18:11 UTC
Message-ID
<xmqqegadtjtv.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAEc+GFerpBC_O4jMvtmUhVdLReEN4nvuz5Q30SFUp8qZnQZBmQ@mail.gmail.com>
Felix Ruess <felix.ruess@gmail.com> 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 <felix.ruess@gmail.com> 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 <felix.ruess@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 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
Previous: Felix Ruess
Message 5 of 5 in “git 2.8.1 not working with socks5h https proxy anymore”
  1. Felix RuessApr 8, 2016
  2. Dennis KaarsemakerApr 8, 2016
  3. Junio C HamanoApr 8, 2016
  4. Felix RuessApr 9, 2016
  5. Junio C HamanoApr 10, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.