Documentation
¶
Overview ¶
Package tailnet asks the local Tailscale client about this machine: whether it is on a tailnet, its MagicDNS name and addresses, and whether the tailnet can issue HTTPS certificates for it. It also fetches such a certificate (`tailscale cert`). It only runs the tailscale command line with fixed arguments; it never talks to the network itself, and a machine without Tailscale simply reports that it is not on a tailnet.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoTailscale = errors.New("tailscale is not installed (no tailscale command found)")
ErrNoTailscale means the tailscale command line was not found.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// Run runs the tailscale command line; nil finds it (Find) and runs it.
Run Runner
// CacheFor is how long a Status answer is reused; 0 means a minute.
CacheFor time.Duration
// Now is the clock; nil means time.Now.
Now func() time.Time
// contains filtered or unexported fields
}
Client asks Tailscale about this machine. The zero value finds the tailscale command line on first use.
func (*Client) Cert ¶
Cert fetches (or renews) the HTTPS certificate for domain from the tailnet into certFile and keyFile, using `tailscale cert`. Tailscale keeps its own copy and only asks for a new certificate when the old one is close to expiry, so calling it daily is cheap. The tailnet must have HTTPS certificates enabled, and the certificate is published in the public Certificate Transparency logs.
type Info ¶
type Info struct {
// Running is true when Tailscale is up and logged in to a tailnet.
Running bool `json:"running"`
// DNSName is this machine's MagicDNS name without the trailing dot,
// for example "chat-pi.tail1234.ts.net"; "" when MagicDNS is off.
DNSName string `json:"dns_name,omitempty"`
// IPs are this machine's Tailscale addresses (100.x.y.z and fd7a:...).
IPs []netip.Addr `json:"ips,omitempty"`
// CertDomains are the names the tailnet can issue HTTPS certificates
// for; empty when HTTPS certificates are not enabled in the tailnet.
CertDomains []string `json:"cert_domains,omitempty"`
}
Info is what Tailscale reports about this machine.
func ParseStatus ¶
ParseStatus reads the output of `tailscale status --json`.