diff --git a/client/internal/networkmonitor/monitor.go b/client/internal/networkmonitor/monitor.go index 7f7c42d08..b3fa82e52 100644 --- a/client/internal/networkmonitor/monitor.go +++ b/client/internal/networkmonitor/monitor.go @@ -28,16 +28,11 @@ type NetworkMonitor struct { cancel context.CancelFunc wg sync.WaitGroup mu sync.Mutex - - // nexthopChanged reports whether the default next hop changed; overridable in tests. - nexthopChanged func(oldv4, oldv6 systemops.Nexthop) bool } // New creates a new network monitor. func New() *NetworkMonitor { - return &NetworkMonitor{ - nexthopChanged: nexthopChanged, - } + return &NetworkMonitor{} } // Listen begins monitoring network changes. When a change is detected, this function will return without error. @@ -104,7 +99,7 @@ func (nw *NetworkMonitor) Listen(ctx context.Context) (err error) { case <-timer.C: // A flapping NIC may return to the same default route after the // debounce window; only restart if the next hop actually changed. - if nw.nexthopChanged(nexthop4, nexthop6) { + if nexthopChanged(nexthop4, nexthop6) { return nil } log.Debug("Network monitor: default route unchanged after debounce, ignoring") diff --git a/client/internal/networkmonitor/monitor_test.go b/client/internal/networkmonitor/monitor_test.go index a948eba8f..a58013fd0 100644 --- a/client/internal/networkmonitor/monitor_test.go +++ b/client/internal/networkmonitor/monitor_test.go @@ -61,7 +61,6 @@ func TestNetworkMonitor_Event(t *testing.T) { } } nw := New() - nw.nexthopChanged = func(_, _ systemops.Nexthop) bool { return true } defer nw.Stop() var resErr error @@ -83,7 +82,6 @@ func TestNetworkMonitor_MultiEvent(t *testing.T) { checkChangeFn = me.checkChange nw := New() - nw.nexthopChanged = func(_, _ systemops.Nexthop) bool { return true } defer nw.Stop() done := make(chan struct{})