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

9538e9f97035ce7a382d2b395db3368bd0326113 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 

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
Co-authored-by: Rhea Ghosh <rhea@tailscale.com>
This commit is contained in:
Joe Tsai 2023-09-20 13:46:19 -07:00 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
}
}
if b.netMap == nil {
return zero, u, false
}
n, ok = b.peers[nid]
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()]
if !ok {