Documentation
¶
Index ¶
- func AddRoute(ifaceName string, destination netip.Prefix, gateway netip.Addr) error
- func BringInterfaceDown(ifaceName string) error
- func BringInterfaceUp(ifaceName string) error
- func DeleteRoutes(deviceName string, family int) error
- func DeleteTunDevice(deviceName string) error
- func RemoveIPAddress(ifaceName string, ipAddr netip.Prefix) error
- func RemoveRoute(ifaceName string, destination netip.Prefix, gateway netip.Addr) error
- func SetDNS(dnsServers []netip.Addr) error
- func SetDNSForInterface(ifaceName string, dnsServers []netip.Addr) error
- func SetGateway(ifaceName string, gateway netip.Addr) error
- func SetIPAddress(link netlink.Link, ipAddr netip.Prefix) error
- func SetMTU(ifaceName string, mtu int) error
- type NetworkConfig
- type TunManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BringInterfaceDown ¶
BringInterfaceDown brings a network interface down
func BringInterfaceUp ¶
BringInterfaceUp brings a network interface up
func DeleteRoutes ¶
RestoreOriginalRouting restores the original routing configuration
func DeleteTunDevice ¶
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 ¶
RemoveIPAddress removes an IP address from a network interface
func RemoveRoute ¶
RemoveRoute removes a specific route from the routing table
func SetDNSForInterface ¶
SetDNSForInterface sets DNS servers for a specific interface using systemd-resolved
func SetGateway ¶
SetGateway sets the default gateway for an interface
func SetIPAddress ¶
SetIPAddress sets an IP address 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