mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6962] [MERGED] fix(traffic): restore quota-disabled inbounds when their traffic is reset #6545
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#6545
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?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6962
Author: @muditagrawal2007
Created: 10/26/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @MHSanaei
Base:
main← Head:fix/inbound-reset-restores-quota-disabled-inbounds📝 Commits (3)
af66e5efix(traffic): restore quota-disabled inbounds when their traffic is resetcb84245Merge remote-tracking branch 'origin/main' into pr/69626af63b3style(traffic): keep the inbound reset comments to two lines📊 Changes
9 files changed (+184 additions, -38 deletions)
View changed files
📝
internal/web/controller/inbound.go(+6 -4)📝
internal/web/job/periodic_traffic_reset_job.go(+3 -19)📝
internal/web/service/api_scale_postgres_test.go(+2 -2)📝
internal/web/service/inbound_disable.go(+24 -0)📝
internal/web/service/inbound_traffic.go(+43 -10)➕
internal/web/service/inbound_traffic_restore_test.go(+103 -0)📝
internal/web/service/mtproto_quota_reset_test.go(+1 -1)📝
internal/web/service/node_admin_fanout_test.go(+1 -1)📝
internal/web/service/reset_writer_test.go(+1 -1)📄 Description
The bug
An inbound with a traffic cap is switched off by
disableInvalidInboundsonceup + down >= total, and it is dropped from the running core — every client on it goes down with it.The periodic reset brought such an inbound back: after zeroing its counters it re-enabled it (
SetInboundEnable). The admin reset endpoints did not:POST /panel/api/inbounds/:id/resetTrafficPOST /panel/api/inbounds/resetAllTrafficsThey only zeroed
up/downand leftenable = false. The inbound then stayed off permanently:inboundQuotaDisabledpredicate needsup + down >= total, which the reset had just made false;So an operator whose inbound hit its cap, and who clicked "Reset All Traffic" expecting service to resume, silently killed every client on that inbound for good.
The fix
The "a traffic cap switched this inbound off" predicate moves into the service layer (
internal/web/service/inbound_disable.go), next to thedisableInvalidInboundsit mirrors, and is applied by both reset paths:ResetInboundTrafficre-enables the inbound when its own cap was what switched it off;ResetAllTrafficsdoes the same for every inbound it just unblocked.Only a cap may bring an inbound back. Inbounds an operator switched off by hand and inbounds that expired stay off — the reset has nothing to do with either, and the periodic job already drew that line.
The periodic job loses its own copy of the predicate and relies on the service, so there is one definition of "quota-disabled" instead of two.
Both reset methods now report whether the running core still needs a restart, so a plain counter reset no longer restarts Xray for nothing — the re-enable patches the live core in place, and only a failed patch asks for a restart.
Tests
internal/web/service/inbound_traffic_restore_test.godrives the real code path against a temp DB and a local runtime:TestResetAllTrafficsRestoresQuotaDisabledInboundTestResetInboundTrafficRestoresQuotaDisabledInboundTestResetAllTrafficsLeavesHandDisabledAndExpiredInboundsOff— the guard that the fix does not bring back inbounds it should not.The first two fail on the unfixed tree with "an inbound whose traffic cap was lifted must be enabled again"; the third passes before and after, so it pins the boundary rather than the fix.
go test ./...,golangci-lint runandmake gen-checkare green.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
[PR #6962] fix(traffic): restore quota-disabled inbounds when their traffic is resetto [PR #6962] [MERGED] fix(traffic): restore quota-disabled inbounds when their traffic is reset