Browse Source

lib/relays: Fix incorrect timeout, bring back logging (ref #6289) (#6291)

* lib/relays: Fix incorrect timeout, bring back logging (ref #6289)

* Fix format strings
Audrius Butkevicius 5 years ago
parent
commit
17b441c993
2 changed files with 9 additions and 3 deletions
  1. 8 2
      lib/dialer/public.go
  2. 1 1
      lib/relay/client/static.go

+ 8 - 2
lib/dialer/public.go

@@ -65,10 +65,14 @@ func dialContextWithFallback(ctx context.Context, fallback proxy.ContextDialer,
 		return nil, errUnexpectedInterfaceType
 	}
 	if dialer == proxy.Direct {
-		return fallback.DialContext(ctx, network, addr)
+		conn, err := fallback.DialContext(ctx, network, addr)
+		l.Debugf("Dialing direct result %s %s: %v %v", network, addr, conn, err)
+		return conn, err
 	}
 	if noFallback {
-		return dialer.DialContext(ctx, network, addr)
+		conn, err := dialer.DialContext(ctx, network, addr)
+		l.Debugf("Dialing no fallback result %s %s: %v %v", network, addr, conn, err)
+		return conn, err
 	}
 
 	ctx, cancel := context.WithCancel(ctx)
@@ -79,10 +83,12 @@ func dialContextWithFallback(ctx context.Context, fallback proxy.ContextDialer,
 	fallbackDone := make(chan struct{})
 	go func() {
 		proxyConn, proxyErr = dialer.DialContext(ctx, network, addr)
+		l.Debugf("Dialing proxy result %s %s: %v %v", network, addr, proxyConn, proxyErr)
 		close(proxyDone)
 	}()
 	go func() {
 		fallbackConn, fallbackErr = fallback.DialContext(ctx, network, addr)
+		l.Debugf("Dialing fallback result %s %s: %v %v", network, addr, fallbackConn, fallbackErr)
 		close(fallbackDone)
 	}()
 	<-proxyDone

+ 1 - 1
lib/relay/client/static.go

@@ -152,7 +152,7 @@ func (c *staticClient) connect(ctx context.Context) error {
 	}
 
 	t0 := time.Now()
-	timeoutCtx, cancel := context.WithTimeout(ctx, time.Second)
+	timeoutCtx, cancel := context.WithTimeout(ctx, c.connectTimeout)
 	defer cancel()
 	tcpConn, err := dialer.DialContext(timeoutCtx, "tcp", c.uri.Host)
 	if err != nil {