Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetInterfaceIPv4Addr ¶
Gets the net.IP as IPv4 of a specified network interface
func InterfaceCount ¶
Returns the number of network interfaces available on the machine
Types ¶
type CallerContext ¶
type CallerContext uint8
Indicates what callback was called in the notification
const ( CONTEXT_NOTIFY_IP_INTERFACE_CHANGE CallerContext = iota CONTEXT_NOTIFY_UNICAST_IP_ADDRESS_CHANGE )
func (CallerContext) String ¶
func (cc CallerContext) String() string
type MibNotificationType ¶
type MibNotificationType uint8
The MIB_NOTIFICATION_TYPE enumeration type defines the notification type that is passed to a callback function when a notification occurs.
const ( // A parameter was changed. MIB_PARAMETER_NOTIFICATION MibNotificationType = iota // A new MIB instance was added. MIB_ADD_INSTANCE // A new MIB instance was added. MIB_DELETE_INSTANCE // A notification that is invoked immediately after registration for change notification completes. // This initial notification does not indicate that a change occurred to a MIB instance. // The purpose of this initial notification type is to provide confirmation that the callback function is properly registered. MIB_INITIAL_NOTIFICATION )
func (MibNotificationType) String ¶
func (mnt MibNotificationType) String() string
type MonitorNotification ¶
type MonitorNotification struct {
CallerContext CallerContext
NotificationType MibNotificationType
InterfaceIndex int
InterfaceAddress net.IP
}
type NetAddr ¶
NetAddr represents a network interface with an index, a name and an IP
func AllInterfaces ¶
Returns a list of all network interfaces as []NetAddr without any filtering
func InterfaceList ¶
Returns a list of network interfaces as []NetAddr filtering them by includeFlags and excludeFlags
a common includeFlags is net.FlagRunning to only get the enabled interfaces, and a common excludeFlags is net.FlagLoopback to remove the loopback interface from the list
type NetMonitor ¶
type NetMonitor struct {
MonitorNotificationChan chan MonitorNotification
// contains filtered or unexported fields
}
NetMonitor represents a registered monitor to the network interfaces on windows machines once registered, any change to a network name or ip address is sent to the MonitorChan
func NewNetMonitor ¶
func NewNetMonitor() *NetMonitor
Creates a new NetMonitor and initiates its channel
func (*NetMonitor) Register ¶
func (nm *NetMonitor) Register(initialNotification bool) error
Registers the network monitor to the windows notifier
If returns error it's possible the error came from either notification hooks registering, so it is up to the caller to clean up by calling Unregister() as well
func (*NetMonitor) Unregister ¶
func (nm *NetMonitor) Unregister() error
Removes the windows notifier to the network interfaces