Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: ProxyFromEnvironment does not support socks5h #24135

Open
sorsasampo opened this issue Feb 26, 2018 · 4 comments
Open

net/http: ProxyFromEnvironment does not support socks5h #24135

sorsasampo opened this issue Feb 26, 2018 · 4 comments

Comments

@sorsasampo
Copy link

@sorsasampo sorsasampo commented Feb 26, 2018

What version of Go are you using (go version)?

go version go1.10 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/go"
GORACE=""
GOROOT="/home/user/go1.10"
GOTMPDIR=""
GOTOOLDIR="/home/user/go1.10/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build712629011=/tmp/go-build -gno-record-gcc-switches"

What did you do?

What did you expect to see?

What did you see instead?

go get does not understand socks5h in HTTPS_PROXY, even though it understands socks5.

For example, to test using the tor proxy:

$ HTTPS_PROXY=socks5h://127.0.0.1:9050 go get -v golang.org/x/tools/cmd/goimports
Fetching https://golang.org/x/tools/cmd/goimports?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd/goimports?go-get=1: proxyconnect tcp: dial tcp: lookup socks5h: No address associated with hostname
package golang.org/x/tools/cmd/goimports: unrecognized import path "golang.org/x/tools/cmd/goimports" (https fetch: Get https://golang.org/x/tools/cmd/goimports?go-get=1: proxyconnect tcp: dial tcp: lookup socks5h: No address associated with hostname)

Other tools that understand HTTPS_PROXY also understand socks5h (resolve hostname through the proxy, not locally). curl and yum, for example.

Related to issue #18508.

@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Feb 26, 2018

Seems reasonable. We need to clean up the x/net/socks* packages first, but then somebody can do this.

/cc @mikioh

@gopherbot
Copy link

@gopherbot gopherbot commented Jan 7, 2019

Change https://golang.org/cl/156518 mentions this issue: http/httpproxy: support socks5h scheme in proxy URL

@ChrMa
Copy link

@ChrMa ChrMa commented Sep 8, 2020

As a git user, which has recently started using git-lfs, which in turn is written in go, I've stumbled across the same issue.
Sometimes i need to use git with a socks5h HTTPS_PROXY, and git works just fine, but git-ls gives the above error message saying host socks5h cannot be resolved. When I set HTTPS_PROXY to using socks5 instead, git-ls works, but now git tries to resolve all host names and give the resulting IPs to the socks server, which does not work with my setup and is one of the reasons I'm using the socks server in the first place.
The only way around this is using a combination of HTTPS_PROXY=socks5://server:port and https_proxy=socks5h://server:port, which works because git-lfs gives HTTPS_PROXY precedence over https_proxy, while git itself does exactly the opposite.
Given that the socks5 implemented in go is in reality socks5h in the first place, why not add socks5h to the list of proxy protocols recognized and just handle it the same as socks5? The above mentioned change https://go-review.googlesource.com/c/net/+/156518 seems to try exactly this, even though I don't quite understand, why it split off part of the change into another change at https://go-review.googlesource.com/c/go/+/162318 .

@thatnerdjosh
Copy link

@thatnerdjosh thatnerdjosh commented Dec 10, 2020

I volunteer to work on this support if no one is working on it

EDIT: @mikioh is the cleanup on the SOCKS module done yet?

/CC @bradfitz (if you still are a maintainer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants