Documentation
¶
Index ¶
- func AddTunAddr(tun gtun.Tun, addr string) error
- func AddTunRoute(tun gtun.Tun, route string) error
- func CreateDefaultTUN(base string, mtu int) (gtun.Tun, error)
- func GetTunAddrs(tun gtun.Tun) ([]string, error)
- func GetTunRotue(tun gtun.Tun) ([]string, error)
- func SetTunAddrs(tun gtun.Tun, addrs []string) error
- func SetTunMTU(tun gtun.Tun, mtu int) error
- func SetTunName(tun gtun.Tun) ([]string, error)
- func SetTunRoutes(tun gtun.Tun, routes []string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddTunAddr ¶
AddTunAddr updates list off addrs of provided Tun.
The address must be a CIDR prefix such as "10.0.0.1/32" or "fd00::1/128". The Tun must expose a non-nil File; otherwise sysnet.ErrUnknownTun is returned.
func AddTunRoute ¶
AddTunRoute updates list off routes of provided Tun.
The route must be a CIDR prefix such as "10.0.0.0/24" or "fd00::/64". The Tun must expose a non-nil File; otherwise sysnet.ErrUnknownTun is returned.
func CreateDefaultTUN ¶
CreateDefaultTUN creates a TUN device whose name is generated from base.
Unlike tuntap.CreateTUN, base is not used as the exact interface name. Instead, each attempt uses the template "<base>-<rand>", where rand is a freshly generated 5-character alpha-numeric string. For example, base "vpn" can produce "vpn-aZ38fK02Lm".
If the generated name is already occupied, CreateDefaultTUN generates another random suffix and tries again. Only name-occupied errors are retryable; random generation failures, invalid names, permission errors, missing /dev/net/tun, unsupported MTU values, and all other tuntap.CreateTUN errors are returned immediately.
func GetTunAddrs ¶
GetTunAddrs returns list off addrs of provided Tun.
Returned entries are CIDR prefixes assigned to the interface. The Tun must expose a non-nil File; otherwise sysnet.ErrUnknownTun is returned.
func GetTunRotue ¶
GetTunRotue returns list off routes of provided Tun.
The misspelling is kept to match the gonnect sysnet.System interface. The Tun must expose a non-nil File; otherwise sysnet.ErrUnknownTun is returned.
func SetTunAddrs ¶
SetTunAddrs updates list off addrs of provided Tun.
Existing interface addresses are removed before the new CIDR addresses are added. The Tun must expose a non-nil File; otherwise sysnet.ErrUnknownTun is returned.
func SetTunMTU ¶
SetTunMTU updates MTU of provided Tun.
The Tun must expose a non-nil File; otherwise sysnet.ErrUnknownTun is returned. Values lower than the IPv4 minimum MTU are replaced with a sensible default of 1420 bytes.
func SetTunName ¶
SetTunName updates name of provided Tun.
The current gonnect sysnet.System interface does not provide a replacement name argument, so this function validates that the Tun is known through its File and returns the current kernel interface name. If File is nil, sysnet.ErrUnknownTun is returned.
func SetTunRoutes ¶
SetTunRoutes updates list off routes of provided Tun.
Existing main-table routes whose output interface is the Tun are removed before the provided CIDR routes are added. The Tun must expose a non-nil File; otherwise sysnet.ErrUnknownTun is returned.
Types ¶
This section is empty.