From 33c541ae30971c7efec702c13a74f0476d495d3a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 25 Nov 2021 17:11:01 -0800 Subject: [PATCH] ipn/ipnlocal: populate self status from netmap in ipnlocal, not magicsock. Fixes #1933 Signed-off-by: David Anderson --- ipn/ipnlocal/local.go | 14 ++++++++++++-- wgengine/magicsock/magicsock.go | 13 ------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 563173151..16df12770 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -350,8 +350,18 @@ func (b *LocalBackend) updateStatus(sb *ipnstate.StatusBuilder, extraLocked func } }) sb.MutateSelfStatus(func(ss *ipnstate.PeerStatus) { - if b.netMap != nil && b.netMap.SelfNode != nil { - ss.ID = b.netMap.SelfNode.StableID + if b.netMap != nil { + ss.HostName = b.netMap.Hostinfo.Hostname + ss.DNSName = b.netMap.Name + ss.UserID = b.netMap.User + if sn := b.netMap.SelfNode; sn != nil { + ss.ID = sn.StableID + if c := sn.Capabilities; len(c) > 0 { + ss.Capabilities = append([]string(nil), c...) + } + } + } else { + ss.HostName, _ = os.Hostname() } for _, pln := range b.peerAPIListeners { ss.PeerAPIURL = append(ss.PeerAPIURL, pln.urlStr) diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index 1ac79616f..7f9e2f7b4 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -17,7 +17,6 @@ "math" "math/rand" "net" - "os" "reflect" "runtime" "sort" @@ -3129,18 +3128,6 @@ func (c *Conn) UpdateStatus(sb *ipnstate.StatusBuilder) { ss.Addrs = append(ss.Addrs, ep.Addr.String()) } ss.OS = version.OS() - if c.netMap != nil { - ss.HostName = c.netMap.Hostinfo.Hostname - ss.DNSName = c.netMap.Name - ss.UserID = c.netMap.User - if c.netMap.SelfNode != nil { - if c := c.netMap.SelfNode.Capabilities; len(c) > 0 { - ss.Capabilities = append([]string(nil), c...) - } - } - } else { - ss.HostName, _ = os.Hostname() - } if c.derpMap != nil { derpRegion, ok := c.derpMap.Regions[c.myDerp] if ok {