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
+6
View File
@@ -43,6 +43,12 @@ periodic **traffic reset** schedule: `never` (default), `hourly`, `daily`,
For `monthly` resets, select a day from 1 to 31. If the selected day does not
exist in a shorter month, the reset runs on that month's last day.
Enable **Keep client usage** to reset only the inbound's counters on its schedule.
Clients keep their accumulated usage until their own reset. With the switch off,
the schedule also resets the attached clients' usage, including their usage on
other inbounds. Upgrade the master and the nodes hosting the inbound before
enabling this option on a managed inbound.
</Step>
</Steps>
+4
View File
@@ -40,6 +40,10 @@ icon: ArrowDownToLine
选择 `monthly` 时,可以指定每月 1 至 31 日重置。如果当月没有指定日期,
则在该月最后一天重置。
开启**保留客户端用量**后,定时任务仅清零入站计数,客户端继续按自己的周期累计用量。
关闭时,定时任务也会清零关联客户端在所有入站上的累计用量。
为纳管入站开启此选项前,请先升级主面板及承载该入站的节点。
</Step>
</Steps>
+7
View File
@@ -3254,6 +3254,11 @@
"minimum": 0,
"type": "integer"
},
"preserveClientTraffic": {
"description": "Older snapshots omit this field.\nKeep client usage during scheduled inbound resets",
"nullable": true,
"type": "boolean"
},
"protocol": {
"enum": [
"vmess",
@@ -5421,6 +5426,7 @@
"nodeId": null,
"originNodeGuid": "",
"port": 443,
"preserveClientTraffic": null,
"protocol": "vless",
"remark": "VLESS-443",
"settings": null,
@@ -16993,6 +16999,7 @@
"nodeId": null,
"originNodeGuid": "",
"port": 443,
"preserveClientTraffic": null,
"protocol": "vless",
"remark": "VLESS-443",
"settings": null,