ipn/ipnstate: add PeerStatus.KeyExpiry for tailscale status --json

Fixes #6712

Change-Id: I817cd5342fac8a956fcefda2d63158fa488f3395
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2023-01-23 12:33:58 -08:00
committed by Brad Fitzpatrick
parent b6aa1c1f22
commit 06fff461dc
4 changed files with 14 additions and 2 deletions

View File

@@ -723,6 +723,10 @@ func peerStatusFromNode(ps *ipnstate.PeerStatus, n *tailcfg.Node) {
if n.Expired {
ps.Expired = true
}
if t := n.KeyExpiry; !t.IsZero() {
t = t.Round(time.Second)
ps.KeyExpiry = &t
}
}
// WhoIs reports the node and user who owns the node with the given IP:port.

View File

@@ -20,6 +20,7 @@ import (
"tailscale.com/tailcfg"
"tailscale.com/types/key"
"tailscale.com/types/ptr"
"tailscale.com/types/views"
"tailscale.com/util/dnsname"
)
@@ -251,6 +252,10 @@ type PeerStatus struct {
// information from control or optimisically set on the client if the
// expiration time has passed.
Expired bool `json:",omitempty"`
// KeyExpiry, if present, is the time at which the node key expired or
// will expire.
KeyExpiry *time.Time `json:",omitempty"`
}
type StatusBuilder struct {
@@ -435,6 +440,9 @@ func (sb *StatusBuilder) AddPeer(peer key.NodePublic, st *PeerStatus) {
if st.Expired {
e.Expired = true
}
if t := st.KeyExpiry; t != nil {
e.KeyExpiry = ptr.To(*t)
}
}
type StatusUpdater interface {