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 8, 2016, 19:16 UTC
Message-ID
<xmqq8u0nx66h.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAEc+GFeG-ZdeTXGsjmwV0QP6QwYvjA4nzCGitka0aXjqEkatfg@mail.gmail.com>
Felix Ruess <felix.ruess@gmail.com> writes:
Show 5 quoted lines
> I just encountered a problem with the latest git version (2.8.1) that
> looks like a regression to me:
> When trying to clone a repo via a https socks5 proxy the connection times out:
>
> $ git config --global 'http.proxy=socks5h://127.0.0.1:1080'

The first version of Git that has code that explicitly supports socks proxy is 2.6.4, it seems. Since then we have always used CURLPROXY_SOCKS5 for curl_http_proxy that begins with a string "socks5".

Checking
    https://github.com/curl/curl/blob/master/docs/libcurl/symbols-in-versions

I find that that at curl 7.18.0, curl added a separate CURLPROXY_SOCKS5_HOSTNAME that can be triggered by "socks5h:" that is separate from CURLPROXY_SOCKS5, and I am guessing that the differences in behaviour between these two is what is causing you trouble. 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)

and because not using _HOSTNAME variant would likely not ask the proxy to do the resolving, it explains the stall on your end, if your box cannot resolve external hostname.

Perhaps the attached patch may help?

I do not know if Pat is still active as a developer, but I am wondering what the reason was to use starts_with(..., "socks5") instead of "socks5:", "socks4a:", etc. when identifying the proxy type.

 http.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/http.c b/http.c
index 69da445..4304b80 100644
--- a/http.c
+++ b/http.c
@@ -605,7 +605,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"))
Previous: Dennis KaarsemakerNext: Felix Ruess
Message 3 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.