mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6834] [MERGED] fix(traffic): re-enable a quota-disabled inbound on its periodic reset #6473
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#6473
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/6834
Author: @jayhemnani9910
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @alireza0
Base:
main← Head:fix/periodic-reset-reenable-inbound📝 Commits (1)
5994b10fix(traffic): re-enable a quota-disabled inbound on its periodic reset📊 Changes
2 files changed (+69 additions, -0 deletions)
View changed files
📝
internal/web/job/periodic_traffic_reset_job.go(+23 -0)📝
internal/web/job/periodic_traffic_reset_job_test.go(+46 -0)📄 Description
Summary
An inbound with its own total traffic limit is switched off when it uses that limit up. Its periodic traffic reset zeroes the counters but never switches it back on. This makes the periodic reset re-enable an inbound that its own limit switched off.
This changes behaviour: an inbound that used up its limit now comes back on at its next periodic reset. Today it stays off until someone enables it by hand. Details under Breaking changes.
Why
disableInvalidInboundssetsenable = falseon a local inbound onceup + down >= total(internal/web/service/inbound_disable.go:17-29). The periodic job callsResetInboundTraffic(internal/web/job/periodic_traffic_reset_job.go:92), which only writesup = 0, down = 0(internal/web/service/inbound_traffic.go:875). Nothing switches the inbound back on afterwards. So an inbound with, say, a monthly limit and a monthly reset stays off for good after the first month it runs out, and the reset schedule does nothing for it.The job now checks, before the reset, whether the inbound was off because of its own limit: local,
total > 0,up + down >= total, not expired. That is the same conditiondisableInvalidInboundsuses. If so, once the counters are zero it switches the inbound back on with the existingSetInboundEnable. An inbound that is off while under its limit was switched off by hand and stays off. So does an expired one. The manual per-inbound Reset Traffic button is not changed.Related: #6833 does the same for clients on these reset paths. This PR applies to
mainon its own and does not need #6833. Both editresetInboundsOnSchedule, so whichever lands second needs a small rebase.Type of change
Areas affected
How was this tested?
TestPeriodicTrafficResetReenablesQuotaDisabledInbound(internal/web/job) has three cases: off because of its own limit (re-enabled), off by hand under its limit (stays off), over its limit but expired (stays off). Without the fix the first case fails (inbound enable = false after its reset, want true). With the fix all three pass.go test -shuffle=on -count=1 ./...: 50 packages ok, same as on main. golangci-lint oninternal/web/job: 0 issues.total= 30 KB and traffic resethourly. I sent traffic through it with a local Xray client until the panel switched it off. After the 02:00 hourly run its usage was 0, but it was still disabled and connections failed.Breaking changes
No config, migration or API change, but behaviour changes: an inbound that used up its own traffic limit is now switched back on by its periodic reset. Before, it stayed off until someone enabled it by hand. An inbound switched off by hand while it is over its limit looks the same to the job and also comes back on at its reset. Inbounds with traffic reset
neverare not affected.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.