router

package
v0.98.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: BSD-3-Clause Imports: 15 Imported by: 33

Documentation

Overview

Package router presents an interface to manipulate the host network stack's state.

Index

Constants

This section is empty.

Variables

View Source
var SetRoutesFunc func(cfg *Config) error

SetRoutesFunc applies the given router settings to the OS network stack. cfg is guaranteed to be non-nil.

This is logically part of the router_darwin.go implementation, and should not be used on other platforms.

The code to reconfigure the network stack on MacOS and iOS is in the non-open `ipn-go-bridge` package, which bridges between the Go and Swift pieces of the application. The ipn-go-bridge sets SetRoutesFunc at startup.

So why isn't this in router_darwin.go? Because in the non-oss repository, we build ipn-go-bridge when developing on Linux as well as MacOS, so that we don't have to wait until the Mac CI to discover that we broke it. So this one definition needs to exist in both the darwin and linux builds. Hence this file and build tag.

Functions

This section is empty.

Types

type Config

type Config struct {
	LocalAddrs []netaddr.IPPrefix
	DNS        []netaddr.IP
	DNSDomains []string
	Routes     []netaddr.IPPrefix // routes to point into the Tailscale interface

	SubnetRoutes     []netaddr.IPPrefix // subnets being advertised to other Tailscale nodes
	SNATSubnetRoutes bool               // SNAT traffic to local subnets
	NetfilterMode    NetfilterMode      // how much to manage netfilter rules
}

Config is the subset of Tailscale configuration that is relevant to the OS's network stack.

type NetfilterMode

type NetfilterMode int

NetfilterMode is the firewall management mode to use when programming the Linux network stack.

const (
	NetfilterOff      NetfilterMode = iota // remove all tailscale netfilter state
	NetfilterNoDivert                      // manage tailscale chains, but don't call them
	NetfilterOn                            // manage tailscale chains and call them from main chains
)

func (NetfilterMode) String

func (m NetfilterMode) String() string

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

	// 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.

func New

func New(logf logger.Logf, wgdev *device.Device, tundev tun.Device) (Router, error)

New returns a new Router for the current platform, using the provided tun device.

func NewFake

func NewFake(logf logger.Logf, _ *device.Device, _ tun.Device) (Router, error)

NewFakeRouter returns a Router that does nothing when called and always returns nil errors.

Jump to

Keyboard shortcuts

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