1
0
mirror of https://github.com/juanfont/headscale.git synced 2026-02-07 20:04:00 +01:00
This commit is contained in:
Samy Djemaï 2026-02-19 15:12:57 -08:00 committed by GitHub
commit e45dfc6aed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -81,11 +81,13 @@ func loadDERPMapFromURL(addr url.URL) (*tailcfg.DERPMap, error) {
func mergeDERPMaps(derpMaps []*tailcfg.DERPMap) *tailcfg.DERPMap {
result := tailcfg.DERPMap{
OmitDefaultRegions: false,
HomeParams: &tailcfg.DERPHomeParams{},
Regions: map[int]*tailcfg.DERPRegion{},
}
for _, derpMap := range derpMaps {
maps.Copy(result.Regions, derpMap.Regions)
maps.Copy(result.HomeParams.RegionScore, derpMap.HomeParams.RegionScore)
}
for id, region := range result.Regions {
@ -94,6 +96,12 @@ func mergeDERPMaps(derpMaps []*tailcfg.DERPMap) *tailcfg.DERPMap {
}
}
for id, regionScore := range result.HomeParams.RegionScore {
if regionScore <= 0 {
delete(result.HomeParams.RegionScore, id)
}
}
return &result
}