Skip to content

Commit 6c30413

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. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent d1fdd7f commit 6c30413

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
@@ -370,6 +370,17 @@ static CURL *get_curl_handle(void)
370370
if (curl_http_proxy) {
371371
curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
372372
curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
373+
#if LIBCURL_VERSION_NUM >= 0x071800
374+
if (starts_with(curl_http_proxy, "socks5"))
375+
curl_easy_setopt(result,
376+
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
377+
else if (starts_with(curl_http_proxy, "socks4a"))
378+
curl_easy_setopt(result,
379+
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);
380+
else if (starts_with(curl_http_proxy, "socks"))
381+
curl_easy_setopt(result,
382+
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
383+
#endif
373384
}
374385

375386
set_curl_keepalive(result);

0 commit comments

Comments
 (0)