From ed792b97c0de66b1d7541842f35c33d016aadc3c Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Thu, 26 Nov 2015 23:41:11 +0000 Subject: [PATCH] Take timeout into account when dialing --- lib/relay/client/methods.go | 2 +- lib/relay/client/static.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/relay/client/methods.go b/lib/relay/client/methods.go index 831118b3d..3376e1d24 100644 --- a/lib/relay/client/methods.go +++ b/lib/relay/client/methods.go @@ -21,7 +21,7 @@ func GetInvitationFromRelay(uri *url.URL, id syncthingprotocol.DeviceID, certs [ return protocol.SessionInvitation{}, fmt.Errorf("Unsupported relay scheme: %v", uri.Scheme) } - rconn, err := dialer.Dial("tcp", uri.Host) + rconn, err := dialer.DialTimeout("tcp", uri.Host, timeout) if err != nil { return protocol.SessionInvitation{}, err } diff --git a/lib/relay/client/static.go b/lib/relay/client/static.go index 26fd70cfb..d56a9a318 100644 --- a/lib/relay/client/static.go +++ b/lib/relay/client/static.go @@ -9,6 +9,7 @@ import ( "net/url" "time" + "github.com/syncthing/syncthing/lib/dialer" syncthingprotocol "github.com/syncthing/syncthing/lib/protocol" "github.com/syncthing/syncthing/lib/relay/protocol" "github.com/syncthing/syncthing/lib/sync" @@ -189,7 +190,7 @@ func (c *staticClient) connect() error { } t0 := time.Now() - tcpConn, err := net.Dial("tcp", c.uri.Host) + tcpConn, err := dialer.DialTimeout("tcp", c.uri.Host, c.connectTimeout) if err != nil { return err }