Documentation ¶
Overview ¶
Package router presents an interface to manipulate the host network stack's state.
Index ¶
- func Cleanup(logf logger.Logf, interfaceName string)
- type CallbackRouter
- func (r *CallbackRouter) Close() error
- func (r *CallbackRouter) GetBaseConfig() (dns.OSConfig, error)
- func (r *CallbackRouter) Set(rcfg *Config) error
- func (r *CallbackRouter) SetDNS(dcfg dns.OSConfig) error
- func (r *CallbackRouter) SupportsSplitDNS() bool
- func (r *CallbackRouter) Up() error
- func (r *CallbackRouter) UpdateMagicsockPort(_ uint16, _ string) error
- type Config
- type RouteTable
- type Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CallbackRouter ¶
type CallbackRouter struct { SetBoth func(rcfg *Config, dcfg *dns.OSConfig) error SplitDNS bool // GetBaseConfigFunc optionally specifies a function to return the current DNS // config in response to GetBaseConfig. // // If nil, reading the current config isn't supported and GetBaseConfig() // will return ErrGetBaseConfigNotSupported. GetBaseConfigFunc func() (dns.OSConfig, error) // InitialMTU is the MTU the tun should be initialized with. // Zero means don't change the MTU from the default. This MTU // is applied only once, shortly after the TUN is created, and // ignored thereafter. InitialMTU uint32 // contains filtered or unexported fields }
CallbackRouter is an implementation of both Router and dns.OSConfigurator. When either network or DNS settings are changed, SetBoth is called with both configs. Mainly used as a shim for OSes that want to set both network and DNS configuration simultaneously (Mac, iOS, Android).
func (*CallbackRouter) Close ¶
func (r *CallbackRouter) Close() error
func (*CallbackRouter) GetBaseConfig ¶
func (r *CallbackRouter) GetBaseConfig() (dns.OSConfig, error)
func (*CallbackRouter) Set ¶
func (r *CallbackRouter) Set(rcfg *Config) error
Set implements Router.
func (*CallbackRouter) SetDNS ¶
func (r *CallbackRouter) SetDNS(dcfg dns.OSConfig) error
SetDNS implements dns.OSConfigurator.
func (*CallbackRouter) SupportsSplitDNS ¶
func (r *CallbackRouter) SupportsSplitDNS() bool
SupportsSplitDNS implements dns.OSConfigurator.
func (*CallbackRouter) UpdateMagicsockPort ¶
func (r *CallbackRouter) UpdateMagicsockPort(_ uint16, _ string) error
UpdateMagicsockPort implements the Router interface. This implementation does nothing and returns nil because this router does not currently need to know what the magicsock UDP port is.
type Config ¶
type Config struct { // LocalAddrs are the address(es) for this node. This is // typically one IPv4/32 (the 100.x.y.z CGNAT) and one // IPv6/128 (Tailscale ULA). LocalAddrs []netip.Prefix // Routes are the routes that point into the Tailscale // interface. These are the /32 and /128 routes to peers, as // well as any other subnets that peers are advertising and // this node has chosen to use. Routes []netip.Prefix // LocalRoutes are the routes that should not be routed through Tailscale. // There are no priorities set in how these routes are added, normal // routing rules apply. LocalRoutes []netip.Prefix // NewMTU is currently only used by the MacOS network extension // app to set the MTU of the tun in the router configuration // callback. If zero, the MTU is unchanged. NewMTU int // Linux-only things below, ignored on other platforms. SubnetRoutes []netip.Prefix // subnets being advertised to other Tailscale nodes SNATSubnetRoutes bool // SNAT traffic to local subnets NetfilterMode preftype.NetfilterMode // how much to manage netfilter rules NetfilterKind string // what kind of netfilter to use (nftables, iptables) }
Config is the subset of Tailscale configuration that is relevant to the OS's network stack.
type RouteTable ¶
RouteTable is a Linux routing table: both its name and number. See /etc/iproute2/rt_tables.
type Router ¶
type Router interface { // Up brings the router up. Up() error // Set updates the OS network stack with a new Config. It may be // called multiple times with identical Configs, which the // implementation should handle gracefully. Set(*Config) error // UpdateMagicsockPort tells the OS network stack what port magicsock // is currently listening on, so it can be threaded through firewalls // and such. This is distinct from Set() since magicsock may rebind // ports independently from the Config changing. // // network should be either "udp4" or "udp6". UpdateMagicsockPort(port uint16, network string) error // Close closes the router. Close() error }
Router is responsible for managing the system network stack.
There is typically only one instance of this interface per process.