From 000c02dad9412154a5a06b13d973a1dee5010dfc Mon Sep 17 00:00:00 2001 From: Juan Font Date: Tue, 13 Dec 2022 22:29:50 +0000 Subject: [PATCH] Show online in CLI & API when isOnline() reports so --- cmd/headscale/cli/nodes.go | 4 +--- machine.go | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/headscale/cli/nodes.go b/cmd/headscale/cli/nodes.go index a5a10069..bb563fce 100644 --- a/cmd/headscale/cli/nodes.go +++ b/cmd/headscale/cli/nodes.go @@ -513,9 +513,7 @@ func nodesToPtables( } var online string - if lastSeen.After( - time.Now().Add(-5 * time.Minute), - ) { // TODO: Find a better way to reliably show if online + if machine.Online { online = pterm.LightGreen("online") } else { online = pterm.LightRed("offline") diff --git a/machine.go b/machine.go index 9be7204e..2aae7911 100644 --- a/machine.go +++ b/machine.go @@ -767,6 +767,7 @@ func (machine *Machine) toProto() *v1.Machine { GivenName: machine.GivenName, Namespace: machine.Namespace.toProto(), ForcedTags: machine.ForcedTags, + Online: machine.isOnline(), // TODO(kradalby): Implement register method enum converter // RegisterMethod: ,