Skip to content

Commit 9178fd7

Browse files
committed
proxy: expand Dialer interface to expose DialContext
currently, the Dialer interface returned (from say proxy.SOCKS5()) only exposes the Dial function, while it has a DialContext function as well. As Dial() usage is deprecated, DialContext should be exposed as well. All implementations in proxy already had a DialContext function besides a single test recording struct, so added a similiar recorder to it.
1 parent 296f09a commit 9178fd7

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

proxy/per_host_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ func (r *recordingProxy) Dial(network, addr string) (net.Conn, error) {
2121
return nil, errors.New("recordingProxy")
2222
}
2323

24+
func (r *recordingProxy) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
25+
r.addrs = append(r.addrs, addr)
26+
return nil, errors.New("recordingProxy")
27+
}
28+
2429
func TestPerHost(t *testing.T) {
2530
expectedDef := []string{
2631
"example.com:123",

proxy/proxy.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package proxy // import "golang.org/x/net/proxy"
88

99
import (
10+
"context"
1011
"errors"
1112
"net"
1213
"net/url"
@@ -19,6 +20,7 @@ import (
1920
type Dialer interface {
2021
// Dial connects to the given address via the proxy.
2122
Dial(network, addr string) (c net.Conn, err error)
23+
DialContext(ctx context.Context, network, address string) (net.Conn, error)
2224
}
2325

2426
// Auth contains authentication parameters that specific Dialers may require.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy