From 315efbd0725fe65c6751367bdca0cbd12ea48c8f Mon Sep 17 00:00:00 2001 From: balki <3070606-balki@users.noreply.gitlab.com> Date: Tue, 31 May 2022 17:28:53 -0400 Subject: [PATCH] minor simplification --- proxy/proxy.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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) }