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: Pat Thoyts <patthoyts@users.sourceforge.net> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pat Thoyts committed
Oct 26, 2015 at 14:15 UTC
6d7afe07f29df75f831a46fb0f657fa37e561779
1 file changed
+11
http.c
+11
@@ -424,6 +424,17 @@ static CURL *get_curl_handle(void)
424
425
if (curl_http_proxy) {
426
curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
427
+#if LIBCURL_VERSION_NUM >= 0x071800
428
+ if (starts_with(curl_http_proxy, "socks5"))
429
+ curl_easy_setopt(result,
430
+ CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
431
+ else if (starts_with(curl_http_proxy, "socks4a"))
432
+ curl_easy_setopt(result,
433
+ CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);
434
+ else if (starts_with(curl_http_proxy, "socks"))
435
+ curl_easy_setopt(result,
436
+ CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
437
+#endif
438
}
439
#if LIBCURL_VERSION_NUM >= 0x070a07
440
curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);