diff --git a/proxy/proxy.go b/proxy/proxy.go index eef7a7a..15c45f0 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -25,17 +25,13 @@ func GetTransport(proxy string) (http.RoundTripper, error) { return proxyTcp(proxyUrl) } -type forwardDialer struct { - dialContext func(ctx context.Context, network, address string) (net.Conn, error) -} +type forwardDialer func(ctx context.Context, network, address string) (net.Conn, error) -func (d *forwardDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) { - return d.dialContext(ctx, network, address) +func (d forwardDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) { + return d(ctx, network, address) } -func (d *forwardDialer) Dial(network, address string) (net.Conn, error) { +func (d forwardDialer) Dial(network, address string) (net.Conn, error) { panic("Dial should not be called") - //default Dial is nil - //return defaultTransport().Dial(network, address) } func unixSocks5Proxy(proxyUrl *url.URL) (http.RoundTripper, error) { @@ -53,7 +49,7 @@ func unixSocks5Proxy(proxyUrl *url.URL) (http.RoundTripper, error) { Password: password, } } - dialer, err := proxy.SOCKS5("unix", proxyUrl.Path, auth, &forwardDialer{trans.DialContext}) + dialer, err := proxy.SOCKS5("unix", proxyUrl.Path, auth, forwardDialer(trans.DialContext)) if err != nil { return nil, fmt.Errorf("failed to make socks proxy, url: %s, err: %w", proxyUrl, err) }