mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-12 13:48:01 +00:00
ipn/ipnlocal: use views for Peer.PrimaryRoutes and Peer.Tags
RELNOTE=`tailscale status --json` now shows Tags and PrimaryRoutes Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
@@ -48,6 +48,7 @@ import (
|
||||
"tailscale.com/types/netmap"
|
||||
"tailscale.com/types/persist"
|
||||
"tailscale.com/types/preftype"
|
||||
"tailscale.com/types/views"
|
||||
"tailscale.com/util/deephash"
|
||||
"tailscale.com/util/dnsname"
|
||||
"tailscale.com/util/multierr"
|
||||
@@ -443,13 +444,23 @@ func (b *LocalBackend) populatePeerStatusLocked(sb *ipnstate.StatusBuilder) {
|
||||
exitNodeOption := tsaddr.PrefixesContainsFunc(p.AllowedIPs, func(r netaddr.IPPrefix) bool {
|
||||
return r.Bits() == 0
|
||||
})
|
||||
var tags *views.StringSlice
|
||||
var primaryRoutes *views.IPPrefixSlice
|
||||
if p.Tags != nil {
|
||||
v := views.StringSliceOf(p.Tags)
|
||||
tags = &v
|
||||
}
|
||||
if p.PrimaryRoutes != nil {
|
||||
v := views.IPPrefixSliceOf(p.PrimaryRoutes)
|
||||
primaryRoutes = &v
|
||||
}
|
||||
sb.AddPeer(p.Key, &ipnstate.PeerStatus{
|
||||
InNetworkMap: true,
|
||||
ID: p.StableID,
|
||||
UserID: p.User,
|
||||
TailscaleIPs: tailscaleIPs,
|
||||
Tags: p.Tags,
|
||||
PrimaryRoutes: p.PrimaryRoutes,
|
||||
Tags: tags,
|
||||
PrimaryRoutes: primaryRoutes,
|
||||
HostName: p.Hostinfo.Hostname(),
|
||||
DNSName: p.Name,
|
||||
OS: p.Hostinfo.OS(),
|
||||
|
@@ -20,6 +20,7 @@ import (
|
||||
"inet.af/netaddr"
|
||||
"tailscale.com/tailcfg"
|
||||
"tailscale.com/types/key"
|
||||
"tailscale.com/types/views"
|
||||
"tailscale.com/util/dnsname"
|
||||
)
|
||||
|
||||
@@ -111,12 +112,12 @@ type PeerStatus struct {
|
||||
|
||||
// Tags are the list of ACL tags applied to this node.
|
||||
// See tailscale.com/tailcfg#Node.Tags for more information.
|
||||
Tags []string `json:",omitempty"`
|
||||
Tags *views.StringSlice `json:",omitempty"`
|
||||
|
||||
// PrimaryRoutes are the routes this node is currently the primary
|
||||
// subnet router for, as determined by the control plane. It does
|
||||
// not include the IPs in TailscaleIPs.
|
||||
PrimaryRoutes []netaddr.IPPrefix `json:",omitempty"`
|
||||
PrimaryRoutes *views.IPPrefixSlice `json:",omitempty"`
|
||||
|
||||
// Endpoints:
|
||||
Addrs []string
|
||||
@@ -274,10 +275,10 @@ func (sb *StatusBuilder) AddPeer(peer key.NodePublic, st *PeerStatus) {
|
||||
if v := st.TailscaleIPs; v != nil {
|
||||
e.TailscaleIPs = v
|
||||
}
|
||||
if v := st.PrimaryRoutes; v != nil {
|
||||
if v := st.PrimaryRoutes; v != nil && !v.IsNil() {
|
||||
e.PrimaryRoutes = v
|
||||
}
|
||||
if v := st.Tags; v != nil {
|
||||
if v := st.Tags; v != nil && !v.IsNil() {
|
||||
e.Tags = v
|
||||
}
|
||||
if v := st.OS; v != "" {
|
||||
|
Reference in New Issue
Block a user