fix(traffic): preserve client usage on scheduled inbound resets (#7136)

A client attached to several inbounds shares one usage counter. When any one of those inbounds reached its scheduled reset, the job zeroed the client's whole usage, across inbounds and nodes, although the client's own cycle resets on another day (#7135).

Add a per-inbound "Keep client usage" switch, off by default: with it on, the scheduled reset clears only the inbound's own counters. The setting is pushed to nodes and read back from their snapshots. A node that does not advertise the capability is refused when the switch is saved, not later at push time, so an older node never ends up with a config it cannot apply.
This commit is contained in:
dkgks
2026-11-24 21:02:13 +08:00
committed by GitHub
parent ccdda6f728
commit 5d76c0a1c6
41 changed files with 504 additions and 29 deletions
+3 -1
View File
@@ -26,8 +26,10 @@ const (
// CapAmneziaWGKernel marks a node that honours an AmneziaWG inbound's
// kernelMode; an older node drops the flag and serves it embedded.
CapAmneziaWGKernel = "awg-kernel"
// CapPreserveClientTraffic marks a node that supports inbound-only scheduled resets.
CapPreserveClientTraffic = "preserve-client-traffic"
// NodeCaps is the full CapsHeader value this build advertises.
NodeCaps = CapZstd + "," + CapAmneziaWGKernel
NodeCaps = CapZstd + "," + CapAmneziaWGKernel + "," + CapPreserveClientTraffic
// maxDecodeBytes bounds in-memory decompression to defuse a zstd bomb from
// an (authenticated) node-API caller.