[client] tie DNS warm-up dial to engine context; fix codespell

This commit is contained in:
mlsmaycon
2026-07-15 22:17:57 +02:00
parent 82d8f0a4ee
commit 38b377f21e
3 changed files with 11 additions and 4 deletions
+9 -3
View File
@@ -20,11 +20,17 @@ type dnsPeerActivator struct {
peerStore *peerstore.Store
status *peer.Status
mu *sync.Mutex
// ctx is the engine's long-lived context. The connection dial is tied to it
// (not the per-query DNS wait budget) so a handshake that outlasts the wait
// still completes in the background rather than being cancelled at the deadline.
ctx context.Context
}
// ActivatePeersByIP triggers wake-up for the peer(s) owning ips and waits until
// one is connected or ctx expires. Unknown or already-connected IPs are skipped,
// so the steady-state (warm) path adds no latency.
// one is connected or ctx (the per-query DNS wait budget) expires. Activation
// itself is tied to the engine's long-lived context so the dial survives a wait
// that times out. Unknown or already-connected IPs are skipped, so the
// steady-state (warm) path adds no latency.
func (a *dnsPeerActivator) ActivatePeersByIP(ctx context.Context, ips []string) {
if a == nil || a.connMgr == nil {
return
@@ -41,7 +47,7 @@ func (a *dnsPeerActivator) ActivatePeersByIP(ctx context.Context, ips []string)
if !ok {
continue
}
a.connMgr.ActivatePeer(ctx, conn)
a.connMgr.ActivatePeer(a.ctx, conn)
pending = append(pending, ip)
}
a.mu.Unlock()
+1
View File
@@ -663,6 +663,7 @@ func (e *Engine) Start(netbirdConfig *mgmProto.NetbirdConfig, mgmtURL *url.URL)
peerStore: e.peerStore,
status: e.statusRecorder,
mu: e.syncMsgMux,
ctx: e.ctx,
})
}