propagate proxy url parsing err

This commit is contained in:
Steve Yoon 2019-12-30 12:58:06 -05:00 committed by Matt Joiner
parent 32579e72c7
commit d34dfa6575
1 changed files with 11 additions and 12 deletions

View File

@ -56,18 +56,15 @@ func listenTcp(network, address, proxyURL string) (s socket, err error) {
// If we don't need the proxy - then we should return default net.Dialer,
// otherwise, let's try to parse the proxyURL and return proxy.Dialer
if len(proxyURL) != 0 {
dl := disabledListener{l}
// TODO: The error should be propagated, as proxy may be in use for
// security or privacy reasons. Also just pass proxy.Dialer in from
// the Config.
if dialer, err := getProxyDialer(proxyURL); err == nil {
return tcpSocket{dl, func(ctx context.Context, addr string) (conn net.Conn, err error) {
defer perf.ScopeTimerErr(&err)()
return dialer.Dial(network, addr)
}}, nil
dialer, err := getProxyDialer(proxyURL)
if err != nil {
return nil, err
}
return tcpSocket{dl, func(ctx context.Context, addr string) (conn net.Conn, err error) {
defer perf.ScopeTimerErr(&err)()
return dialer.Dial(network, addr)
}}, nil
}
dialer := net.Dialer{}
return tcpSocket{l, func(ctx context.Context, addr string) (conn net.Conn, err error) {
@ -154,9 +151,11 @@ func listenUtp(network, addr, proxyURL string, fc firewallCallback) (s socket, e
// otherwise, let's try to parse the proxyURL and return proxy.Dialer
if len(proxyURL) != 0 {
ds := disabledUtpSocket{us}
if dialer, err := getProxyDialer(proxyURL); err == nil {
return utpSocketSocket{ds, network, dialer}, nil
dialer, err := getProxyDialer(proxyURL)
if err != nil {
return nil, err
}
return utpSocketSocket{ds, network, dialer}, nil
}
return utpSocketSocket{us, network, nil}, nil