Commit Graph

3 Commits

Author SHA1 Message Date
Sanaei 3f2a2195a8 fix(wireguard): apply a peer change pushed to a node at once
The previous commit applied a device write at once, but only on the panel
that received the request. A node takes the same change as an inbound update
from its master, and that path still flagged the 30 s reconcile: a device
disabled on the master kept its tunnel on the node until the node's next tick.

ReconcileNow is the one place both paths go through. It applies when the core
runs and only flags when it is down, so a device write never starts a core the
tick has not started.

Measured with a real master and node panel (Xray 26.11.9, kernel WireGuard
clients): a device disabled on the master is cut on the node after 5 s instead
of 11-30 s, and a new one connects 7 s after it is added. No unit test reaches
it, a test process is never running; the scenario is the proof.
2026-11-25 00:13:21 +03:30
Sanaei c1cf280055 fix(wireguard): apply a device change at once
A device write only flagged the next reconcile, which runs every 30 s. Until
then a disabled or deleted device kept its tunnel, and a new one could not
connect: 12-24 s measured on a running panel, under 1 s now.

The handler applies the change through the same non-forced path the reconcile
uses, and falls back to the flag when that fails. No unit test reaches it: the
controller tests run without a core. The Docker timeline shows it (toggle a
device, read `wg show` on the client and the peer list of the core).
2026-11-24 23:52:09 +03:30
Artem K f25cecfb40 feat(wireguard): support multiple devices per client (#7143)
A WireGuard client had one key pair and one tunnel address, so an operator who gave the same config to a phone and a laptop saw the two fight over the peer endpoint.

One client can now own extra devices, up to a per-client limit: each has its own keys and address, shares the client's quota, expiry and switch, and gets its own config, QR code and subscription. Devices become extra peers under the client's email, built by the same core-user map the other paths use, and a device change is applied to the running inbound in place instead of rebuilding it.

Nodes advertise a wg-devices capability; the master refuses a device for a node that would ignore it, before storing it and again when pushing the inbound.
2026-11-24 22:16:16 +03:30