mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-21 10:27:30 +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:
@@ -7,6 +7,11 @@ import "sort"
|
||||
|
||||
// DERPMap describes the set of DERP packet relay servers that are available.
|
||||
type DERPMap struct {
|
||||
// HomeParams, if non-nil, is a change in home parameters.
|
||||
//
|
||||
// The rest of the DEPRMap fields, if zero, means unchanged.
|
||||
HomeParams *DERPHomeParams `json:",omitempty"`
|
||||
|
||||
// Regions is the set of geographic regions running DERP node(s).
|
||||
//
|
||||
// It's keyed by the DERPRegion.RegionID.
|
||||
@@ -16,6 +21,8 @@ type DERPMap struct {
|
||||
|
||||
// OmitDefaultRegions specifies to not use Tailscale's DERP servers, and only use those
|
||||
// specified in this DERPMap. If there are none set outside of the defaults, this is a noop.
|
||||
//
|
||||
// This field is only meaningful if the Regions map is non-nil (indicating a change).
|
||||
OmitDefaultRegions bool `json:"omitDefaultRegions,omitempty"`
|
||||
}
|
||||
|
||||
@@ -29,6 +36,25 @@ func (m *DERPMap) RegionIDs() []int {
|
||||
return ret
|
||||
}
|
||||
|
||||
// DERPHomeParams contains parameters from the server related to selecting a
|
||||
// DERP home region (sometimes referred to as the "preferred DERP").
|
||||
type DERPHomeParams struct {
|
||||
// RegionScore scales latencies of DERP regions by a given scaling
|
||||
// factor when determining which region to use as the home
|
||||
// ("preferred") DERP. Scores in the range (0, 1) will cause this
|
||||
// region to be proportionally more preferred, and scores in the range
|
||||
// (1, ∞) will penalize a region.
|
||||
//
|
||||
// If a region is not present in this map, it is treated as having a
|
||||
// score of 1.0.
|
||||
//
|
||||
// Scores should not be 0 or negative; such scores will be ignored.
|
||||
//
|
||||
// A nil map means no change from the previous value (if any); an empty
|
||||
// non-nil map can be sent to reset all scores back to 1.0.
|
||||
RegionScore map[int]float64 `json:",omitempty"`
|
||||
}
|
||||
|
||||
// DERPRegion is a geographic region running DERP relay node(s).
|
||||
//
|
||||
// Client nodes discover which region they're closest to, advertise
|
||||
|
Reference in New Issue
Block a user