[PATCH 2/6] remote-http(s): Support SOCKS proxies
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Oct 26, 2015, 13:15 UTC
- Message-ID
- <bf218d020e24216f55d1514c4459e645b13ec075.1445865176.git.johannes.schindelin@gmx.de>
- In-Reply-To
- <cover.1445865176.git.johannes.schindelin@gmx.de>
From: Pat Thoyts <patthoyts@users.sourceforge.net>
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 <johannes.schindelin@gmx.de> --- http.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/http.c b/http.c index 7da76ed..6b89dea 100644 --- a/http.c +++ b/http.c @@ -465,6 +465,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);
-- 2.1.4