Skip to content

Commit ff74001

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 1f524e1 commit ff74001

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
@@ -465,6 +465,17 @@ static CURL *get_curl_handle(void)
465465

466466
if (curl_http_proxy) {
467467
curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
468+
#if LIBCURL_VERSION_NUM >= 0x071800
469+
if (starts_with(curl_http_proxy, "socks5"))
470+
curl_easy_setopt(result,
471+
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
472+
else if (starts_with(curl_http_proxy, "socks4a"))
473+
curl_easy_setopt(result,
474+
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);
475+
else if (starts_with(curl_http_proxy, "socks"))
476+
curl_easy_setopt(result,
477+
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
478+
#endif
468479
}
469480
#if LIBCURL_VERSION_NUM >= 0x070a07
470481
curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);

0 commit comments

Comments
 (0)