mirror of
https://github.com/tailscale/tailscale.git
synced 2025-03-28 03:52:35 +00:00
ipn: add TailnetStatus
field to tailscale status --json
(#3865)
We need to capture some tailnet-related information for some Docker features we're building. This exposes the tailnet name and MagicDNS information via `tailscale status --json`. Fixes tailscale/corp#3670 Signed-off-by: Ross Zurowski <ross@rosszurowski.com>
This commit is contained in:
parent
c988bd6ed1
commit
6d02a48d8d
@ -383,9 +383,14 @@ func (b *LocalBackend) updateStatus(sb *ipnstate.StatusBuilder, extraLocked func
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if b.netMap != nil {
|
if b.netMap != nil {
|
||||||
s.MagicDNSSuffix = b.netMap.MagicDNSSuffix()
|
|
||||||
s.CertDomains = append([]string(nil), b.netMap.DNS.CertDomains...)
|
s.CertDomains = append([]string(nil), b.netMap.DNS.CertDomains...)
|
||||||
s.TailnetName = b.netMap.Domain
|
s.MagicDNSSuffix = b.netMap.MagicDNSSuffix()
|
||||||
|
if s.CurrentTailnet == nil {
|
||||||
|
s.CurrentTailnet = &ipnstate.TailnetStatus{}
|
||||||
|
}
|
||||||
|
s.CurrentTailnet.MagicDNSSuffix = b.netMap.MagicDNSSuffix()
|
||||||
|
s.CurrentTailnet.MagicDNSEnabled = b.netMap.DNS.Proxied
|
||||||
|
s.CurrentTailnet.Name = b.netMap.Domain
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
sb.MutateSelfStatus(func(ss *ipnstate.PeerStatus) {
|
sb.MutateSelfStatus(func(ss *ipnstate.PeerStatus) {
|
||||||
|
@ -33,10 +33,6 @@ type Status struct {
|
|||||||
// "Starting", "Running".
|
// "Starting", "Running".
|
||||||
BackendState string
|
BackendState string
|
||||||
|
|
||||||
// TailnetName is the name of the network that's currently in
|
|
||||||
// use.
|
|
||||||
TailnetName string
|
|
||||||
|
|
||||||
AuthURL string // current URL provided by control to authorize client
|
AuthURL string // current URL provided by control to authorize client
|
||||||
TailscaleIPs []netaddr.IP // Tailscale IP(s) assigned to this node
|
TailscaleIPs []netaddr.IP // Tailscale IP(s) assigned to this node
|
||||||
Self *PeerStatus
|
Self *PeerStatus
|
||||||
@ -46,13 +42,15 @@ type Status struct {
|
|||||||
// problems are detected)
|
// problems are detected)
|
||||||
Health []string
|
Health []string
|
||||||
|
|
||||||
// MagicDNSSuffix is the network's MagicDNS suffix for nodes
|
// This field is the legacy name of CurrentTailnet.MagicDNSSuffix.
|
||||||
// in the network such as "userfoo.tailscale.net".
|
//
|
||||||
// There are no surrounding dots.
|
// Deprecated: use CurrentTailnet.MagicDNSSuffix instead.
|
||||||
// MagicDNSSuffix should be populated regardless of whether a domain
|
|
||||||
// has MagicDNS enabled.
|
|
||||||
MagicDNSSuffix string
|
MagicDNSSuffix string
|
||||||
|
|
||||||
|
// CurrentTailnet is information about the tailnet that the node
|
||||||
|
// is currently connected to. When not connected, this field is nil.
|
||||||
|
CurrentTailnet *TailnetStatus
|
||||||
|
|
||||||
// CertDomains are the set of DNS names for which the control
|
// CertDomains are the set of DNS names for which the control
|
||||||
// plane server will assist with provisioning TLS
|
// plane server will assist with provisioning TLS
|
||||||
// certificates. See SetDNSRequest for dns-01 ACME challenges
|
// certificates. See SetDNSRequest for dns-01 ACME challenges
|
||||||
@ -64,6 +62,24 @@ type Status struct {
|
|||||||
User map[tailcfg.UserID]tailcfg.UserProfile
|
User map[tailcfg.UserID]tailcfg.UserProfile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TailnetStatus is information about a Tailscale network ("tailnet").
|
||||||
|
type TailnetStatus struct {
|
||||||
|
// Name is the name of the network that's currently in use.
|
||||||
|
Name string
|
||||||
|
|
||||||
|
// MagicDNSSuffix is the network's MagicDNS suffix for nodes
|
||||||
|
// in the network such as "userfoo.tailscale.net".
|
||||||
|
// There are no surrounding dots.
|
||||||
|
// MagicDNSSuffix should be populated regardless of whether a domain
|
||||||
|
// has MagicDNS enabled.
|
||||||
|
MagicDNSSuffix string
|
||||||
|
|
||||||
|
// MagicDNSEnabled is whether or not the network has MagicDNS enabled.
|
||||||
|
// Note that the current device may still not support MagicDNS if
|
||||||
|
// `--accept-dns=false` was used.
|
||||||
|
MagicDNSEnabled bool
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Status) Peers() []key.NodePublic {
|
func (s *Status) Peers() []key.NodePublic {
|
||||||
kk := make([]key.NodePublic, 0, len(s.Peer))
|
kk := make([]key.NodePublic, 0, len(s.Peer))
|
||||||
for k := range s.Peer {
|
for k := range s.Peer {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user