]> Sergey Matveev's repositories - btrtrc.git/commitdiff
propagate proxy url parsing err
authorSteve Yoon <sick.yoon@gmail.com>
Mon, 30 Dec 2019 17:58:06 +0000 (12:58 -0500)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 1 Jan 2020 23:18:14 +0000 (09:18 +1000)
socket.go

index 56b3eba5f162e6ead772707910887bce774a8a97..d61e3d32819763aa42aa7a4008be99f264d031bf 100644 (file)
--- a/socket.go
+++ b/socket.go
@@ -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