Documentation
¶
Index ¶
- func CreateTapDevice(name, cidr string) error
- func EnableIpv4Forwarding() error
- func FindIPv4(addrs []net.Addr) netip.Addr
- func GetDefaultGatewayDevice() string
- func GetInterfaceIndex(iface string) int
- func GetInterfaceMTU(name string) (int, error)
- func Htons(i uint16) uint16
- func OpenRawSocket(name string) (int, error)
- func StopTapDevice(name string) error
- type InterfaceInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTapDevice ¶
CreateTapDevice create tap device, sets cidr to it and up via ip command
func EnableIpv4Forwarding ¶
func EnableIpv4Forwarding() error
EnableIpv4Forwarding writes 1 to '/proc/sys/net/ipv4/ip_forward'
func GetDefaultGatewayDevice ¶
func GetDefaultGatewayDevice() string
GetDefaultGateway parses command 'ip route' and return default device name
func GetInterfaceIndex ¶
GetInterfaceIndex returns the index of the network interface with the given name.
func GetInterfaceMTU ¶
GetInterfaceMTU returns mtu from file '/sys/class/net/<interface>/mtu'
func OpenRawSocket ¶
OpenRawSocket opens raw socket by name and return its file descriptor
func StopTapDevice ¶
StopTapDevice stop tap device by name via ip command
Types ¶
type InterfaceInfo ¶
type InterfaceInfo struct {
Name string
HardAddr net.HardwareAddr
IP net.IP
}
func GetDefaultGatewayInfo ¶
func GetDefaultGatewayInfo(ifce string) (InterfaceInfo, error)
GetDefaultGatewayInfo gather gateway info by interface name or empty struct
func GetInterfaceInfo ¶
func GetInterfaceInfo(name string) (InterfaceInfo, error)
GetInterfaceInfo gather interface mac and ip address
Click to show internal directories.
Click to hide internal directories.