Re: git 2.8.1 not working with socks5h https proxy anymore

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Felix Ruess <felix.ruess@xxxxxxxxx> writes:

> 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"))
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]