ipn: sort VIP services before hashing (#15035)

We're computing the list of services to hash by iterating over the
values of a map, the ordering of which is not guaranteed. This can cause
the hash to fluctuate depending on the ordering if there's more than one
service hosted by the same host.

Updates tailscale/corp#25733.

Signed-off-by: Naman Sood <mail@nsood.in>
push-wmvmtoxuoumt
Naman Sood 9 months ago committed by GitHub
parent 75a03fc719
commit a4b8c24834
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -8238,7 +8238,14 @@ func (b *LocalBackend) vipServicesFromPrefsLocked(prefs ipn.PrefsView) []*tailcf
services[sn].Active = true services[sn].Active = true
} }
return slicesx.MapValues(services) servicesList := slicesx.MapValues(services)
// [slicesx.MapValues] provides the values in an indeterminate order, but since we'll
// be hashing a representation of this list later we want it to be in a consistent
// order.
slices.SortFunc(servicesList, func(a, b *tailcfg.VIPService) int {
return strings.Compare(a.Name.String(), b.Name.String())
})
return servicesList
} }
var ( var (

Loading…
Cancel
Save