[client] Extend WG watcher for ICE connection too#5133
Conversation
📝 WalkthroughWalkthroughMoves WireGuard watcher lifecycle out of WorkerRelay into Conn, replacing per-watcher cancellable contexts with an explicit enabled flag and mutex, updates constructor signatures (NewWGWatcher, NewWorkerRelay), adds Conn-level enable/disable helpers and disconnect handlers, and adapts tests accordingly. Changes
Sequence DiagramsequenceDiagram
participant Conn as Conn
participant WGWatcher as WGWatcher
participant WorkerRelay as WorkerRelay
Note over WorkerRelay,WGWatcher: Old: WorkerRelay owned watcher
WorkerRelay->>WGWatcher: EnableWgWatcher()
WorkerRelay->>WGWatcher: DisableWgWatcher()
Note over Conn,WGWatcher: New: Conn owns watcher lifecycle
Conn->>WorkerRelay: NewWorkerRelay() (no watcher)
Conn->>WGWatcher: NewWGWatcher(dumpState)
Conn->>WGWatcher: enableWgWatcherIfNeeded(ctx,onDisconnected)
WGWatcher->>WGWatcher: Set enabled = true
WorkerRelay-->>Conn: relay established
WGWatcher->>Conn: onDisconnected event
Conn->>Conn: handleRelayDisconnectedLocked()
Conn->>WGWatcher: disableWgWatcherIfNeeded()
WGWatcher->>WGWatcher: Set enabled = false
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|



Describe your changes
Extend the WireGuard watcher to monitor handshakes over ICE and relayed connections as well.
Issue ticket number and link
Stack
Checklist
Documentation
Select exactly one:
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
https://github.com/netbirdio/docs/pull/__
Summary by CodeRabbit
Bug Fixes
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.