[PR #6834] [MERGED] fix(traffic): re-enable a quota-disabled inbound on its periodic reset #6473

Closed
opened 2026-11-02 04:09:01 +07:00 by bsakaguchi · 0 comments
Owner

📋 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)

  • 5994b10 fix(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

disableInvalidInbounds sets enable = false on a local inbound once up + down >= total (internal/web/service/inbound_disable.go:17-29). The periodic job calls ResetInboundTraffic (internal/web/job/periodic_traffic_reset_job.go:92), which only writes up = 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 condition disableInvalidInbounds uses. If so, once the counters are zero it switches the inbound back on with the existing SetInboundEnable. 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 main on its own and does not need #6833. Both edit resetInboundsOnSchedule, so whichever lands second needs a small rebase.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

  • New table test 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 on internal/web/job: 0 issues.
  • Manual check on the v3.10.2 release, panel and inbound on 127.0.0.1: VLESS TCP inbound with total = 30 KB and traffic reset hourly. 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.
  • With this branch, after the next hourly run the inbound was enabled again and a connection through it worked.

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 never are not affected.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass. (no frontend changes)
  • I updated the Wiki / README / API docs if user-facing behavior changed. (not needed)
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6834 **Author:** [@jayhemnani9910](https://github.com/jayhemnani9910) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@alireza0](https://github.com/alireza0) **Base:** `main` ← **Head:** `fix/periodic-reset-reenable-inbound` --- ### 📝 Commits (1) - [`5994b10`](https://github.com/MHSanaei/3x-ui/commit/5994b10f5dea80c6c2bcbe47512df21cc6fc3eb6) fix(traffic): re-enable a quota-disabled inbound on its periodic reset ### 📊 Changes **2 files changed** (+69 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/job/periodic_traffic_reset_job.go` (+23 -0) 📝 `internal/web/job/periodic_traffic_reset_job_test.go` (+46 -0) </details> ### 📄 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 `disableInvalidInbounds` sets `enable = false` on a local inbound once `up + down >= total` (`internal/web/service/inbound_disable.go:17-29`). The periodic job calls `ResetInboundTraffic` (`internal/web/job/periodic_traffic_reset_job.go:92`), which only writes `up = 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 condition `disableInvalidInbounds` uses. If so, once the counters are zero it switches the inbound back on with the existing `SetInboundEnable`. 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 `main` on its own and does not need #6833. Both edit `resetInboundsOnSchedule`, so whichever lands second needs a small rebase. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [ ] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [x] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? - New table test `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 on `internal/web/job`: 0 issues. - Manual check on the v3.10.2 release, panel and inbound on 127.0.0.1: VLESS TCP inbound with `total` = 30 KB and traffic reset `hourly`. 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. - With this branch, after the next hourly run the inbound was enabled again and a connection through it worked. ## 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 `never` are not affected. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. (no frontend changes) - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. (not needed) - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:09:01 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6473
No description provided.