Documentation
¶
Overview ¶
Package network provides utility functions to extract some data about network
Index ¶
- Constants
- Variables
- func AddrEqual(a, b string) bool
- func DisplayInterfaces(includeAny bool) error
- func GetDefaultGatewayIPv4() (netip.Addr, error)
- func GetDefaultInterface() (*net.Interface, error)
- func GetGatewayIPv4FromInterface(iface string) (netip.Addr, error)
- func GetIPv4PrefixFromInterface(iface *net.Interface) (netip.Prefix, error)
- func InterfaceByName(name string) (*net.Interface, error)
- func IsLocalAddress(addr string) bool
- func ListenPacket(conf *ListenConfig) (*packet.Conn, error)
- type ListenConfig
Constants ¶
View Source
const ETH_P_ALL int = 0x03
Variables ¶
View Source
var ( BroadcastMAC = net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff} LoopbackMAC = net.HardwareAddr{0x00, 0x00, 0x00, 0x00, 0x00, 0x00} )
Functions ¶
func AddrEqual ¶ added in v0.0.14
AddrEqual compares two address strings and returns true if they are equal.
It treats loopback and unspecified IPs as equivalent. Returns false in case of inequality or error.
func DisplayInterfaces ¶
func GetDefaultGatewayIPv4 ¶
func GetDefaultInterface ¶
func InterfaceByName ¶
InterfaceByName returns the interface specified by name.
func IsLocalAddress ¶ added in v0.0.10
func ListenPacket ¶ added in v0.0.14
func ListenPacket(conf *ListenConfig) (*packet.Conn, error)
Types ¶
type ListenConfig ¶ added in v0.0.14
type ListenConfig struct { Device *net.Interface // network interface which to bind to, if not specified default interface is used Protocol int // network protocol, defaults to ETH_P_ALL Promiscuous *bool // enable or disable promiscuous mode FilterExpr string // packet filter expression like in tcpdump }
Click to show internal directories.
Click to hide internal directories.