kernel

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kernel

type Kernel interface {
	EnableIPForwarding() error
	IsIPForwardingEnabled() (bool, error)
	CreateRoute(destination *net.IPNet, gateway net.IP, priority int, ifKey NetworkInterface) error
	DeleteRoute(destination *net.IPNet, gateway net.IP, priority int, ifKey NetworkInterface) error
	InterfaceExists(ifKey NetworkInterface) (bool, error)
	RouteExists(destination *net.IPNet, gateway net.IP, priority int, ifKey NetworkInterface) (bool, error)
}

Kernel defines the interface for kernel route management.

type NetworkInterface

type NetworkInterface int

NetworkInterface is an enum for network interface keys.

const (
	N3 NetworkInterface = iota
	N6
)

type RealKernel

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

RealKernel is the production implementation of the Kernel interface.

func NewRealKernel

func NewRealKernel(n3Interface, n6Interface string) *RealKernel

NewRealKernel creates a new RealKernel instance. The user must supply the interface names for the n3 and n6 interfaces.

func (*RealKernel) CreateRoute

func (rk *RealKernel) CreateRoute(destination *net.IPNet, gateway net.IP, priority int, ifKey NetworkInterface) error

CreateRoute adds a route to the kernel for the interface defined by ifKey.

func (*RealKernel) DeleteRoute

func (rk *RealKernel) DeleteRoute(destination *net.IPNet, gateway net.IP, priority int, ifKey NetworkInterface) error

DeleteRoute removes a route from the kernel for the interface defined by ifKey.

func (*RealKernel) EnableIPForwarding

func (rk *RealKernel) EnableIPForwarding() error

EnableIPForwarding enables IP forwarding on the host.

func (*RealKernel) InterfaceExists

func (rk *RealKernel) InterfaceExists(ifKey NetworkInterface) (bool, error)

InterfaceExists checks if the interface corresponding to ifKey exists.

func (*RealKernel) IsIPForwardingEnabled

func (rk *RealKernel) IsIPForwardingEnabled() (bool, error)

IsIPForwardingEnabled checks if IP forwarding is enabled on the host.

func (*RealKernel) RouteExists

func (rk *RealKernel) RouteExists(destination *net.IPNet, gateway net.IP, priority int, ifKey NetworkInterface) (bool, error)

RouteExists checks if a route exists for the interface defined by ifKey.

Jump to

Keyboard shortcuts

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