netutil

package
v0.0.0-...-113f59a Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package netutil contains misc shared networking code & types.

Package netutil contains misc shared networking code & types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcAdvertiseRoutes

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

func CheckIPForwarding(routes []netip.Prefix, state *interfaces.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

func CheckReversePathFiltering(routes []netip.Prefix, state *interfaces.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 state param can be nil, in which case interfaces.GetState is used.

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 NewAltReadWriteCloserConn

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

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