tunmanage

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRoute

func AddRoute(ifaceName string, destination netip.Prefix, gateway netip.Addr) error

AddRoute adds a specific route to the routing table

func BringInterfaceDown

func BringInterfaceDown(ifaceName string) error

BringInterfaceDown brings a network interface down

func BringInterfaceUp

func BringInterfaceUp(ifaceName string) error

BringInterfaceUp brings a network interface up

func DeleteRoutes

func DeleteRoutes(deviceName string, family int) error

RestoreOriginalRouting restores the original routing configuration

func DeleteTunDevice

func DeleteTunDevice(deviceName string) error

DeleteTunDevice completely removes a TUN device from the system Note: The kernel automatically removes all routes and IP addresses when the device is deleted

func RemoveIPAddress

func RemoveIPAddress(ifaceName string, ipAddr netip.Prefix) error

RemoveIPAddress removes an IP address from a network interface

func RemoveRoute

func RemoveRoute(ifaceName string, destination netip.Prefix, gateway netip.Addr) error

RemoveRoute removes a specific route from the routing table

func SetDNS

func SetDNS(dnsServers []netip.Addr) error

SetDNS sets DNS servers for the system

func SetDNSForInterface

func SetDNSForInterface(ifaceName string, dnsServers []netip.Addr) error

SetDNSForInterface sets DNS servers for a specific interface using systemd-resolved

func SetGateway

func SetGateway(ifaceName string, gateway netip.Addr) error

SetGateway sets the default gateway for an interface

func SetIPAddress

func SetIPAddress(link netlink.Link, ipAddr netip.Prefix) error

SetIPAddress sets an IP address for a network interface

func SetMTU

func SetMTU(ifaceName string, mtu int) error

SetMTU sets the MTU for a network interface

Types

type NetworkConfig

type NetworkConfig struct {
	InterfaceName string
	IP4           netip.Prefix
	IP6           netip.Prefix
	Gateway4      netip.Addr
	Gateway6      netip.Addr
	DNS4          []netip.Addr
	DNS6          []netip.Addr
	Routes4       []netip.Prefix
	Routes6       []netip.Prefix
	MTU           int
}

NetworkConfig represents the network configuration for an interface

type TunManager

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

func NewTunManager

func NewTunManager(option *tun.TunOption, enable6 bool) *TunManager

func (*TunManager) Close

func (t *TunManager) Close() error

func (*TunManager) SetTun

func (t *TunManager) SetTun(enable6 bool) error

func (*TunManager) SetTunSupport6

func (t *TunManager) SetTunSupport6(support6 bool) error

func (*TunManager) Start

func (t *TunManager) Start() error

Jump to

Keyboard shortcuts

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