Skip to content

Commit 8cd6e79

Browse files
patthoytsdscho
authored andcommitted
remote-http(s): Support SOCKS proxies
With this patch we properly support SOCKS proxies, configured e.g. like this: git config http.proxy socks5://192.168.67.1:32767 Without this patch, Git mistakenly tries to use SOCKS proxies as if they were HTTP proxies, resulting in a error message like: fatal: unable to access 'http://.../': Proxy CONNECT aborted This patch was required to work behind a faulty AP and scraped from http://stackoverflow.com/questions/15227130/#15228479 and guarded with an appropriate cURL version check by Johannes Schindelin. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent f52fa30 commit 8cd6e79

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

http.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,17 @@ static CURL *get_curl_handle(void)
447447

448448
if (curl_http_proxy) {
449449
curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
450+
#if LIBCURL_VERSION_NUM >= 0x071800
451+
if (starts_with(curl_http_proxy, "socks5"))
452+
curl_easy_setopt(result,
453+
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
454+
else if (starts_with(curl_http_proxy, "socks4a"))
455+
curl_easy_setopt(result,
456+
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);
457+
else if (starts_with(curl_http_proxy, "socks"))
458+
curl_easy_setopt(result,
459+
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
460+
#endif
450461
}
451462
#if LIBCURL_VERSION_NUM >= 0x070a07
452463
curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);

0 commit comments

Comments
 (0)