From e4ef65be761dd1b4d65e0f3ccc4c07130d28b0b1 Mon Sep 17 00:00:00 2001 From: Silver Bullet Date: Thu, 2 Sep 2021 05:44:42 +0800 Subject: [PATCH 1/2] fix: check last seen time without possible null pointer --- cmd/headscale/cli/nodes.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/headscale/cli/nodes.go b/cmd/headscale/cli/nodes.go index d72201c9..7afc6026 100644 --- a/cmd/headscale/cli/nodes.go +++ b/cmd/headscale/cli/nodes.go @@ -154,8 +154,10 @@ func nodesToPtables(m []headscale.Machine) (pterm.TableData, error) { ephemeral = true } var lastSeen time.Time + var lastSeenTime string if m.LastSeen != nil { lastSeen = *m.LastSeen + lastSeenTime = lastSeen.Format("2006-01-02 15:04:05") } nKey, err := wgkey.ParseHex(m.NodeKey) if err != nil { @@ -164,12 +166,12 @@ func nodesToPtables(m []headscale.Machine) (pterm.TableData, error) { nodeKey := tailcfg.NodeKey(nKey) var online string - if m.LastSeen.After(time.Now().Add(-5 * time.Minute)) { // TODO: Find a better way to reliably show if online + if lastSeen.After(time.Now().Add(-5 * time.Minute)) { // TODO: Find a better way to reliably show if online online = pterm.LightGreen("true") } else { online = pterm.LightRed("false") } - d = append(d, []string{strconv.FormatUint(m.ID, 10), m.Name, nodeKey.ShortString(), m.IPAddress, strconv.FormatBool(ephemeral), lastSeen.Format("2006-01-02 15:04:05"), online}) + d = append(d, []string{strconv.FormatUint(m.ID, 10), m.Name, nodeKey.ShortString(), m.IPAddress, strconv.FormatBool(ephemeral), lastSeenTime, online}) } return d, nil } From 6faaae0c5f3aa1465b9cf6fa8145e73b72b679a2 Mon Sep 17 00:00:00 2001 From: Silver Bullet Date: Thu, 2 Sep 2021 06:08:12 +0800 Subject: [PATCH 2/2] docs: add notes on how to build own DERP server The official doc is hidden under a bunch of issues. Add a doc link here and hope it could be helpful. --- derp.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/derp.yaml b/derp.yaml index 17bfc186..9434e712 100644 --- a/derp.yaml +++ b/derp.yaml @@ -1,7 +1,7 @@ # This file contains some of the official Tailscale DERP servers, # shamelessly taken from https://github.com/tailscale/tailscale/blob/main/net/dnsfallback/dns-fallback-servers.json # -# If you plan to somehow use headscale, please deploy your own DERP infra +# If you plan to somehow use headscale, please deploy your own DERP infra: https://tailscale.com/kb/1118/custom-derp-servers/ regions: 1: regionid: 1