Take timeout into account when dialing

This commit is contained in:
Audrius Butkevicius 2015-11-26 23:41:11 +00:00
parent a4b8c2298a
commit ed792b97c0
2 changed files with 3 additions and 2 deletions

View File

@ -21,7 +21,7 @@ func GetInvitationFromRelay(uri *url.URL, id syncthingprotocol.DeviceID, certs [
return protocol.SessionInvitation{}, fmt.Errorf("Unsupported relay scheme: %v", uri.Scheme) 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 { if err != nil {
return protocol.SessionInvitation{}, err return protocol.SessionInvitation{}, err
} }

View File

@ -9,6 +9,7 @@ import (
"net/url" "net/url"
"time" "time"
"github.com/syncthing/syncthing/lib/dialer"
syncthingprotocol "github.com/syncthing/syncthing/lib/protocol" syncthingprotocol "github.com/syncthing/syncthing/lib/protocol"
"github.com/syncthing/syncthing/lib/relay/protocol" "github.com/syncthing/syncthing/lib/relay/protocol"
"github.com/syncthing/syncthing/lib/sync" "github.com/syncthing/syncthing/lib/sync"
@ -189,7 +190,7 @@ func (c *staticClient) connect() error {
} }
t0 := time.Now() t0 := time.Now()
tcpConn, err := net.Dial("tcp", c.uri.Host) tcpConn, err := dialer.DialTimeout("tcp", c.uri.Host, c.connectTimeout)
if err != nil { if err != nil {
return err return err
} }