Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Change ¶ added in v0.84.0
type Change struct {
Kind ChangeKind
Before NextHops
After NextHops
}
Change describes one debounced underlay change.
type ChangeKind ¶ added in v0.84.0
type ChangeKind int
ChangeKind classifies how the underlay default route moved.
const ( // ChangeNone means the default next hops are the same as before, as after // a route flap. ChangeNone ChangeKind = iota // ChangeAddress means the default interface and gateway stayed, but the // interface addresses changed, as with a new DHCP lease. ChangeAddress // ChangeGateway means the default route stayed on the same interface but // its gateway changed, as when the same Wi-Fi adapter joins another network. ChangeGateway // ChangeInterface means the default route moved to another interface, // even through the same gateway, as when a cable or a dock is plugged in. ChangeInterface // ChangeOffline means no default route is left at all, as with Wi-Fi off // and no cable. The snapshot after it is empty and must not become the // baseline: the next change is compared with the network before it. ChangeOffline // ChangeWake means the system woke up from sleep during the change, // whatever the routes did. Wake-ups keep today's restart. ChangeWake // ChangeUnknown means the underlay could not be read after the event. // It says nothing about the network, so nothing is changed on it. ChangeUnknown )
func (ChangeKind) String ¶ added in v0.84.0
func (k ChangeKind) String() string
String returns the change kind as it appears in logs.
type NetworkMonitor ¶ added in v0.27.8
type NetworkMonitor struct {
// contains filtered or unexported fields
}
NetworkMonitor watches for changes in network configuration.
func (*NetworkMonitor) Listen ¶ added in v0.38.0
Listen begins monitoring network changes. When a change is detected, it returns how the underlay moved. It can be called again after it returns, to watch for the next change. The caller passes the snapshot to compare with, normally the After of the previous change; an empty baseline makes Listen read the current one and wait until a default route exists.
func (*NetworkMonitor) Stop ¶ added in v0.27.8
func (nw *NetworkMonitor) Stop()
Stop stops the network monitor.
type NextHops ¶ added in v0.84.0
type NextHops struct {
V4 systemops.Nexthop
V6 systemops.Nexthop
// Addrs holds the unicast addresses of the default interfaces, sorted and
// without link-local ones.
Addrs []netip.Addr
}
NextHops is the underlay snapshot: the default next hop of each address family and the addresses of the default interfaces.
func (NextHops) HasDefault ¶ added in v0.84.0
HasDefault reports whether the snapshot has a default route in any family.