http 전송을 위해 git과 함께 socks 프록시 사용
git이 HTTP 전송을 위해 socks 프록시를 사용하도록 만드는 방법은 무엇입니까?
GIT 전송에 양말 프록시를 사용하도록 GIT_PROXY_COMMAND로 git을 구성하는 데 성공했습니다.
또한 .curlrc 파일을 구성하여 socks 프록시를 정의했으며 다음과 같은 curl 명령을 사용하여 정보를 직접 가져올 수 있습니다.
curl http://git.kernel.org/pub/scm/git/git.git/info/refs?service=git-upload-pack
그러나 다음과 같은 HTTP 전송 프로토콜을 사용하여 데이터를 검색하기 위해 git과 함께 socks 프록시를 사용하는 방법 :
git clone http://git.kernel.org/pub/scm/git
Git 1.8.2 및 SOCKS v5 프록시로 테스트했으며 다음 설정이 저에게 효과적입니다.
git config --global http.proxy 'socks5://127.0.0.1:7070'
2017-3-31 업데이트 :
문서에 따르면 이름에도 불구하고 HTTP 및 HTTPS 저장소 URL 모두에서 작동합니다. 이것을 지적 해 주신 @user에게 감사드립니다.http
.proxy
2018-11-27 업데이트 :
프록시를 비활성화하려면 다음 명령을 실행하십시오.
git config --global --unset http.proxy
2019-03-04 수정 :
당신은 또한 프록시를 사용하여 해결 될 호스트 이름을 원하는 경우, 아래의 사용 thuzhf의 솔루션은 사용하는 socks5h
대신socks5
프록시를 전역 구성으로 설정하지 않으려면 다음을 시도하십시오 ALL_PROXY=
.
$ ALL_PROXY=socks5://127.0.0.1:8888 git clone https://github.com/some/one.git
(조금 알림) 호스트 이름도 프록시에 의해 확인되도록하려면 (즉 , 프록시를 통해 모든 것을 전달하는 것을 의미 ), 특히 gist를 복제 할 때 다음 설정을 사용할 수 있습니다 (핵심은 대신 socks5h 를 사용 한다는 것입니다). 의 SOCKS5 ) :
git config --global http.proxy socks5h://127.0.0.1:1080
다음 명령을 사용하여 socks5 프록시에서 특정 저장소를 복제합니다. 프록시 설정은 --config
옵션 으로 지정됩니다 .
$ git clone https://github.com/xxxxx --config 'http.proxy=socks5://127.0.0.1:1234'
참고 : 여기에있는 패치는 버전 2.4.11의 2015 년에 git에 적용되었습니다. 그 이후로 http.proxy 구성 설정과 함께 socks : // URL을 사용할 수 있습니다.
git : // 프로토콜의 경우 Using Git with a SOCKS proxy 있습니다. 그러나 git은 socks 프록시를 제대로 지원하지 않는 것으로 보입니다. git 자체는 libcurl에 연결됩니다. 따라서 .curlrc 파일은 사용되지 않습니다 (컬 명령 줄 클라이언트에만 해당). 그러나 다음 패치는 필요한 지원을 제공합니다. 이 패치를 git에 적용하면 간단히 ALL_PROXY 환경 변수 또는 HTTP_PROXY 또는 HTTPS_PROXY를 socks://hostname:portnum
(또는 socks4 / socks5) 또는 실제로 http.proxy git config 설정으로 설정할 수 있으며 libcurl은 이제 실제로 프록시를 사용할 때 socks 프로토콜을 사용합니다.
예를 들어, 활성 추적 :
$ GIT_CURL_VERBOSE=1 bin-wrappers/git -c "http.proxy=socks://localhost:1080" ls-remote http://github.com/patthoyts/tclftd2xx.git
* Couldn't find host github.com in the _netrc file; using defaults
* About to connect() to proxy localhost port 1080 (#0)
* Trying 127.0.0.1...
* connected
* SOCKS4 request granted.
* Connected to localhost (127.0.0.1) port 1080 (#0)
> GET /patthoyts/tclftd2xx.git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.8.1.msysgit.1.dirty
... and on to a successful request ...
필요한 패치 :
diff --git a/http.c b/http.c
index 3b312a8..f34cc75 100644
--- a/http.c
+++ b/http.c
@@ -322,6 +322,14 @@ static CURL *get_curl_handle(void)
if (curl_http_proxy) {
curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
+#if LIBCURL_VERSION_NUM >= 0x071800
+ if (!strncmp("socks5", curl_http_proxy, 6))
+ curl_easy_setopt(result, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+ else if (!strncmp("socks4a", curl_http_proxy, 7))
+ curl_easy_setopt(result, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);
+ else if (!strncmp("socks", curl_http_proxy, 5))
+ curl_easy_setopt(result, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+#endif
}
return result;
@briankip을 참조하고 Yang.Y가 언급했듯이 http 프록시 설정을 제거하면 ini 파일을 직접 편집 할 수 있습니다.
명령 줄에서 다음을 사용하여이 작업을 수행 할 수도 있습니다.
git config --global --unset http.proxy
제거되었는지 확인하려면 다음을 사용하여 현재 구성을 나열하십시오.
git config --list
참고 URL : https://stackoverflow.com/questions/15227130/using-a-socks-proxy-with-git-for-the-http-transport
'Nice programing' 카테고리의 다른 글
AppEngine 오류 [java.lang.NoClassDefFoundError : org / w3c / dom / ElementTraversal] (0) | 2020.12.02 |
---|---|
터치 장치 용 문서 .click 기능 (0) | 2020.12.02 |
C #에서 기본 네임 스페이스와 함께 Xpath 사용 (0) | 2020.12.02 |
UIColor의 상수 값을 어떻게 정의합니까? (0) | 2020.12.02 |
pg_config 경로를 찾는 방법 (0) | 2020.12.02 |