mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6833] [MERGED] fix(traffic): re-enable quota-disabled clients on inbound and reset-all resets #6471
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#6471
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/6833
Author: @jayhemnani9910
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @MHSanaei
Base:
main← Head:fix/periodic-reset-reenable-clients📝 Commits (1)
290a5e7fix(traffic): re-enable quota-disabled clients on inbound and reset-all resets📊 Changes
7 files changed (+145 additions, -23 deletions)
View changed files
📝
internal/web/job/periodic_traffic_reset_client_test.go(+46 -1)📝
internal/web/job/periodic_traffic_reset_job.go(+4 -1)📝
internal/web/service/client_bulk_reset_reenable_test.go(+21 -0)📝
internal/web/service/client_crud.go(+31 -3)📝
internal/web/service/client_traffic.go(+37 -14)📝
internal/web/service/mtproto_quota_reset_test.go(+2 -2)📝
internal/web/service/node_reset_undelivered_test.go(+4 -2)📄 Description
Summary
When a client runs out of quota, the inbound's periodic traffic reset and the Reset All Client Traffic button zero its usage but leave it switched off. This makes both paths re-enable the clients their quota switched off, the same way the per-client reset, bulk reset and the client's own reset cycle already do.
Why
Running out of quota switches a client off in three places:
client_traffics.enable, the clients record (internal/web/service/inbound_disable.go:173) and the inbound settings JSON (inbound_disable.go:135).GetXrayConfigskips any client whose record is off (internal/web/service/xray.go:246).ResetAllClientTraffics(used by the inbound's periodic reset,internal/web/job/periodic_traffic_reset_job.go:116) andResetAllTraffics(the Reset All Client Traffic button) only setclient_traffics.enableback to true (internal/web/service/client_traffic.go:177and:222). The record and the settings JSON stay disabled. The client page then shows 0 usage, but the client is out of the running core until someone enables it by hand, every period.Refs #4396: the same symptom on 3.0.2 with a daily inbound reset. It was closed after the reporter switched to expiry plus Auto Renew as a workaround, and it still reproduces on v3.10.2.
TestResetAllTrafficsReenablesDepletedClientsalready says a depleted client "must be re-enabled after Reset All Client Traffic, matching every other reset path", but it only checksclient_traffics.The fix reads which disabled clients had used up their quota inside the transaction that zeroes the counters, then switches those back on with
BulkSetEnableafter it commits.ResetAllClientTrafficsnow returnsneedRestartfor the job. A client that is off while under its quota was disabled by hand and stays off. That is the same rule the client's own reset cycle uses (periodic_traffic_reset_job.go:154).Type of change
Areas affected
How was this tested?
TestPeriodicTrafficResetInboundRestoresClients(internal/web/job): a depleted client on an inbound with a daily reset comes back on in all three places; a client disabled by hand stays off.TestResetAllTraffics_ReenablesDepletedClientEverywhere(internal/web/service): same two cases for Reset All Client Traffic.clients.enable still false after the inbound's reset,client_records.enable = false, want true). With the fix they pass.go test -shuffle=on -count=1 ./...: 50 packages ok, same as on main. golangci-lint on the two changed packages: 0 issues.hourly, one client with a 30 KB limit.never, one client with a 30 KB limit and its ownhourlyreset.Breaking changes
None.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass. (no frontend changes)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.