summaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorPat Thoyts <patthoyts@users.sourceforge.net>2015-10-26 13:15:07 (GMT)
committerJeff King <peff@peff.net>2015-11-20 12:31:39 (GMT)
commit6d7afe07f29df75f831a46fb0f657fa37e561779 (patch)
tree6a7786659df2979d582398a98389fe061b4fdce4 /http.c
parenta2558fb8e1e387b630312311e1d22c95663da5d0 (diff)
downloadgit-6d7afe07f29df75f831a46fb0f657fa37e561779.zip
git-6d7afe07f29df75f831a46fb0f657fa37e561779.tar.gz
git-6d7afe07f29df75f831a46fb0f657fa37e561779.tar.bz2
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>
Diffstat (limited to 'http.c')
-rw-r--r--http.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/http.c b/http.c
index 9448c50..be3f5fb 100644
--- a/http.c
+++ b/http.c
@@ -424,6 +424,17 @@ 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"))
+ curl_easy_setopt(result,
+ CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+ else if (starts_with(curl_http_proxy, "socks4a"))
+ curl_easy_setopt(result,
+ CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);
+ else if (starts_with(curl_http_proxy, "socks"))
+ curl_easy_setopt(result,
+ CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+#endif
}
#if LIBCURL_VERSION_NUM >= 0x070a07
curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);