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: Transport does not support proxy schemes added with RegisterProtocol #28964

Open
beiriannydd opened this Issue Nov 27, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@beiriannydd

beiriannydd commented Nov 27, 2018

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

$ go version
go version go1.11.1 linux/amd64

Does this issue reproduce with the latest release?

I checked https://golang.org/src/net/http/transport.go?s=3628:10127#L93 using godoc and it has no handling for Proxies with schemes other than http(s)/socks5, so yes.

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/xxx/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/Users/xxx/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/Users/xxxx/src/devops-automation/go.mod"
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-build522908579=/tmp/go-build -gno-record-gcc-switches"

What did you do?

dt.RegisterProtocol("ssh", proxy.NewSSHTransport(bastionHost))

NewSSHTransport returns an http.Transport which has Dial() which ensures a tunnel is open and then calls ssh.Client.Dial() on the open client to create a tunneled connection

    dt.Proxy() -> url.URL{Scheme: "ssh", Host: bastionHost+":22"}
    req := http.NewRequest("GET", "http://testurl.com", nil)

What did you expect to see?

sshTransport Dial to be used for the proxy

What did you see instead?

DefaultTransport Dial was used for the proxy.

It would be nice not to have to rewrite RoundTrip to allow additional proxy schemes.
I think that this could be solved by checking if either Request Scheme or Proxy Scheme use a different transport and then delegating the rest of the request to the scheme's Transport.

@bradfitz bradfitz changed the title from net/http/#Transport does not support proxy schemes added with RegisterProtocol to net/http: Transport does not support proxy schemes added with RegisterProtocol Nov 27, 2018

@bradfitz bradfitz added this to the Unplanned milestone Nov 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment