diff options
| author | Brad Fitzpatrick <bradfitz@tailscale.com> | 2021-05-07 07:27:14 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <brad@danga.com> | 2021-05-07 09:31:55 -0700 |
| commit | e72ed3fcc2fd865b75d4ef52ff3f910f60578751 (patch) | |
| tree | ec104f1bea789d438aac3ad2a7b2bfa5b28998b7 | |
| parent | 3c8e230ee1ea856742647d5e1e79087f100eb01b (diff) | |
| download | tailscale-e72ed3fcc2fd865b75d4ef52ff3f910f60578751.tar.xz tailscale-e72ed3fcc2fd865b75d4ef52ff3f910f60578751.zip | |
ipn/{ipnlocal,ipnstate}: add PeerStatus.ID stable ID to status --json output
Needed for the "up checker" to map back from exit node stable IDs (the
ipn.Prefs.ExitNodeID) back to an IP address in error messages.
But also previously requested so people can use it to then make API
calls. The upcoming "tailscale admin" subcommand will probably need it
too.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
| -rw-r--r-- | ipn/ipnlocal/local.go | 4 | ||||
| -rw-r--r-- | ipn/ipnstate/ipnstate.go | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 3603e2e0e..6df575621 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -326,6 +326,9 @@ func (b *LocalBackend) updateStatus(sb *ipnstate.StatusBuilder, extraLocked func } }) sb.MutateSelfStatus(func(ss *ipnstate.PeerStatus) { + if b.netMap != nil && b.netMap.SelfNode != nil { + ss.ID = b.netMap.SelfNode.StableID + } for _, pln := range b.peerAPIListeners { ss.PeerAPIURL = append(ss.PeerAPIURL, pln.urlStr) } @@ -365,6 +368,7 @@ func (b *LocalBackend) populatePeerStatusLocked(sb *ipnstate.StatusBuilder) { } sb.AddPeer(key.Public(p.Key), &ipnstate.PeerStatus{ InNetworkMap: true, + ID: p.StableID, UserID: p.User, TailAddrDeprecated: tailAddr4, TailscaleIPs: tailscaleIPs, diff --git a/ipn/ipnstate/ipnstate.go b/ipn/ipnstate/ipnstate.go index cbc3413ca..99663acf1 100644 --- a/ipn/ipnstate/ipnstate.go +++ b/ipn/ipnstate/ipnstate.go @@ -65,6 +65,7 @@ type PeerStatusLite struct { } type PeerStatus struct { + ID tailcfg.StableNodeID PublicKey key.Public HostName string // HostInfo's Hostname (not a DNS name or necessarily unique) DNSName string @@ -203,6 +204,9 @@ func (sb *StatusBuilder) AddPeer(peer key.Public, st *PeerStatus) { return } + if v := st.ID; v != "" { + e.ID = v + } if v := st.HostName; v != "" { e.HostName = v } |
