Documentation
¶
Overview ¶
Package jsonoutput provides stable and versioned JSON serialisation for CLI output. This allows us to provide stable output to scripts/clients, but also make breaking changes to the output when it's useful.
Historically we only used `--json` as a boolean flag, so changing the output could break scripts that rely on the existing format.
This package allows callers to pass a version number to `--json` and get a consistent output. We'll bump the version when we make a breaking change that's likely to break scripts that rely on the existing output, e.g. if we remove a field or change the type/format.
Passing just the boolean flag `--json` will always return v1, to preserve compatibility with scripts written before we versioned our output.
Index ¶
- func PrintNetworkLockLogJSONV1(out io.Writer, updates []ipnstate.NetworkLockUpdate) error
- func PrintNetworkLockStatusJSONV1(out io.Writer, status *ipnstate.NetworkLockStatus) error
- type DNSAnswer
- type DNSExtraRecord
- type DNSQueryResult
- type DNSResolverInfo
- type DNSStatusResult
- type DNSSystemConfig
- type DNSTailnetInfo
- type JSONSchemaVersion
- type ResponseEnvelope
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintNetworkLockLogJSONV1 ¶ added in v1.94.0
func PrintNetworkLockLogJSONV1(out io.Writer, updates []ipnstate.NetworkLockUpdate) error
PrintNetworkLockLogJSONV1 prints the stored TKA state as a JSON object to the CLI, in a stable "v1" format.
This format includes:
- the AUM hash as a base32-encoded string
- the raw AUM as base64-encoded bytes
- the expanded AUM, which prints named fields for consumption by other tools
func PrintNetworkLockStatusJSONV1 ¶ added in v1.94.0
func PrintNetworkLockStatusJSONV1(out io.Writer, status *ipnstate.NetworkLockStatus) error
PrintNetworkLockStatusJSONV1 prints the current Tailnet Lock status as a JSON object to the CLI, in a stable "v1" format.
Types ¶
type DNSAnswer ¶ added in v1.96.0
type DNSAnswer struct {
Name string
TTL uint32
Class string // e.g. "ClassINET"
Type string // e.g. "TypeA", "TypeAAAA"
Body string // human-readable record data
}
DNSAnswer is a single DNS resource record from a query response.
type DNSExtraRecord ¶ added in v1.96.0
type DNSExtraRecord struct {
Name string
Type string `json:",omitempty"` // empty means A or AAAA, depending on Value
Value string // typically an IP address
}
DNSExtraRecord is the JSON form of [tailcfg.DNSRecord].
type DNSQueryResult ¶ added in v1.96.0
type DNSQueryResult struct {
Name string
QueryType string // e.g. "A", "AAAA"
Resolvers []DNSResolverInfo `json:",omitzero"`
ResponseCode string // e.g. "RCodeSuccess", "RCodeNameError"
Answers []DNSAnswer `json:",omitzero"`
}
DNSQueryResult is the result of a DNS query via the Tailscale internal forwarder (100.100.100.100).
type DNSResolverInfo ¶ added in v1.96.0
type DNSResolverInfo struct {
// Addr is a plain IP, IP:port, DoH URL, or HTTP-over-WireGuard URL.
Addr string
// BootstrapResolution is optional pre-resolved IPs for DoT/DoH
// resolvers whose address is not already an IP.
BootstrapResolution []string `json:",omitempty"`
}
DNSResolverInfo is the JSON form of [dnstype.Resolver].
type DNSStatusResult ¶ added in v1.96.0
type DNSStatusResult struct {
// TailscaleDNS is whether the Tailscale DNS configuration is
// installed on this device (the --accept-dns setting).
TailscaleDNS bool
// CurrentTailnet describes MagicDNS configuration for the tailnet.
CurrentTailnet *DNSTailnetInfo `json:",omitzero"` // nil if not connected
// Resolvers are the DNS resolvers, in preference order. If
// empty, the system defaults are used.
Resolvers []DNSResolverInfo `json:",omitzero"`
// SplitDNSRoutes maps domain suffixes to dedicated resolvers.
// An empty resolver slice means the suffix is handled by
// Tailscale's built-in resolver (100.100.100.100).
SplitDNSRoutes map[string][]DNSResolverInfo `json:",omitzero"`
// FallbackResolvers are like Resolvers but only used when
// split DNS needs explicit default resolvers.
FallbackResolvers []DNSResolverInfo `json:",omitzero"`
SearchDomains []string `json:",omitzero"`
// Nameservers are nameserver IPs.
//
// Deprecated: old protocol versions only. Use Resolvers.
Nameservers []string `json:",omitzero"`
// CertDomains are FQDNs for which the coordination server
// provisions TLS certificates via dns-01 ACME challenges.
CertDomains []string `json:",omitzero"`
// ExtraRecords contains extra DNS records in the MagicDNS config.
ExtraRecords []DNSExtraRecord `json:",omitzero"`
// ExitNodeFilteredSet are DNS suffixes this node won't resolve
// when acting as an exit node DNS proxy. Period-prefixed
// entries are suffix matches; others are exact. Always
// lowercase, no trailing dots.
ExitNodeFilteredSet []string `json:",omitzero"`
SystemDNS *DNSSystemConfig `json:",omitzero"` // nil if unavailable
SystemDNSError string `json:",omitempty"`
}
DNSStatusResult is the full DNS status collected from the local Tailscale daemon.
type DNSSystemConfig ¶ added in v1.96.0
type DNSSystemConfig struct {
Nameservers []string `json:",omitzero"`
SearchDomains []string `json:",omitzero"`
// MatchDomains are DNS suffixes restricting which queries use
// these Nameservers. Empty means Nameservers is the primary
// resolver.
MatchDomains []string `json:",omitzero"`
}
DNSSystemConfig is the OS DNS configuration as observed by Tailscale, mirroring net/dns.OSConfig.
type DNSTailnetInfo ¶ added in v1.96.0
type DNSTailnetInfo struct {
// MagicDNSEnabled is whether MagicDNS is enabled for the
// tailnet. The device may still not use it if
// --accept-dns=false.
MagicDNSEnabled bool
// MagicDNSSuffix is the tailnet's MagicDNS suffix
// (e.g. "tail1234.ts.net"), without surrounding dots.
MagicDNSSuffix string `json:",omitempty"`
// SelfDNSName is this device's FQDN
// (e.g. "host.tail1234.ts.net."), with trailing dot.
SelfDNSName string `json:",omitempty"`
}
DNSTailnetInfo describes MagicDNS configuration for the tailnet, combining ipnstate.TailnetStatus and ipnstate.PeerStatus.
type JSONSchemaVersion ¶
type JSONSchemaVersion struct {
// IsSet tracks if the flag was provided at all.
IsSet bool
// Value tracks the desired schema version, which defaults to 1 if
// the user passes `--json` without an argument.
Value int
}
JSONSchemaVersion implements flag.Value, and tracks whether the CLI has been called with `--json`, and if so, with what value.
func (*JSONSchemaVersion) IsBoolFlag ¶
func (v *JSONSchemaVersion) IsBoolFlag() bool
IsBoolFlag tells the flag package that JSONSchemaVersion can be set without an argument.
func (*JSONSchemaVersion) Set ¶
func (v *JSONSchemaVersion) Set(s string) error
Set is called when the user passes the flag as a command-line argument.
func (*JSONSchemaVersion) String ¶
func (v *JSONSchemaVersion) String() string
String returns the default value which is printed in the CLI help text.
type ResponseEnvelope ¶
type ResponseEnvelope struct {
// SchemaVersion is the version of the JSON output, e.g. "1", "2", "3"
SchemaVersion string
// ResponseWarning tells a user if a newer version of the JSON output
// is available.
ResponseWarning string `json:"_WARNING,omitzero"`
}
ResponseEnvelope is a set of fields common to all versioned JSON output.