magicsock: start connection to HOME derp immediately

The code as written intended to do this, but it repeated the
comparison of derpNum and c.myDerp after c.myDerp had been
updated, so it never executed.

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
This commit is contained in:
David Crawshaw 2020-03-19 17:32:31 +11:00
parent 73cae4eb11
commit 455ba751d9
1 changed files with 3 additions and 2 deletions

View File

@ -400,13 +400,14 @@ func (c *Conn) setNearestDERP(derpNum int) (wantDERP bool) {
// No change.
return true
}
// On change, notify all currently connected DERP servers and
// start connecting to our home DERP if we are not already.
c.myDerp = derpNum
c.logf("home DERP server is now %v, %v", derpNum, c.derps.ServerByID(derpNum))
for i, ad := range c.activeDerp {
go ad.c.NotePreferred(i == c.myDerp)
}
if derpNum != 0 && derpNum != c.myDerp {
// On change, start connecting to it:
if derpNum != 0 {
go c.derpWriteChanOfAddr(&net.UDPAddr{IP: derpMagicIP, Port: derpNum})
}
return true