controlclient

package
v0.96.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: BSD-3-Clause Imports: 29 Imported by: 27

Documentation

Overview

Package controlclient implements the client for the Tailscale control plane.

It handles authentication, port picking, and collects the local network configuration.

Index

Constants

View Source
const (
	LoginDefault     = LoginFlags(0)
	LoginInteractive = LoginFlags(1 << iota) // force user login and key refresh
)
View Source
const (
	UAllowSingleHosts = 1 << iota
	UAllowSubnetRoutes
	UAllowDefaultRoute
	UHackDefaultRoute

	UDefault = 0
)

Variables

This section is empty.

Functions

func NewHostinfo

func NewHostinfo() *tailcfg.Hostinfo

func UFlagsHelper

func UFlagsHelper(uroutes, rroutes, droutes bool) int

Several programs need to parse these arguments into uflags, so let's centralize it here.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client connects to a tailcontrol server for a node.

func New

func New(opts Options) (*Client, error)

New creates and starts a new Client.

func NewNoStart

func NewNoStart(opts Options) (*Client, error)

NewNoStart creates a new Client, but without calling Start on it.

func (*Client) AuthCantContinue

func (c *Client) AuthCantContinue() bool

func (*Client) Login

func (c *Client) Login(t *oauth2.Token, flags LoginFlags)

func (*Client) Logout

func (c *Client) Logout()

func (*Client) SetHostinfo

func (c *Client) SetHostinfo(hi *tailcfg.Hostinfo)

func (*Client) SetNetInfo

func (c *Client) SetNetInfo(ni *tailcfg.NetInfo)

func (*Client) SetStatusFunc

func (c *Client) SetStatusFunc(fn func(Status))

func (*Client) Shutdown

func (c *Client) Shutdown()

func (*Client) Start

func (c *Client) Start()

Start starts the client's goroutines.

It should only be called for clients created by NewNoStart.

func (*Client) UpdateEndpoints

func (c *Client) UpdateEndpoints(localPort uint16, endpoints []string)

type Decompressor

type Decompressor interface {
	DecodeAll(input, dst []byte) ([]byte, error)
	Close()
}

type Direct

type Direct struct {
	// contains filtered or unexported fields
}

Direct is the client that connects to a tailcontrol server for a node.

func NewDirect

func NewDirect(opts Options) (*Direct, error)

NewDirect returns a new Direct client.

func (*Direct) GetPersist

func (c *Direct) GetPersist() Persist

func (*Direct) PollNetMap

func (c *Direct) PollNetMap(ctx context.Context, maxPolls int, cb func(*NetworkMap)) error

func (*Direct) SetEndpoints

func (c *Direct) SetEndpoints(localPort uint16, endpoints []string) (changed bool)

SetEndpoints updates the list of locally advertised endpoints. It won't be replicated to the server until a *fresh* call to PollNetMap(). You don't need to restart PollNetMap if we return changed==false.

func (*Direct) SetHostinfo

func (c *Direct) SetHostinfo(hi *tailcfg.Hostinfo)

SetHostinfo clones the provided Hostinfo and remembers it for the next update.

func (*Direct) SetNetInfo

func (c *Direct) SetNetInfo(ni *tailcfg.NetInfo)

SetNetInfo clones the provided NetInfo and remembers it for the next update.

func (*Direct) TryLogin

func (c *Direct) TryLogin(ctx context.Context, t *oauth2.Token, flags LoginFlags) (url string, err error)

func (*Direct) TryLogout

func (c *Direct) TryLogout(ctx context.Context) error

func (*Direct) WaitLoginURL

func (c *Direct) WaitLoginURL(ctx context.Context, url string) (newUrl string, err error)

type LoginFlags

type LoginFlags int

type LoginGoal

type LoginGoal struct {
	// contains filtered or unexported fields
}

type NetworkMap

type NetworkMap struct {
	NodeKey       tailcfg.NodeKey
	PrivateKey    wgcfg.PrivateKey
	Expiry        time.Time
	Addresses     []wgcfg.CIDR
	LocalPort     uint16 // used for debugging
	MachineStatus tailcfg.MachineStatus
	Peers         []tailcfg.Node
	DNS           []wgcfg.IP
	DNSDomains    []string
	Hostinfo      tailcfg.Hostinfo
	PacketFilter  filter.Matches

	User   tailcfg.UserID
	Domain string
	// TODO(crawshaw): reduce UserProfiles to []tailcfg.UserProfile?
	// There are lots of ways to slice this data, leave it up to users.
	UserProfiles map[tailcfg.UserID]tailcfg.UserProfile
	Roles        []tailcfg.Role
}

func (*NetworkMap) Concise

func (nm *NetworkMap) Concise() string

func (*NetworkMap) ConciseDiffFrom

func (b *NetworkMap) ConciseDiffFrom(a *NetworkMap) string

func (*NetworkMap) Equal

func (n *NetworkMap) Equal(n2 *NetworkMap) bool

func (*NetworkMap) JSON

func (nm *NetworkMap) JSON() string

func (NetworkMap) String

func (nm NetworkMap) String() string

func (*NetworkMap) UAPI

func (nm *NetworkMap) UAPI(uflags int, dnsOverride []wgcfg.IP) string

func (*NetworkMap) UserMap

func (nm *NetworkMap) UserMap() map[string][]filter.IP

TODO(apenwarr): delete me once relaynode doesn't need this anymore. control.go:userMap() supercedes it. This does not belong in the client.

func (*NetworkMap) WGCfg

func (nm *NetworkMap) WGCfg(uflags int, dnsOverride []wgcfg.IP) (*wgcfg.Config, error)

func (*NetworkMap) WireGuardConfigOneEndpoint

func (nm *NetworkMap) WireGuardConfigOneEndpoint(uflags int, dnsOverride []wgcfg.IP) string

TODO(apenwarr): This mode is dangerous. Discarding the extra endpoints is almost universally the wrong choice. Except that plain wireguard can't handle a peer with multiple endpoints. (Yet?)

type Options

type Options struct {
	Persist         Persist           // initial persistent data
	HTTPC           *http.Client      // HTTP client used to talk to tailcontrol
	ServerURL       string            // URL of the tailcontrol server
	TimeNow         func() time.Time  // time.Now implementation used by Client
	Hostinfo        *tailcfg.Hostinfo // non-nil passes ownership, nil means to use default using os.Hostname, etc
	NewDecompressor func() (Decompressor, error)
	KeepAlive       bool
	Logf            logger.Logf
}

type Persist

type Persist struct {
	PrivateMachineKey wgcfg.PrivateKey
	PrivateNodeKey    wgcfg.PrivateKey
	OldPrivateNodeKey wgcfg.PrivateKey // needed to request key rotation
	Provider          string
	LoginName         string
}

func (*Persist) Equals

func (p *Persist) Equals(p2 *Persist) bool

func (*Persist) Pretty

func (p *Persist) Pretty() string

type Status

type Status struct {
	LoginFinished *empty.Message
	Err           string
	URL           string
	Persist       *Persist          // locally persisted configuration
	NetMap        *NetworkMap       // server-pushed configuration
	Hostinfo      *tailcfg.Hostinfo // current Hostinfo data
	// contains filtered or unexported fields
}

func (*Status) Equal

func (s *Status) Equal(s2 *Status) bool

Equal reports whether s and s2 are equal.

func (Status) String

func (s Status) String() string

Jump to

Keyboard shortcuts

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