Commit 5b500d5
fix(transport): dual-route key-exchange for dual-NAT convergence
When two peers are both behind NAT (e.g. Mac home-NAT ↔ GCP VM stateful
conntrack), the direct PILA key-exchange frame never lands, and the
tunnel only reconverges after slow blackhole detection flips the peer to
relay mode — measured 28s–3min on the canonical Mac↔VM rig, far longer
than the dial/send timeouts, so send-file/send-message time out and the
crypto state desyncs.
sendKeyExchangeToNode now ALSO pushes the key-exchange via the beacon
relay whenever the peer is not yet relay-flagged and a beacon is
available. The relay copy converges in ~1 RTT. It is a no-op once the
peer is relay-flagged (the primary send already went via relay), and
relayProbeLoop keeps probing direct so a genuine direct path still
upgrades the peer out of relay. Best-effort: a failed relay copy falls
back to the existing slow path.
Adds routing.SendRelayFrame (forced-relay send primitive, ignores the
per-peer relay flag and blackhole heuristic) and the ClearRekeyGaveUp /
ClearLastRekeyReq rekey-state shims.
Verified on the canonical Mac↔VM dual-NAT rig:
- G2 liveness: idle 5min (and 90min) then small msg arrives, no reset.
- Small msg ACK in ~0.42s (was 28s–3min).
- 64KB send-file byte-perfect (sha256 match), incl. from a cold daemon
restart (fresh in-memory peer table) — tunnel re-converges in ~12s.
- No regressions: 0 panics, 0 relay-copy failures on either end.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 82649a7 commit 5b500d5
2 files changed
Lines changed: 76 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
410 | 429 | | |
411 | 430 | | |
412 | 431 | | |
| |||
1419 | 1438 | | |
1420 | 1439 | | |
1421 | 1440 | | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
1422 | 1468 | | |
1423 | 1469 | | |
1424 | 1470 | | |
| |||
0 commit comments