netstack

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMTU = 1280 // IPv6 minimum MTU, required for some PPPoE links.

Variables

This section is empty.

Functions

func TCPForwarder

func TCPForwarder(ctx context.Context, conf *TCPForwarderConfig) func(ipstack *stack.Stack, req *tcp.ForwarderRequest)

TCPForwarder forwards TCP connections.

Types

type NetTun

type NetTun struct {
	// contains filtered or unexported fields
}

func CreateNetTUN

func CreateNetTUN(localAddresses, dnsServers []netip.Addr, mtu *int) (tun.Device, *NetTun, error)

func (*NetTun) BatchSize

func (tun *NetTun) BatchSize() int

func (*NetTun) Close

func (tun *NetTun) Close() error

func (*NetTun) DialContext

func (tun *NetTun) DialContext(ctx context.Context, network, address string) (net.Conn, error)

DialContext establishes a connection to the specified network and address, resolving the hostname if necessary.

func (*NetTun) EnableForwarding

func (tun *NetTun) EnableForwarding(tcpHandler func(*stack.Stack, *tcp.ForwarderRequest), promiscuous bool) error

EnableForwarding enables packet forwarding on the network interface. Promiscuous mode should be enabled if the network interface is expected to forward packets with a destination address different from the address assigned to the NIC, e.g., when acting as a router.

func (*NetTun) Events

func (tun *NetTun) Events() <-chan tun.Event

func (*NetTun) File

func (tun *NetTun) File() *os.File

func (*NetTun) LocalAddresses

func (tun *NetTun) LocalAddresses() []netip.Prefix

LocalAddresses returns the list of local addresses assigned to the NetTun device.

func (*NetTun) LookupContextHost

func (tun *NetTun) LookupContextHost(ctx context.Context, host string) ([]string, error)

LookupContextHost resolves the hostname to an IP address.

func (*NetTun) MTU

func (tun *NetTun) MTU() (int, error)

func (*NetTun) Name

func (tun *NetTun) Name() (string, error)

func (*NetTun) Read

func (tun *NetTun) Read(buf [][]byte, sizes []int, offset int) (int, error)

func (*NetTun) Write

func (tun *NetTun) Write(buf [][]byte, offset int) (int, error)

func (*NetTun) WriteNotify

func (tun *NetTun) WriteNotify()

type TCPForwarderConfig

type TCPForwarderConfig struct {
	// Allowed destination prefixes.
	AllowedDestinations []netip.Prefix
	// Denied destination prefixes.
	DeniedDestinations []netip.Prefix
	// The network to forward connections to.
	Upstream network.Network
}

Jump to

Keyboard shortcuts

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