mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-26 05:09:41 +00:00
net/netcheck, tailcfg: add DERPHomeParams and use it
This allows providing additional information to the client about how to select a home DERP region, such as preferring a given DERP region over all others. Updates #8603 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: I7c4a270f31d8585112fab5408799ffba5b75266f
This commit is contained in:
@@ -90,9 +90,28 @@ func (ms *mapSession) netmapForResponse(resp *tailcfg.MapResponse) *netmap.Netwo
|
||||
ms.lastUserProfile[up.ID] = up
|
||||
}
|
||||
|
||||
if resp.DERPMap != nil {
|
||||
if dm := resp.DERPMap; dm != nil {
|
||||
ms.vlogf("netmap: new map contains DERP map")
|
||||
ms.lastDERPMap = resp.DERPMap
|
||||
|
||||
// Zero-valued fields in a DERPMap mean that we're not changing
|
||||
// anything and are using the previous value(s).
|
||||
if ldm := ms.lastDERPMap; ldm != nil {
|
||||
if dm.Regions == nil {
|
||||
dm.Regions = ldm.Regions
|
||||
dm.OmitDefaultRegions = ldm.OmitDefaultRegions
|
||||
}
|
||||
if dm.HomeParams == nil {
|
||||
dm.HomeParams = ldm.HomeParams
|
||||
} else if oldhh := ldm.HomeParams; oldhh != nil {
|
||||
// Propagate sub-fields of HomeParams
|
||||
hh := dm.HomeParams
|
||||
if hh.RegionScore == nil {
|
||||
hh.RegionScore = oldhh.RegionScore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ms.lastDERPMap = dm
|
||||
}
|
||||
|
||||
if pf := resp.PacketFilter; pf != nil {
|
||||
|
Reference in New Issue
Block a user