Documentation ¶
Index ¶
- Constants
- func ConfigureInterface(m *wgcfg.Config, tun *tun.NativeTun, dns []wgcfg.IP, dnsDomains []string) error
- func MonitorDefaultRoutes(device *device.Device, autoMTU bool, tun *tun.NativeTun) (*winipcfg.RouteChangeCallback, error)
- func NewFakeTun() tun.Device
- func RusagePrefixLog(logf logger.Logf) logger.Logf
- type ByteCount
- type Engine
- func NewFakeUserspaceEngine(logf logger.Logf, listenPort uint16) (Engine, error)
- func NewUserspaceEngine(logf logger.Logf, tunname string, listenPort uint16) (Engine, error)
- func NewUserspaceEngineAdvanced(logf logger.Logf, tundev tun.Device, routerGen RouterGen, listenPort uint16) (Engine, error)
- func NewWatchdog(e Engine) Engine
- type Loggify
- type NetInfoCallback
- type PeerStatus
- type RouteSettings
- type Router
- type RouterGen
- type Status
- type StatusCallback
Constants ¶
const DefaultTunName = "tailscale0"
Variables ¶
This section is empty.
Functions ¶
func ConfigureInterface ¶
func MonitorDefaultRoutes ¶
func NewFakeTun ¶
NewFakeTun returns a fake TUN device that does not depend on the operating system or any special permissions. It primarily exists for testing.
Types ¶
type ByteCount ¶
type ByteCount int64
ByteCount is the number of bytes that have been sent or received.
TODO: why is this a type? remove? TODO: document whether it's payload bytes only or if it includes framing overhead.
type Engine ¶
type Engine interface { // Reconfig reconfigures WireGuard and makes sure it's running. // This also handles setting up any kernel routes. // // The provided DNS domains are not part of wgcfg.Config, as // WireGuard itself doesn't care about such things. // // This is called whenever the tailcontrol (control plane) // sends an updated network map. Reconfig(cfg *wgcfg.Config, dnsDomains []string) error // SetFilter updates the packet filter. SetFilter(*filter.Filter) // SetStatusCallback sets the function to call when the // WireGuard status changes. SetStatusCallback(StatusCallback) // RequestStatus requests a WireGuard status update right // away, sent to the callback registered via SetStatusCallback. RequestStatus() // Close shuts down this wireguard instance, remove any routes // it added, etc. To bring it up again later, you'll need a // new Engine. Close() // Wait waits until the Engine's Close method is called or the // engine aborts with an error. You don't have to call this. // TODO: return an error? Wait() // LinkChange informs the engine that the system network // link has changed. The isExpensive parameter is set on links // where sending packets uses substantial power or money, // such as mobile data on a phone. // // LinkChange should be called whenever something changed with // the network, no matter how minor. The implementation should // look at the state of the network and decide whether the // change from before is interesting enough to warrant taking // action on. LinkChange(isExpensive bool) // SetDERPEnabled controls whether DERP is enabled. // It starts enabled by default. SetDERPEnabled(bool) // SetNetInfoCallback sets the function to call when a // new NetInfo summary is available. SetNetInfoCallback(NetInfoCallback) }
Engine is the Tailscale WireGuard engine interface.
func NewFakeUserspaceEngine ¶
func NewUserspaceEngine ¶
NewUserspaceEngine creates the named tun device and returns a Tailscale Engine running on it.
func NewUserspaceEngineAdvanced ¶
func NewUserspaceEngineAdvanced(logf logger.Logf, tundev tun.Device, routerGen RouterGen, listenPort uint16) (Engine, error)
NewUserspaceEngineAdvanced is like NewUserspaceEngine but takes a pre-created TUN device and allows specifing a custom router constructor and listening port.
func NewWatchdog ¶
NewWatchdog wraps an Engine and makes sure that all methods complete within a reasonable amount of time.
If they do not, the watchdog crashes the process.
type NetInfoCallback ¶
NetInfoCallback is the type used by Engine.SetNetInfoCallback.
type PeerStatus ¶
type RouteSettings ¶
type RouteSettings struct { LocalAddr wgcfg.CIDR // TODO: why is this here? how does it differ from wgcfg.Config's info? DNS []wgcfg.IP DNSDomains []string Cfg *wgcfg.Config }
RouteSettings is the full WireGuard config data (set of peers keys, IP, etc in wgcfg.Config) plus the things that WireGuard doesn't do itself, like DNS stuff.
func (*RouteSettings) OnlyRelevantParts ¶
func (rs *RouteSettings) OnlyRelevantParts() string
OnlyRelevantParts returns a string minimally describing the route settings.
type Router ¶
type Router interface { // Up brings the router up. Up() error // SetRoutes is called regularly on network map updates. // It's how you kernel route table entries are populated for // each peer. SetRoutes(RouteSettings) error // Close closes the router. Close() error }
Router is responsible for managing the system route table.
There's only one instance, and one per-OS implementation.
func NewFakeRouter ¶
NewFakeRouter returns a new fake Router implementation whose implementation does nothing and always returns nil errors.
type RouterGen ¶
RouterGen is the signature for the two funcs that create Router implementations: NewUserspaceRouter (which varies by operating system) and NewFakeRouter.
type Status ¶
type Status struct { Peers []PeerStatus LocalAddrs []string // TODO(crawshaw): []wgcfg.Endpoint? }
Status is the Engine status.
type StatusCallback ¶
StatusCallback is the type of status callbacks used by Engine.SetStatusCallback.
Exactly one of Status or error is non-nil.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package magicsock implements a socket that can change its communication path while in use, actively searching for the best way to communicate.
|
Package magicsock implements a socket that can change its communication path while in use, actively searching for the best way to communicate. |
Package monitor provides facilities for monitoring network interface changes.
|
Package monitor provides facilities for monitoring network interface changes. |