[client] Extract WGWatcher into its own wg_watcher package

Move the WireGuard handshake watcher out of the peer package into
client/internal/peer/wg_watcher. The test stays an internal test since
it drives the unexported checkPeriod. Update conn.go to reference the
watcher through the package.
This commit is contained in:
Zoltan Papp
2026-07-11 15:17:16 +02:00
parent 4d76fd3c80
commit 78f3165e85
3 changed files with 5 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ import (
"github.com/netbirdio/netbird/client/internal/peer/id"
"github.com/netbirdio/netbird/client/internal/peer/state_dump"
"github.com/netbirdio/netbird/client/internal/peer/status"
"github.com/netbirdio/netbird/client/internal/peer/wg_watcher"
"github.com/netbirdio/netbird/client/internal/peer/worker"
"github.com/netbirdio/netbird/client/internal/portforward"
"github.com/netbirdio/netbird/client/internal/rosenpass"
@@ -138,7 +139,7 @@ type Conn struct {
relayDialInFlight bool
pendingRelayOffer *OfferAnswer
wgWatcher *WGWatcher
wgWatcher *wg_watcher.WGWatcher
wgWatcherWg sync.WaitGroup
wgWatcherCancel context.CancelFunc
// wgTimeouts counts consecutive WireGuard handshake timeouts without a
@@ -192,7 +193,7 @@ func NewConn(config ConnConfig, services ServiceDependencies) (*Conn, error) {
statusICE: worker.NewAtomicStatus(),
dumpState: dumpState,
endpointUpdater: NewEndpointUpdater(connLog, config.WgConfig, isController(config)),
wgWatcher: NewWGWatcher(connLog, config.WgConfig.WgInterface, config.Key, dumpState),
wgWatcher: wg_watcher.NewWGWatcher(connLog, config.WgConfig.WgInterface, config.Key, dumpState),
metricsRecorder: services.MetricsRecorder,
}

View File

@@ -1,4 +1,4 @@
package peer
package wg_watcher
import (
"context"

View File

@@ -1,4 +1,4 @@
package peer
package wg_watcher
import (
"context"