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

x/net/proxy: SOCKS5 Timeout is not working properly #37549

Open
qwatros opened this issue Feb 28, 2020 · 3 comments
Open

x/net/proxy: SOCKS5 Timeout is not working properly #37549

qwatros opened this issue Feb 28, 2020 · 3 comments

Comments

@qwatros
Copy link

@qwatros qwatros commented Feb 28, 2020

After successful connection to the proxy timeout doesn't work any more. So it's hanging a long time trying to connect from proxy to an "addr" endpoint (I suppose).

It' would be good to have a global socket timeout option.

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

1.13

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/root666/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/root666/work/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=""
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-build754930586=/tmp/go-build -gno-record-gcc-switches"

What did you do?

func Client(socks, addr string) (net.Conn, error) {
	dialer, err := proxy.SOCKS5("tcp", socks, nil, &net.Dialer{Timeout: 3 * time.Second})
	if err != nil {
		return nil, err
	}
	conn, err := dialer.Dial("tcp", addr)
	if err != nil {
		return nil, err
	}
	return conn, err
}

What did you expect to see?

Timeout with 3 seconds

What did you see instead?

Timeout more then 10 seconds.

@dmitshur dmitshur changed the title x/net/proxy SOCKS5 Timeout is not working properly x/net/proxy: SOCKS5 Timeout is not working properly Mar 2, 2020
@dmitshur
Copy link
Contributor

@dmitshur dmitshur commented Mar 2, 2020

Loading

@dmitshur dmitshur added this to the Unreleased milestone Mar 2, 2020
@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Mar 2, 2020

I think this is a dup of another bug. (or a pending CL or so)

The net.Dialer's timeout is only for the TCP dial. The SOCKS5 dial doesn't support contexts yet.

Loading

@ceo
Copy link

@ceo ceo commented Jul 31, 2021

did you manage to make it work ? i think the timeout you are setting is only for the forward proxy parameter, that dialer is used when connecting to the proxy only , not used when trying to connect to "addr"

Loading

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
4 participants