routes

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRouteExists = errors.New("route already exists")

ErrRouteExists is returned when a route already exists.

Functions

func Add

func Add(ctx context.Context, ifaceName string, addr netip.Prefix) error

Add adds a route to the interface with the given name.

func EnableIPForwarding

func EnableIPForwarding() error

EnableIPForwarding enables IP forwarding.

func Remove

func Remove(ctx context.Context, ifaceName string, addr netip.Prefix) error

Remove removes a route from the interface with the given name.

func SetDefaultIPv4Gateway

func SetDefaultIPv4Gateway(ctx context.Context, gateway Gateway) error

SetDefaultIPv4Gateway sets the default IPv4 gateway for the current system.

func SetDefaultIPv6Gateway

func SetDefaultIPv6Gateway(ctx context.Context, gateway Gateway) error

SetDefaultIPv6Gateway sets the default IPv6 gateway for the current system.

Types

type Gateway added in v0.11.2

type Gateway struct {
	// Name is the name of the gateway interface.
	Name string
	// Addr is the IP address of the gateway interface.
	Addr netip.Addr
}

Gateway represents a gateway route. It contains the name and IP address of a gateway interface.

func GetDefaultGateway

func GetDefaultGateway(_ context.Context) (Gateway, error)

GetDefaultGateway returns the default gateway of the current system.

Jump to

Keyboard shortcuts

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