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

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

* Fix format strings
This commit is contained in:
Audrius Butkevicius 2020-01-23 21:37:35 +00:00 committed by GitHub
parent b9879e2013
commit 17b441c993
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

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

View File

@ -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 {