netstack
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package netstack wires up gVisor's netstack into Tailscale.
Index¶
- type Impl
- func (ns *Impl) Close() error
- func (ns *Impl) DialContextTCP(ctx context.Context, ipp netip.AddrPort) (*gonet.TCPConn, error)
- func (ns *Impl) DialContextTCPWithBind(ctx context.Context, localAddr netip.Addr, remoteAddr netip.AddrPort) (*gonet.TCPConn, error)
- func (ns *Impl) DialContextUDP(ctx context.Context, ipp netip.AddrPort) (*gonet.UDPConn, error)
- func (ns *Impl) DialContextUDPWithBind(ctx context.Context, localAddr netip.Addr, remoteAddr netip.AddrPort) (*gonet.UDPConn, error)
- func (ns *Impl) ExpVar() expvar.Var
- func (ns *Impl) ListenPacket(network, address string) (net.PacketConn, error)
- func (ns *Impl) SetTransportProtocolOption(transport tcpip.TransportProtocolNumber, ...) tcpip.Error
- func (ns *Impl) Start(b LocalBackend) error
- func (ns *Impl) UpdateNetstackIPs(nm *netmap.NetworkMap)
- type LocalBackend
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeImpl¶
type Impl struct {// GetTCPHandlerForFlow conditionally handles an incoming TCP flow for the// provided (src/port, dst/port) 4-tuple.//// A nil value is equivalent to a func returning (nil, false).//// If func returns intercept=false, the default forwarding behavior (if// ProcessLocalIPs and/or ProcesssSubnetIPs) takes place.//// When intercept=true, the behavior depends on whether the returned handler// is non-nil: if nil, the connection is rejected. If non-nil, handler takes// over the TCP conn.GetTCPHandlerForFlow func(src, dstnetip.AddrPort) (handler func(net.Conn), interceptbool)// GetUDPHandlerForFlow conditionally handles an incoming UDP flow for the// provided (src/port, dst/port) 4-tuple.//// A nil value is equivalent to a func returning (nil, false).//// If func returns intercept=false, the default forwarding behavior (if// ProcessLocalIPs and/or ProcesssSubnetIPs) takes place.//// When intercept=true, the behavior depends on whether the returned handler// is non-nil: if nil, the connection is rejected. If non-nil, handler takes// over the UDP flow.GetUDPHandlerForFlow func(src, dstnetip.AddrPort) (handler func(nettype.ConnPacketConn), interceptbool)// ProcessLocalIPs is whether netstack should handle incoming// traffic directed at the Node.Addresses (local IPs).// It can only be set before calling Start.ProcessLocalIPsbool// 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.ProcessSubnetsbool// contains filtered or unexported fields}Impl contains the state for the netstack implementation,and implements wgengine.FakeImpl to act as a userspace networkstack when Tailscale is running in fake mode.
funcCreate¶added inv1.6.0
func Create(logflogger.Logf, tundev *tstun.Wrapper, ewgengine.Engine, mc *magicsock.Conn, dialer *tsdial.Dialer, dns *dns.Manager, pm *proxymap.Mapper) (*Impl,error)
Create creates and populates a new Impl.
func (*Impl)DialContextTCP¶added inv1.6.0
func (*Impl)DialContextTCPWithBind¶added inv1.82.0
func (ns *Impl) DialContextTCPWithBind(ctxcontext.Context, localAddrnetip.Addr, remoteAddrnetip.AddrPort) (*gonet.TCPConn,error)
DialContextTCPWithBind creates a new gonet.TCPConn connected to the specifiedremoteAddress with its local address bound to localAddr on an available port.
func (*Impl)DialContextUDP¶added inv1.10.0
func (*Impl)DialContextUDPWithBind¶added inv1.82.0
func (ns *Impl) DialContextUDPWithBind(ctxcontext.Context, localAddrnetip.Addr, remoteAddrnetip.AddrPort) (*gonet.UDPConn,error)
DialContextUDPWithBind creates a new gonet.UDPConn. Connected to remoteAddr.With its local address bound to localAddr on an available port.
func (*Impl)ExpVar¶added inv1.60.0
ExpVar returns an expvar variable suitable for registering with expvar.Publish.
func (*Impl)ListenPacket¶added inv1.68.0
func (ns *Impl) ListenPacket(network, addressstring) (net.PacketConn,error)
ListenPacket listens for incoming packets for the given network and address.Address must be of the form "ip:port" or "[ip]:port".
As of 2024-05-18, only udp4 and udp6 are supported.
func (*Impl)SetTransportProtocolOption¶added inv1.80.0
func (ns *Impl) SetTransportProtocolOption(transporttcpip.TransportProtocolNumber, optiontcpip.SettableTransportProtocolOption)tcpip.Error
SetTransportProtocolOption forwards to the underlyingstack.Stack.SetTransportProtocolOption. Callers are responsible forensuring that the options are valid, compatible and appropriate for their usecase. Compatibility may change at any version.
func (*Impl)Start¶added inv1.6.0
func (ns *Impl) Start(bLocalBackend)error
Start sets up all the handlers so netstack can start working. Implementswgengine.FakeImpl.
func (*Impl)UpdateNetstackIPs¶added inv1.50.0
func (ns *Impl) UpdateNetstackIPs(nm *netmap.NetworkMap)
UpdateNetstackIPs updates the set of local IPs that netstack should handlefrom nm.
TODO(bradfitz): don't pass the whole netmap here; just pass the twoaddress slice views.
typeLocalBackend¶added inv1.90.0
type LocalBackend =any
LocalBackend is a fake name for *ipnlocal.LocalBackend to avoid an import cycle.