A client's devices all carry the client's email, and the core removes a
WireGuard user by email, one peer at a time. The hot diff therefore removed
every peer of the email and added the survivors back, and a client that left
for good counted as a user whose sessions had to be dropped.
Measured on a running panel (Xray 26.11.9, kernel WireGuard clients):
- disabling or deleting one device cut the client's other devices for about
15 s, the time a client waits before it handshakes again with a peer the
server forgot;
- disabling or deleting a connected WireGuard client restarted the whole core
with the default restartXrayOnClientDisable, taking every inbound down.
The diff is now per public key: a peer that stays is never touched, a changed
peer is updated in place, and a removed one goes through RemoveWireguardPeer,
which relabels that single peer and removes the label. A WireGuard session
ends with its peer, so its removal no longer asks for the restart.
After the change the other devices and other clients of the inbound keep
their tunnels with no gap, and the core keeps its pid.
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.