minor simplification

This commit is contained in:
Balakrishnan Balasubramanian 2022-05-31 17:28:53 -04:00
parent 2540e9b5fc
commit 315efbd072

View File

@ -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)
}