Skip to content

Commit 999e230

Browse files
committed
net/http: use DialWithConn method of socks.Dialer
This change uses the DialWithConn method of socks.Dialer to ensure that the bundled SOCKS client implementation is agnostic to the behavior and capabilities of transport connections. Also updates the bundled golang.org/x/net/internal/socks at git rev 7594486. (golang.org/cl/110135) Updates #25104. Change-Id: I87c2e99eeb857f182ea5d8ef569181d4f45f2e5d Reviewed-on: https://go-review.googlesource.com/110136 Run-TryBot: Mikio Hara <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 7ea2c8c commit 999e230

File tree

2 files changed

+66
-18
lines changed

2 files changed

+66
-18
lines changed

src/net/http/socks_bundle.go

Lines changed: 65 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/net/http/transport.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,9 +1086,6 @@ func (t *Transport) dialConn(ctx context.Context, cm connectMethod) (*persistCon
10861086
case cm.proxyURL.Scheme == "socks5":
10871087
conn := pconn.conn
10881088
d := socksNewDialer("tcp", conn.RemoteAddr().String())
1089-
d.ProxyDial = func(_ context.Context, _, _ string) (net.Conn, error) {
1090-
return conn, nil
1091-
}
10921089
if u := cm.proxyURL.User; u != nil {
10931090
auth := &socksUsernamePassword{
10941091
Username: u.Username(),
@@ -1100,7 +1097,7 @@ func (t *Transport) dialConn(ctx context.Context, cm connectMethod) (*persistCon
11001097
}
11011098
d.Authenticate = auth.Authenticate
11021099
}
1103-
if _, err := d.DialContext(ctx, "tcp", cm.targetAddr); err != nil {
1100+
if _, err := d.DialWithConn(ctx, conn, "tcp", cm.targetAddr); err != nil {
11041101
conn.Close()
11051102
return nil, err
11061103
}

0 commit comments

Comments
 (0)