From a046b48593252dd0956eb1b0b17430df89e9af5b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 5 Feb 2021 13:07:48 -0800 Subject: [PATCH] cmd/tailscale/cli: display currently active exit node in `tailscale status`. Signed-off-by: David Anderson --- cmd/tailscale/cli/status.go | 7 ++++++- ipn/ipnlocal/local.go | 1 + ipn/ipnstate/ipnstate.go | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/tailscale/cli/status.go b/cmd/tailscale/cli/status.go index f4f8c78ad..dde138fa2 100644 --- a/cmd/tailscale/cli/status.go +++ b/cmd/tailscale/cli/status.go @@ -159,13 +159,18 @@ func runStatus(ctx context.Context, args []string) error { relay := ps.Relay anyTraffic := ps.TxBytes != 0 || ps.RxBytes != 0 if !active { - if anyTraffic { + if ps.ExitNode { + f("idle; exit node") + } else if anyTraffic { f("idle") } else { f("-") } } else { f("active; ") + if ps.ExitNode { + f("exit node; ") + } if relay != "" && ps.CurAddr == "" { f("relay %q", relay) } else if ps.CurAddr != "" { diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 1bd974ad3..ffd37ce2a 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -234,6 +234,7 @@ func (b *LocalBackend) UpdateStatus(sb *ipnstate.StatusBuilder) { Created: p.Created, LastSeen: lastSeen, ShareeNode: p.Hostinfo.ShareeNode, + ExitNode: p.StableID != "" && p.StableID == b.prefs.ExitNodeID, }) } } diff --git a/ipn/ipnstate/ipnstate.go b/ipn/ipnstate/ipnstate.go index 3f2d359f7..6d713bc78 100644 --- a/ipn/ipnstate/ipnstate.go +++ b/ipn/ipnstate/ipnstate.go @@ -77,6 +77,7 @@ type PeerStatus struct { LastSeen time.Time // last seen to tailcontrol LastHandshake time.Time // with local wireguard KeepAlive bool + ExitNode bool // true if this is the currently selected exit node. // ShareeNode indicates this node exists in the netmap because // it's owned by a shared-to user and that node might connect @@ -244,6 +245,9 @@ func (sb *StatusBuilder) AddPeer(peer key.Public, st *PeerStatus) { if st.KeepAlive { e.KeepAlive = true } + if st.ExitNode { + e.ExitNode = true + } if st.ShareeNode { e.ShareeNode = true }