mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-08 22:12:21 +00:00
ipn, wgengine: plumb NetworkMap down to magicsock
Now we can have magicsock make decisions based on tailcfg.Debug settings sent by the server. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
b8edb7a5e9
commit
fe50cd0c48
@@ -30,6 +30,7 @@ import (
|
||||
"github.com/tailscale/wireguard-go/wgcfg"
|
||||
"golang.org/x/time/rate"
|
||||
"inet.af/netaddr"
|
||||
"tailscale.com/control/controlclient"
|
||||
"tailscale.com/derp"
|
||||
"tailscale.com/derp/derphttp"
|
||||
"tailscale.com/ipn/ipnstate"
|
||||
@@ -107,6 +108,7 @@ type Conn struct {
|
||||
netInfoLast *tailcfg.NetInfo
|
||||
|
||||
derpMap *tailcfg.DERPMap // nil (or zero regions/nodes) means DERP is disabled
|
||||
netMap *controlclient.NetworkMap
|
||||
privateKey key.Private
|
||||
myDerp int // nearest DERP region ID; 0 means none/unknown
|
||||
derpStarted chan struct{} // closed on first connection to DERP; for tests
|
||||
@@ -1347,6 +1349,25 @@ func (c *Conn) SetDERPMap(dm *tailcfg.DERPMap) {
|
||||
go c.ReSTUN("derp-map-update")
|
||||
}
|
||||
|
||||
// SetNetworkMap is called when the control client gets a new network
|
||||
// map from the control server.
|
||||
//
|
||||
// It should not use the DERPMap field of NetworkMap; that's
|
||||
// conditionally sent to SetDERPMap instead.
|
||||
func (c *Conn) SetNetworkMap(nm *controlclient.NetworkMap) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
if reflect.DeepEqual(nm, c.netMap) {
|
||||
return
|
||||
}
|
||||
c.logf("magicsock: got updated network map")
|
||||
|
||||
c.netMap = nm
|
||||
// TODO: look at Debug fields
|
||||
// TODO: look at DiscoKey fields to reset AddrSet states when node restarts
|
||||
}
|
||||
|
||||
func (c *Conn) wantDerpLocked() bool { return c.derpMap != nil }
|
||||
|
||||
// c.mu must be held.
|
||||
|
||||
Reference in New Issue
Block a user