ipnlocal: log when client reports new peerAPI ports (#15463)

Updates tailscale/tailscale#14393

Signed-off-by: kari-ts <kari@tailscale.com>
This commit is contained in:
kari-ts 2025-04-09 16:49:33 -07:00 committed by GitHub
parent 1da78d8718
commit 5c562116fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4844,9 +4844,34 @@ func (b *LocalBackend) doSetHostinfoFilterServices() {
c := len(hi.Services)
hi.Services = append(hi.Services[:c:c], peerAPIServices...)
hi.PushDeviceToken = b.pushDeviceToken.Load()
// Compare the expected ports from peerAPIServices to the actual ports in hi.Services.
expectedPorts := extractPeerAPIPorts(peerAPIServices)
actualPorts := extractPeerAPIPorts(hi.Services)
if expectedPorts != actualPorts {
b.logf("Hostinfo peerAPI ports changed: expected %v, got %v", expectedPorts, actualPorts)
}
cc.SetHostinfo(&hi)
}
type portPair struct {
v4, v6 uint16
}
func extractPeerAPIPorts(services []tailcfg.Service) portPair {
var p portPair
for _, s := range services {
switch s.Proto {
case "peerapi4":
p.v4 = s.Port
case "peerapi6":
p.v6 = s.Port
}
}
return p
}
// NetMap returns the latest cached network map received from
// controlclient, or nil if no network map was received yet.
func (b *LocalBackend) NetMap() *netmap.NetworkMap {