Documentation
¶
Index ¶
- func CanWrite(ctx context.Context) bool
- func Down(ctx context.Context) error
- func EditPrefs(ctx context.Context, maskedPrefs *ipn.MaskedPrefs) error
- func LockStatus(ctx context.Context) (*ipnstate.NetworkLockStatus, error)
- func Logout(ctx context.Context) error
- func NewIPNStateFromString(v string) (ipn.State, error)
- func PeerName(peer *ipnstate.PeerStatus) string
- func PingPeer(ctx context.Context, peer *ipnstate.PeerStatus) (*ipnstate.PingResult, error)
- func Prefs(ctx context.Context) (*ipn.Prefs, error)
- func SetExitNode(ctx context.Context, peer *ipnstate.PeerStatus) error
- func StartLoginInteractive(ctx context.Context) error
- func StartLoginInteractiveWillOpenBrowser() bool
- func Status(ctx context.Context) (*ipnstate.Status, error)
- func Up(ctx context.Context) error
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanWrite ¶
Returns true if the user has write permissions to the Tailscale config. If false, the user may have to run tsui with sudo.
func EditPrefs ¶
func EditPrefs(ctx context.Context, maskedPrefs *ipn.MaskedPrefs) error
Update preferences.
func LockStatus ¶
func LockStatus(ctx context.Context) (*ipnstate.NetworkLockStatus, error)
Return the tailnet lock status of the current node.
func NewIPNStateFromString ¶ added in v0.2.0
Create an ipn.State from the string representation.
This string representation comes from Tailscale's API and, because Go does not have proper enums, this is the best way to convert it back to a "typed" representation.
func PeerName ¶
func PeerName(peer *ipnstate.PeerStatus) string
Get the user-friendly name of a Tailscale peer such as "foobar-router-2". This is distinct from the device name, which can have duplicates on the network, and from the DNS name, which includes the tailnet suffix.
func PingPeer ¶
func PingPeer(ctx context.Context, peer *ipnstate.PeerStatus) (*ipnstate.PingResult, error)
Ping a peer.
func SetExitNode ¶
func SetExitNode(ctx context.Context, peer *ipnstate.PeerStatus) error
Set the exit node to the given peer, or clear the exit node if peer is nil.
func StartLoginInteractive ¶
Start an interactive login flow. On macOS, this will automatically open the user's web browser.
func StartLoginInteractiveWillOpenBrowser ¶ added in v0.2.0
func StartLoginInteractiveWillOpenBrowser() bool
Returns true if StartLoginInteractive will (probably) open the user's web browser. Can be used to decide whether to display UI elements related to interactive login.
Types ¶
type State ¶
type State struct { // Tailscale preferences. Prefs *ipn.Prefs // Current Tailscale backend state. BackendState ipn.State // Current Tailscale version. This is a shortened version string like "1.70.0". TSVersion string // Auth URL. Empty if the user doesn't need to be authenticated. AuthURL string // User profile of the currently logged in user or nil if unknown. User *tailcfg.UserProfile // Peer status of the local node. Self *ipnstate.PeerStatus // Tailnet lock key. Nil if not enabled. LockKey *key.NLPublic // True if the node is locked out by tailnet lock. IsLockedOut bool // Exit node peers sorted by PeerName. ExitNodes []*ipnstate.PeerStatus // Peers owned by the user sorted by PeerName. MyNodes []*ipnstate.PeerStatus // Tagged peers sorted by PeerName. TaggedNodes []*ipnstate.PeerStatus // Alphabetically sorted keys of AccountNodes. OwnedNodeKeys []string // Peers owned by other accoutns, sorted by PeerName, and keyed by account name. OwnedNodes map[string][]*ipnstate.PeerStatus // ID of the currently selected exit node or nil if none is selected. CurrentExitNode *tailcfg.StableNodeID // Name of the currently selected exit node or an empty string if none is selected. CurrentExitNodeName string // Total bytes received from peers. RxBytes int64 // Total bytes sent to peers. TxBytes int64 }
Opinionated, sanitized subset of Tailscale state.