fix(vpn): make the WireGuard peer key's prefix URL-safe

get_vpn_tunnels keyed a peer as wireguard-<iface>-<pubkey[:8]>. Base64
uses "/" and "+", and the key is used as a URL path segment; a "/"
breaks the route even percent-encoded. The prefix now maps "+" to "-"
and "/" to "_", as napalm-opnsense does (NAPALM/napalm-opnsense#32).
Affected peers change their key once.

Closes #43
This commit is contained in:
Christian Manivong committed 2026-11-01 21:45:42 +01:00
1 parent eaa08ae7e3
commit df4f4b0e4d
3 files changed
+33 -3

No files matched your search

+3 -3
View File
@@ -2112,8 +2112,8 @@ class LinuxDriver(
Falls back to interface-level data from ``ip link`` + ``/proc/net/dev``
when root access is unavailable.
Full data keyed by ``wireguard-<iface>-<pubkey[:8]>`` (one entry per peer).
Fallback keyed by ``wireguard-<iface>`` (one entry per WireGuard interface).
Full data keyed by ``wireguard-<iface>-<pubkey[:8]>``, one per peer, URL-safe
(``+`` → ``-``, ``/`` → ``_``); the fallback by ``wireguard-<iface>``, one per interface.
"""
import time as _time
@@ -2190,7 +2190,7 @@ class LinuxDriver(
local_port = listen_ports.get(iface, "")
local_ep = f":{local_port}" if local_port and local_port != "0" else ""
key = f"wireguard-{iface}-{pubkey[:8]}"
key = f"wireguard-{iface}-{pubkey[:8].replace('+', '-').replace('/', '_')}"
tunnels[key] = {
"type": "WireGuard",
"local_endpoint": local_ep,