From 294ceb513c738bf4338d2cbc94e6b864bfdda3d4 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 15 Dec 2020 18:45:13 -0800 Subject: [PATCH] ipn, wgengine/magicsock: fix `tailscale status` display. Signed-off-by: David Anderson --- ipn/local.go | 10 ++++++++-- wgengine/magicsock/magicsock.go | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ipn/local.go b/ipn/local.go index 52d24e67f..a3c1a6861 100644 --- a/ipn/local.go +++ b/ipn/local.go @@ -209,8 +209,14 @@ func (b *LocalBackend) UpdateStatus(sb *ipnstate.StatusBuilder) { lastSeen = *p.LastSeen } var tailAddr string - if len(p.Addresses) > 0 { - tailAddr = strings.TrimSuffix(p.Addresses[0].String(), "/32") + for _, addr := range p.Addresses { + // The peer struct currently only allows a single + // Tailscale IP address. For compatibility with the + // old display, make sure it's the IPv4 address. + if addr.IP.Is4() && addr.Mask == 32 && tsaddr.IsTailscaleIP(netaddr.IPFrom16(addr.IP.Addr)) { + tailAddr = addr.IP.String() + break + } } sb.AddPeer(key.Public(p.Key), &ipnstate.PeerStatus{ InNetworkMap: true, diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index 185c4ee8a..2d595bb4d 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -2725,7 +2725,12 @@ func (c *Conn) UpdateStatus(sb *ipnstate.StatusBuilder) { continue } sb.AddTailscaleIP(ip) - ss.TailAddr = ip.String() + // TailAddr only allows for a single Tailscale IP. For + // readability of `tailscale status`, make it the IPv4 + // address. + if addr.IP.Is4() { + ss.TailAddr = ip.String() + } } } sb.SetSelfStatus(ss)