MCPcopy Index your code
hub / github.com/coder/coder / CompareDERPMaps

Function CompareDERPMaps

tailnet/derpmap.go:207–231  ·  view source on GitHub ↗

CompareDERPMaps returns true if the given DERPMaps are equivalent. Ordering of slices is ignored. If the first map is nil, the second map must also be nil for them to be considered equivalent. If the second map is nil, the first map can be any value and the function will return true.

(a *tailcfg.DERPMap, b *tailcfg.DERPMap)

Source from the content-addressed store, hash-verified

205// considered equivalent. If the second map is nil, the first map can be any
206// value and the function will return true.
207func CompareDERPMaps(a *tailcfg.DERPMap, b *tailcfg.DERPMap) bool {
208 if a == nil {
209 return b == nil
210 }
211 if b == nil {
212 return true
213 }
214 if len(a.Regions) != len(b.Regions) {
215 return false
216 }
217 if a.OmitDefaultRegions != b.OmitDefaultRegions {
218 return false
219 }
220
221 for id, region := range a.Regions {
222 other, ok := b.Regions[id]
223 if !ok {
224 return false
225 }
226 if !compareDERPRegions(region, other) {
227 return false
228 }
229 }
230 return true
231}
232
233func compareDERPRegions(a *tailcfg.DERPRegion, b *tailcfg.DERPRegion) bool {
234 if a == nil || b == nil {

Callers 5

derpMapUpdatesMethod · 0.92
pollDERPMethod · 0.92
TestManifestFunction · 0.92
setDERPMapMethod · 0.85
StreamDERPMapsMethod · 0.85

Calls 1

compareDERPRegionsFunction · 0.85

Tested by 1

TestManifestFunction · 0.74