mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5100] Resetting an inbound's traffic on the master does not propagate to slave nodes (reverts after sync) #3585
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3585
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @yukh975 on GitHub (Jun 8, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5100
Version
3.2.8 (also present on current
main, commit0d7b6872)Describe the bug
When you reset traffic for a node-owned inbound from the master panel
(the inbound's "Reset Traffic", or "Reset All Traffics"), the master DB is zeroed
and the UI shows
0for a moment — but the slave node's counters are neverreset. On the next node sync the master's value is overwritten back to the real
(non-reset) traffic, so after a page refresh the traffic reappears.
Workaround: log in to each node's own panel and reset the traffic there.
To Reproduce
appears in the master's Inbounds list with its traffic.
All Traffics).
0briefly.previous value.
Expected behavior
Resetting a node-owned inbound's traffic from the master should also reset it on
the slave node — the same way the per-client traffic reset already does — so
the value stays at
0after the next sync.Root cause (pointers)
The inbound-level reset only updates the master DB; it does not propagate to
the node, so the next node sync re-imports the slave's (still non-zero) traffic:
InboundService.ResetInboundTraffic(web/service/inbound.go) — does onlydb.Model(model.Inbound{}).Where("id = ?", id).Updates({"up":0,"down":0}).InboundService.resetAllTrafficsLocked(web/service/inbound.go) — same,DB-only.
By contrast, the client reset path does propagate to the node:
InboundService.resetClientTrafficLockedcallss.nodePushPlan(inbound)andlogs
"ResetClientTraffic: remote propagation to <node> failed"on error.Suggested fix
Mirror the client path in
ResetInboundTraffic/resetAllTrafficsLocked: fornode-owned inbounds (
NodeID != 0) forward the reset to the slave via the samenodePushPlan/ remote mechanism, so the node zeroes its own counters and thenext sync no longer restores the old values.
@github-actions[bot] commented on GitHub (Jun 8, 2026):
Confirmed bug — root cause and fix path
Your analysis is spot-on. I verified the code on
main(0d7b687).What the code actually does
InboundService.ResetInboundTraffic(web/service/inbound.go:3017):Pure DB write on the master. No node propagation at all.
resetAllTrafficsLocked(web/service/inbound.go:3000): same — bulk DB update only, no node propagation.resetClientTrafficLocked(web/service/inbound.go:2981), by contrast, does this after the DB write:Why the fix is straightforward
The
Runtimeinterface (web/runtime/runtime.go:28) already definesResetClientTrafficandResetAllTraffics. The remote implementation (web/runtime/remote.go:391) calls the slave's REST API:ResetClientTraffic→POST panel/api/clients/resetTraffic/<email>ResetAllTraffics→POST panel/api/inbounds/resetAllTrafficsCritically, the slave panel already exposes a per-inbound reset endpoint:
So the necessary pieces already exist on both ends; the master just never calls the slave.
Scope of the bug
The same missing propagation also affects the periodic traffic reset job (
web/job/periodic_traffic_reset_job.go:41) — inbounds with a configured reset period that belong to a node will silently revert on the next sync as well.Fix outline
ResetInboundTraffic(ctx context.Context, ib *model.Inbound) errorto theRuntimeinterface inweb/runtime/runtime.go.web/runtime/remote.goas a call toPOST panel/api/inbounds/<ib.Id>/resetTraffic(same pattern as the existingResetClientTraffic).web/runtime/local.go(like the existingResetAllTrafficsstub there).InboundService.ResetInboundTraffic(web/service/inbound.go:3017): after the DB write, load the inbound, checkNodeID \!= nil, get the runtime vias.runtimeFor(inbound), and callrt.ResetInboundTraffic(...).resetAllTrafficsLocked(web/service/inbound.go:3000): iterate over node-owned inbounds and callrt.ResetInboundTraffic(...)per node — or callrt.ResetAllTraffics(ctx)once per distinct node to batch it.PRs are welcome if you'd like to contribute the fix!
@rqzbeh commented on GitHub (Jun 8, 2026):
Fixed in:
https://github.com/MHSanaei/3x-ui/pull/5103