From 8f43ddf1a2dc52d3e1eda9611353c299c3396e78 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 16 Dec 2021 08:06:32 -0800 Subject: [PATCH] ipn/ipnlocal, health: populate self node's Online bit in tailscale status One option was to just hide "offline" in the text output, but that doesn't fix the JSON output. The next option was to lie and say it's online in the JSON (which then fixes the "offline" in the text output). But instead, this sets the self node's "Online" to whether we're in an active map poll. Fixes #3564 Change-Id: I9b379989bd14655198959e37eec39bb570fb814a Signed-off-by: Brad Fitzpatrick --- health/health.go | 11 ++++++++++- ipn/ipnlocal/local.go | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/health/health.go b/health/health.go index 5c004b589..48beec3df 100644 --- a/health/health.go +++ b/health/health.go @@ -168,7 +168,8 @@ func GotStreamedMapResponse() { selfCheckLocked() } -// SetInPollNetMap records that we're in +// SetInPollNetMap records whether the client has an open +// HTTP long poll open to the control plane. func SetInPollNetMap(v bool) { mu.Lock() defer mu.Unlock() @@ -183,6 +184,14 @@ func SetInPollNetMap(v bool) { } } +// GetInPollNetMap reports whether the client has an open +// HTTP long poll open to the control plane. +func GetInPollNetMap() bool { + mu.Lock() + defer mu.Unlock() + return inMapPoll +} + // SetMagicSockDERPHome notes what magicsock's view of its home DERP is. func SetMagicSockDERPHome(region int) { mu.Lock() diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index d1805ef34..8cc0e3809 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -380,6 +380,7 @@ func (b *LocalBackend) updateStatus(sb *ipnstate.StatusBuilder, extraLocked func } }) sb.MutateSelfStatus(func(ss *ipnstate.PeerStatus) { + ss.Online = health.GetInPollNetMap() if b.netMap != nil { ss.HostName = b.netMap.Hostinfo.Hostname ss.DNSName = b.netMap.Name