tsutil

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanMullvad added in v0.12.0

func CanMullvad(peer *ipnstate.PeerStatus) bool

CanMullvad returns true if peer is allowed to access Mullvad exit nodes.

func DNSOrQuoteHostname added in v0.9.4

func DNSOrQuoteHostname(st *ipnstate.Status, ps *ipnstate.PeerStatus) string

DNSOrQuoteHostname returns a nicely printable version of a peer's name. The function is copied from https://github.com/tailscale/tailscale/blob/b0ed863d55d6b51569ce5c6bd0b7021338ce6a82/cmd/tailscale/cli/status.go#L285

func IsMullvad added in v0.12.0

func IsMullvad(peer *ipnstate.PeerStatus) bool

IsMullvad returns true if peer is a Mullvad exit node.

Types

type Client

type Client struct {
	// Command is the command to call for the Tailscale CLI binary. It
	// defaults to "tailscale".
	Command string
}

Client is a client for Tailscale's services. Some functionality is handled via the Go API, and some is handled via execution of the Tailscale CLI binary.

func (*Client) AcceptRoutes added in v0.10.3

func (c *Client) AcceptRoutes(ctx context.Context, accept bool) error

AcceptRoutes sets whether or not all shared subnet routes from other nodes should be used by the local node.

func (*Client) AdvertiseExitNode

func (c *Client) AdvertiseExitNode(ctx context.Context, enable bool) error

AdvertiseExitNode enables and disables exit node advertisement for the current node.

func (*Client) AdvertiseRoutes

func (c *Client) AdvertiseRoutes(ctx context.Context, routes []netip.Prefix) error

func (*Client) AllowLANAccess

func (c *Client) AllowLANAccess(ctx context.Context, allow bool) error

AllowLANAccess enables and disables the ability for the current node to get access to the regular LAN that it is connected to while an exit node is in use.

func (*Client) DeleteWaitingFile added in v0.10.0

func (c *Client) DeleteWaitingFile(ctx context.Context, name string) error

func (*Client) ExitNode

func (c *Client) ExitNode(ctx context.Context, peer *ipnstate.PeerStatus) error

ExitNode uses the specified peer as an exit node, or unsets an existing exit node if peer is nil.

func (*Client) GetWaitingFile added in v0.10.0

func (c *Client) GetWaitingFile(ctx context.Context, name string) (io.ReadCloser, int64, error)

func (*Client) NetCheck

func (c *Client) NetCheck(ctx context.Context, full bool) (*netcheck.Report, *tailcfg.DERPMap, error)

func (*Client) Prefs

func (c *Client) Prefs(ctx context.Context) (*ipn.Prefs, error)

Prefs returns the options of the local node.

func (*Client) PushFile added in v0.10.0

func (c *Client) PushFile(ctx context.Context, target tailcfg.StableNodeID, size int64, name string, r io.Reader) error

func (*Client) SetControlURL added in v0.10.0

func (c *Client) SetControlURL(ctx context.Context, controlURL string) error

SetControlURL changes the URL of the control plane server used by the daemon. If controlURL is empty, the default Tailscale server is used.

func (*Client) Start

func (c *Client) Start(ctx context.Context) error

Start connects the local peer to the Tailscale network.

func (*Client) Status

func (c *Client) Status(ctx context.Context) (*ipnstate.Status, error)

Status returns the status of the connection to the Tailscale network. If the network is not currently connected, it returns nil, nil.

func (*Client) Stop

func (c *Client) Stop(ctx context.Context) error

Stop disconnects the local peer from the Tailscale network.

func (*Client) WaitingFiles added in v0.10.0

func (c *Client) WaitingFiles(ctx context.Context) ([]apitype.WaitingFile, error)

WaitingFiles polls for any pending incoming files. It blocks for an extended period of time.

type Poller added in v0.9.0

type Poller struct {
	// TS is the Client to use to interact with Tailscale.
	//
	// If it is nil, a default client will be used.
	TS *Client

	// Interval is the default interval to use for polling.
	//
	// If it is a zero, a non-zero default will be used.
	Interval time.Duration

	// If non-nil, New will be called when a new status is received from
	// Tailscale.
	New func(Status)
	// contains filtered or unexported fields
}

A Poller gets the latest Tailscale status at regular intervals or when manually triggered.

A zero-value of a Poller is ready to use.

It is a race condition to change any exported fields of Poller while Run is running.

func (*Poller) Get added in v0.9.0

func (p *Poller) Get() <-chan Status

Get returns a channel that will yield the latest Status fetched. If a new Status is in the process of being fetched, it will wait for that to finish and then yield that.

func (*Poller) Poll added in v0.9.0

func (p *Poller) Poll() chan<- struct{}

Poll returns a channel that, when sent to, causes a new status to be fetched from Tailscale. A send to the channel does not resolve until the poller begins to fetch the status, meaning that a send to Poll followed immediately by a receive from Get will always result in the new Status.

Do not close the returned channel. Doing so will result in undefined behavior.

func (*Poller) Run added in v0.9.0

func (p *Poller) Run(ctx context.Context)

Run runs the poller. It blocks until polling is done, which is generally a result of the given Context being cancelled.

The behavior of two calls to Run running concurrently is undefined. Don't do it.

func (*Poller) SetInterval added in v0.10.0

func (p *Poller) SetInterval() chan<- time.Duration

SetInterval returns a channel that modifies the polling interval of a running poller. This will delay the next poll until the new interval has elapsed.

type Status added in v0.9.0

type Status struct {
	Status *ipnstate.Status
	Prefs  *ipn.Prefs
	Files  []apitype.WaitingFile
}

Status is a type that wraps various status-related types that Tailscale provides.

func (Status) NeedsAuth added in v0.9.3

func (s Status) NeedsAuth() bool

func (Status) Online added in v0.9.0

func (s Status) Online() bool

Online returns true if s indicates that the local node is online and connected to the tailnet.

func (Status) OperatorIsCurrent added in v0.10.2

func (s Status) OperatorIsCurrent() bool

func (Status) SelfAddr added in v0.11.0

func (s Status) SelfAddr() (netip.Addr, bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL