mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-26 03:25:35 +00:00
wgengine/magicsock: reconnect to DERP when its definition changes
Change-Id: I7c560feb9e4a6e155a35ec764a68354f19f694e4 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
506c727e30
commit
a201b89e4a
@ -2252,12 +2252,31 @@ func (c *Conn) SetDERPMap(dm *tailcfg.DERPMap) {
|
||||
return
|
||||
}
|
||||
|
||||
old := c.derpMap
|
||||
c.derpMap = dm
|
||||
if dm == nil {
|
||||
c.closeAllDerpLocked("derp-disabled")
|
||||
return
|
||||
}
|
||||
|
||||
// Reconnect any DERP region that changed definitions.
|
||||
if old != nil {
|
||||
changes := false
|
||||
for rid, oldDef := range old.Regions {
|
||||
if reflect.DeepEqual(oldDef, dm.Regions[rid]) {
|
||||
continue
|
||||
}
|
||||
changes = true
|
||||
if rid == c.myDerp {
|
||||
c.myDerp = 0
|
||||
}
|
||||
c.closeDerpLocked(rid, "derp-region-redefined")
|
||||
}
|
||||
if changes {
|
||||
c.logActiveDerpLocked()
|
||||
}
|
||||
}
|
||||
|
||||
go c.ReSTUN("derp-map-update")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user