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

Updates tailscale/tailscale#14393

Signed-off-by: kari-ts <kari@tailscale.com>
pull/15619/head
kari-ts 8 months ago committed by GitHub
parent 1da78d8718
commit 5c562116fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -4844,9 +4844,34 @@ func (b *LocalBackend) doSetHostinfoFilterServices() {
c := len(hi.Services) c := len(hi.Services)
hi.Services = append(hi.Services[:c:c], peerAPIServices...) hi.Services = append(hi.Services[:c:c], peerAPIServices...)
hi.PushDeviceToken = b.pushDeviceToken.Load() 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) 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 // NetMap returns the latest cached network map received from
// controlclient, or nil if no network map was received yet. // controlclient, or nil if no network map was received yet.
func (b *LocalBackend) NetMap() *netmap.NetworkMap { func (b *LocalBackend) NetMap() *netmap.NetworkMap {

Loading…
Cancel
Save