tsutil

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcceptRoutes added in v0.12.5

func 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 AdvertiseExitNode added in v0.12.5

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

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

func AdvertiseRoutes added in v0.12.5

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

func AllowLANAccess added in v0.12.5

func 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 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 CompareLocations added in v0.12.2

func CompareLocations(loc1, loc2 *tailcfg.Location) int

CompareLocations alphabestically compares the countries and then, if necessary, cities of two Locations.

func ComparePeers added in v0.12.4

func ComparePeers(p1, p2 *ipnstate.PeerStatus) int

ComparePeers compares two peers. It does so by location if available, then by hostname. It returns the peers in a deterministic order if their locations or hostnames are identical, so the result of calling this is never 0. To determine if peers are the same, compare their IDs manually.

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 DeleteWaitingFile added in v0.12.5

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

func ExitNode added in v0.12.5

func 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 GetStatus added in v0.12.5

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

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

func GetWaitingFile added in v0.12.5

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

func IsMullvad added in v0.12.0

func IsMullvad(peer *ipnstate.PeerStatus) bool

IsMullvad returns true if peer is a Mullvad exit node.

func NetCheck added in v0.12.5

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

func Prefs added in v0.12.5

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

Prefs returns the options of the local node.

func PushFile added in v0.12.5

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

func SetControlURL added in v0.12.5

func 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 Start added in v0.12.5

func Start(ctx context.Context) error

Start connects the local peer to the Tailscale network.

func Stop added in v0.12.5

func Stop(ctx context.Context) error

Stop disconnects the local peer from the Tailscale network.

func WaitingFiles added in v0.12.5

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

WaitingFiles polls for any pending incoming files. It returns quickly if there are no files currently pending.

Types

type Poller added in v0.9.0

type Poller struct {
	// 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