lib/connections: Parallel dials in the same priority (fixes #4456)

Well Tested(TM)

Introduces a potential issue where we always pick some connectable but dodgy connection that breaks
soon after the TLS handshake.

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4489
This commit is contained in:
AudriusButkevicius
2017-11-15 09:36:33 +00:00
committed by Jakob Borg
parent 783dd612f7
commit aecd7c64ce
2 changed files with 91 additions and 9 deletions

View File

@@ -177,3 +177,17 @@ func (o *onAddressesChangedNotifier) notifyAddressesChanged(l genericListener) {
callback(l)
}
}
type dialTarget struct {
dialer genericDialer
priority int
uri *url.URL
deviceID protocol.DeviceID
}
func (t dialTarget) Dial() (internalConn, error) {
l.Debugln("dialing", t.deviceID, t.uri, "prio", t.priority)
conn, err := t.dialer.Dial(t.deviceID, t.uri)
l.Debugln("dialing", t.deviceID, t.uri, "outcome", conn, err)
return conn, err
}