ipn/ipnlocal: fix LocalBackend.WhoIs for self (#9472)

9538e9f970 broke LocalBackend.WhoIs
where you can no longer lookup yourself in WhoIs.
This occurs because the LocalBackend.peers map only contains peers.
If we fail to lookup a peer, double-check whether it is ourself.

Fixes #9470

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
Co-authored-by: Rhea Ghosh <rhea@tailscale.com>
pull/9487/head
Joe Tsai 1 year ago committed by GitHub
parent c5b2a365de
commit ae89482f25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -868,9 +868,16 @@ func (b *LocalBackend) WhoIs(ipp netip.AddrPort) (n tailcfg.NodeView, u tailcfg.
return zero, u, false return zero, u, false
} }
} }
if b.netMap == nil {
return zero, u, false
}
n, ok = b.peers[nid] n, ok = b.peers[nid]
if !ok { if !ok {
return zero, u, false // Check if this the self-node, which would not appear in peers.
if !b.netMap.SelfNode.Valid() || nid != b.netMap.SelfNode.ID() {
return zero, u, false
}
n = b.netMap.SelfNode
} }
u, ok = b.netMap.UserProfiles[n.User()] u, ok = b.netMap.UserProfiles[n.User()]
if !ok { if !ok {

Loading…
Cancel
Save