fix: WireGuard peers keep their tunnel key when others come and go (#32) #33

Merged
christianmanivong merged 2 commits from fix/wireguard-stable-keys-32 into main 2026-10-27 09:06:56 +00:00
Owner

Fixes #32.

get_vpn_tunnels() keyed WireGuard peers with a running counter, so a peer added ahead of an existing one renumbered every peer after it, and whatever a consumer stores per key moved to another peer.

The key is now wireguard-{interface}-{first 8 chars of the public key}, as in napalm-linux, with the base64 made URL-safe (+ → -, / → _) because the key is used as a URL path segment. Two peers sharing the prefix get the whole key; a row without a public key keeps its position. IPsec and OpenVPN keys were already stable.

Every WireGuard key changes once with this change. netOrk carries its per-tunnel metadata and checks across (NetOrk/netork#1654), so that change has to be deployed before or together with this pin.

Checked read-only against a live OPNsense 26.7 firewall with four peers on three interfaces: four distinct keys, one of them with a / turned into _.

Fixes #32. `get_vpn_tunnels()` keyed WireGuard peers with a running counter, so a peer added ahead of an existing one renumbered every peer after it, and whatever a consumer stores per key moved to another peer. The key is now `wireguard-{interface}-{first 8 chars of the public key}`, as in napalm-linux, with the base64 made URL-safe (`+` → `-`, `/` → `_`) because the key is used as a URL path segment. Two peers sharing the prefix get the whole key; a row without a public key keeps its position. IPsec and OpenVPN keys were already stable. **Every WireGuard key changes once with this change.** netOrk carries its per-tunnel metadata and checks across (NetOrk/netork#1654), so that change has to be deployed before or together with this pin. Checked read-only against a live OPNsense 26.7 firewall with four peers on three interfaces: four distinct keys, one of them with a `/` turned into `_`.
christianmanivong added 1 commit 2026-10-27 08:21:06 +00:00
fix: WireGuard peers keep their tunnel key when others come and go (#32)
driver / lint (pull_request) Successful in 17s
driver / standard (pull_request) Failing after 17s
driver / test (3.10) (pull_request) Failing after 3s
driver / test (3.11) (pull_request) Failing after 6s
driver / types (pull_request) Successful in 1m2s
driver / lowest (pull_request) Successful in 59s
driver / test (3.13) (pull_request) Successful in 1m39s
driver / test (3.12) (pull_request) Successful in 1m42s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 1m11s
CI / driver (pull_request) Failing after 3m12s
driver / publish (pull_request) Skipped
9f45952605
get_vpn_tunnels() keyed WireGuard peers with a running counter over the
peer rows, so a peer added ahead of an existing one renumbered every peer
after it. Whatever a consumer stores per key moved with it: netOrk's site
link and tunnel check ended up on a new, offline peer and alarmed while the
real tunnel was up.

The key is now the interface and the start of the public key, as in
napalm-linux, made URL-safe because the key is a path segment. Two peers
sharing the prefix get the whole key; a row without a public key keeps its
position. IPsec and OpenVPN keys were already stable.

Every WireGuard key changes once; netOrk carries its
per-tunnel metadata across (netork#1654).
christianmanivong added 1 commit 2026-10-27 09:03:30 +00:00
refactor: WireGuard tunnels are read in their own module (#32)
driver / lint (pull_request) Successful in 13s
driver / standard (pull_request) Successful in 14s
driver / test (3.10) (pull_request) Failing after 6s
driver / types (pull_request) Successful in 1m2s
driver / test (3.11) (pull_request) Successful in 1m5s
driver / test (3.12) (pull_request) Successful in 1m5s
driver / lowest (pull_request) Successful in 33s
driver / test (3.13) (pull_request) Successful in 59s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 1m1s
CI / driver (pull_request) Failing after 2m25s
driver / publish (pull_request) Skipped
eaafa540e5
get_vpn_tunnels() grew past the quality baseline with the key fix. The
WireGuard part is pure parsing of /api/wireguard/service/show, like the
listen ports in listening.py, so it moves to wireguard.py and the driver
calls it. opnsense.py shrinks from 3125 to 3082 lines.
christianmanivong merged commit 9115628abe into main 2026-10-27 09:06:56 +00:00
christianmanivong deleted branch fix/wireguard-stable-keys-32 2026-10-27 09:06:56 +00:00
Sign in to join this conversation.