system

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package system contains utilities for managing network interfaces on the system.

Index

Constants

View Source
const DefaultMTU = 1350

DefaultMTU is the default MTU for wireguard interfaces.

View Source
const MaxMTU = 1500

MaxMTU is the maximum MTU for wireguard interfaces.

Variables

This section is empty.

Functions

func IsInterfaceNotExists

func IsInterfaceNotExists(err error) bool

IsInterfaceNotExists returns true if the given error is an interface not exists error.

func IsRouteExists

func IsRouteExists(err error) bool

IsRouteExists returns true if the given error is a route exists error.

Types

type Interface

type Interface interface {
	// Name returns the real name of the interface.
	Name() string
	// AddressV4 should return the current private IPv4 address of this interface.
	AddressV4() netip.Prefix
	// AddressV6 should return the current private IPv6 address of this interface.
	AddressV6() netip.Prefix
	// Up activates the interface.
	Up(context.Context) error
	// Down deactivates the interface.
	Down(context.Context) error
	// Destroy destroys the interface.
	Destroy(context.Context) error
	// AddRoute adds a route for the given network.
	AddRoute(context.Context, netip.Prefix) error
	// RemoveRoute removes the route for the given network.
	RemoveRoute(context.Context, netip.Prefix) error
}

Interface represents an underlying machine network interface for use with wireguard.

func New

func New(ctx context.Context, opts *Options) (Interface, error)

New creates a new interface using the given options.

type Options

type Options struct {
	// Name is the name of the interface.
	Name string
	// NetworkV4 is the private IPv4 network of this interface.
	NetworkV4 netip.Prefix
	// NetworkV6 is the private IPv6 network of this interface.
	NetworkV6 netip.Prefix
	// ForceTUN forces the use of a TUN interface.
	ForceTUN bool
	// MTU is the MTU of the interface. If unset, it will be automatically
	// detected from the host.
	MTU uint32
}

Options represents the options for creating a new interface.

Directories

Path Synopsis
Package firewall contains an interface for interacting with the system firewall.
Package firewall contains an interface for interacting with the system firewall.

Jump to

Keyboard shortcuts

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