From 17b441c993d4f947ddeca7dde74e02ac7db72905 Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Thu, 23 Jan 2020 21:37:35 +0000 Subject: [PATCH] lib/relays: Fix incorrect timeout, bring back logging (ref #6289) (#6291) * lib/relays: Fix incorrect timeout, bring back logging (ref #6289) * Fix format strings --- lib/dialer/public.go | 10 ++++++++-- lib/relay/client/static.go | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/dialer/public.go b/lib/dialer/public.go index 30cf6c9ac..6014aa932 100644 --- a/lib/dialer/public.go +++ b/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 diff --git a/lib/relay/client/static.go b/lib/relay/client/static.go index f977564ba..28f8371f9 100644 --- a/lib/relay/client/static.go +++ b/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 {