netstack

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: BSD-3-Clause Imports: 35 Imported by: 21

Documentation

Overview

Package netstack wires up gVisor's netstack into Tailscale.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSubnetRouterWrapper added in v1.8.0

func NewSubnetRouterWrapper(r router.Router) router.Router

NewSubnetRouterWrapper returns a Router wrapper that prevents the underlying Router r from seeing any advertised subnet routes, as netstack will handle them instead.

Types

type DNSMap added in v1.6.0

type DNSMap map[string]netaddr.IP

DNSMap maps MagicDNS names (both base + FQDN) to their first IP. It should not be mutated once created.

func DNSMapFromNetworkMap added in v1.6.0

func DNSMapFromNetworkMap(nm *netmap.NetworkMap) DNSMap

func (DNSMap) Resolve added in v1.6.0

func (m DNSMap) Resolve(ctx context.Context, addr string) (netaddr.IPPort, error)

Resolve resolves addr into an IP:port using first the MagicDNS contents of m, else using the system resolver.

type Impl

type Impl struct {
	// ForwardTCPIn, if non-nil, handles forwarding an inbound TCP
	// connection.
	// TODO(bradfitz): provide mechanism for tsnet to reject a
	// port other than accepting it and closing it.
	ForwardTCPIn func(c net.Conn, port uint16)

	// ProcessLocalIPs is whether netstack should handle incoming
	// traffic directed at the Node.Addresses (local IPs).
	// It can only be set before calling Start.
	ProcessLocalIPs bool

	// ProcessSubnets is whether netstack should handle incoming
	// traffic destined to non-local IPs (i.e. whether it should
	// be a subnet router).
	// It can only be set before calling Start.
	ProcessSubnets bool
	// contains filtered or unexported fields
}

Impl contains the state for the netstack implementation, and implements wgengine.FakeImpl to act as a userspace network stack when Tailscale is running in fake mode.

func Create added in v1.6.0

func Create(logf logger.Logf, tundev *tstun.Wrapper, e wgengine.Engine, mc *magicsock.Conn) (*Impl, error)

Create creates and populates a new Impl.

func (*Impl) DialContextTCP added in v1.6.0

func (ns *Impl) DialContextTCP(ctx context.Context, addr string) (*gonet.TCPConn, error)

func (*Impl) DialContextUDP added in v1.10.0

func (ns *Impl) DialContextUDP(ctx context.Context, addr string) (*gonet.UDPConn, error)

func (*Impl) Start added in v1.6.0

func (ns *Impl) Start() error

Start sets up all the handlers so netstack can start working. Implements wgengine.FakeImpl.

Jump to

Keyboard shortcuts

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