netutil

package
v1.70.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: BSD-3-Clause Imports: 18 Imported by: 26

Documentation

Overview

Package netutil contains misc shared networking code & types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcAdvertiseRoutes added in v1.48.0

func CalcAdvertiseRoutes(advertiseRoutes string, advertiseDefaultRoute bool) ([]netip.Prefix, error)

CalcAdvertiseRoutes calculates the requested routes to be advertised by a node. advertiseRoutes is the user-provided, comma-separated list of routes (IP addresses or CIDR prefixes) to advertise. advertiseDefaultRoute indicates whether the node should act as an exit node and advertise default routes.

func CheckIPForwarding added in v1.24.0

func CheckIPForwarding(routes []netip.Prefix, state *netmon.State) (warn, err error)

CheckIPForwarding reports whether IP forwarding is enabled correctly for subnet routing and exit node functionality on any interface. The state param must not be nil. The routes should only be advertised routes, and should not contain the nodes Tailscale IPs. It returns an error if it is unable to determine if IP forwarding is enabled. It returns a warning describing configuration issues if IP forwarding is non-functional or partly functional.

func CheckReversePathFiltering added in v1.58.0

func CheckReversePathFiltering(state *netmon.State) (warn []string, err error)

CheckReversePathFiltering reports whether reverse path filtering is either disabled or set to 'loose' mode for exit node functionality on any interface.

The routes should only be advertised routes, and should not contain the node's Tailscale IPs.

This function returns an error if it is unable to determine whether reverse path filtering is enabled, or a warning describing configuration issues if reverse path fitering is non-functional or partly functional.

func DefaultInterfacePortable added in v1.70.0

func DefaultInterfacePortable() (string, netip.Addr, error)

DefaultInterfacePortable looks up the current default interface using a portable lookup method that works on most systems with a BSD style socket interface.

Returns the interface name and IP address of the default route interface.

If the default cannot be determined, an error is returned. Requires that there is a route on the system servicing UDP IPv4.

func NewAltReadWriteCloserConn added in v1.24.0

func NewAltReadWriteCloserConn(rwc io.ReadWriteCloser, c net.Conn) net.Conn

NewAltReadWriteCloserConn returns a net.Conn that wraps rwc (for Read, Write, and Close) and c (for all other methods).

func NewDrainBufConn added in v1.24.0

func NewDrainBufConn(c net.Conn, initialReadBuf *bufio.Reader) net.Conn

NewDrainBufConn returns a net.Conn conditionally wrapping c, prefixing any bytes that are in initialReadBuf, which may be nil.

func NewOneConnListener

func NewOneConnListener(c net.Conn, addr net.Addr) net.Listener

NewOneConnListener returns a net.Listener that returns c on its first Accept and EOF thereafter.

The returned Listener's Addr method returns addr if non-nil. If nil, Addr returns a non-nil dummy address instead.

Types

This section is empty.

Jump to

Keyboard shortcuts

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