cmd/tailscale: add tailscale status region name, last write, consistently star

There's a lot of confusion around what tailscale status shows, so make it better:
show region names, last write time, and put stars around DERP too if active.

Now stars are always present if activity, and always somewhere.
This commit is contained in:
Brad Fitzpatrick
2020-07-03 13:44:22 -07:00
parent 0ea51872c9
commit 630379a1d0
3 changed files with 89 additions and 28 deletions

View File

@@ -14,6 +14,7 @@ import (
"net"
"net/http"
"os"
"time"
"github.com/peterbourgon/ff/v2/ffcli"
"github.com/toqueteos/webbrowser"
@@ -127,6 +128,15 @@ func runStatus(ctx context.Context, args []string) error {
ps.TxBytes,
ps.RxBytes,
)
// TODO: let server report this active bool instead
active := !ps.LastWrite.IsZero() && time.Since(ps.LastWrite) < 2*time.Minute
relay := ps.Relay
if active && relay != "" && ps.CurAddr == "" {
relay = "*" + relay + "*"
} else {
relay = " " + relay
}
f("%-6s", relay)
for i, addr := range ps.Addrs {
if i != 0 {
f(", ")