8000 proxy: expand Dialer interface to expose DialContext by sjpotter · Pull Request #164 · golang/net · GitHub
[go: up one dir, main page]

Skip to content

proxy: expand Dialer interface to expose DialContext #164

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
sjpotter committed Feb 6, 2023
commit 9178fd775914f6757c687b5a783a9b3aa86b04fb
5 changes: 5 additions & 0 deletions proxy/per_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ func (r *recordingProxy) Dial(network, addr string) (net.Conn, error) {
return nil, errors.New("recordingProxy")
}

func (r *recordingProxy) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
r.addrs = append(r.addrs, addr)
return nil, errors.New("recordingProxy")
}

func TestPerHost(t *testing.T) {
expectedDef := []string{
"example.com:123",
Expand Down
2 changes: 2 additions & 0 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package proxy // import "golang.org/x/net/proxy"

import (
"context"
"errors"
"net"
"net/url"
Expand All @@ -19,6 +20,7 @@ import (
type Dialer interface {
// Dial connects to the given address via the proxy.
Dial(network, addr string) (c net.Conn, err error)
DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

// Auth contains authentication parameters that specific Dialers may require.
Expand Down
0