netstack

package
v0.0.0-...-3caaee0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: BSD-3-Clause Imports: 48 Imported by: 0

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

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

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

Create creates and populates a new Impl.

func (*Impl) Close

func (ns *Impl) Close() error

func (*Impl) DialContextTCP

func (ns *Impl) DialContextTCP(ctx context.Context, ipp netip.AddrPort) (*gonet.TCPConn, error)

func (*Impl) DialContextUDP

func (ns *Impl) DialContextUDP(ctx context.Context, ipp netip.AddrPort) (*gonet.UDPConn, error)

func (*Impl) SetLocalBackend

func (ns *Impl) SetLocalBackend(lb *ipnlocal.LocalBackend)

SetLocalBackend sets the LocalBackend; it should only be run before the Start method is called.

func (*Impl) Start

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