[PR #6071] [MERGED] inbounds: allow custom monthly traffic reset days #6070

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6071
Author: @Ki-Seki
Created: 7/22/2026
Status: ✅ Merged
Merged: 7/28/2026
Merged by: @MHSanaei

Base: main ← Head: feat/monthly-traffic-reset-day


📝 Commits (3)

  • 1b2b457 inbounds: allow custom monthly traffic reset days
  • 95806b6 Merge branch 'main' into feat/monthly-traffic-reset-day
  • 32609da Merge branch 'main' into feat/monthly-traffic-reset-day

📊 Changes

37 files changed (+179 additions, -16 deletions)

View changed files

📝 docs/architecture.md (+2 -2)
📝 docs/content/docs/en/config/inbounds.mdx (+3 -0)
📝 docs/content/docs/fa/config/inbounds.mdx (+3 -0)
📝 docs/content/docs/ru/config/inbounds.mdx (+3 -0)
📝 docs/content/docs/zh/config/inbounds.mdx (+3 -0)
📝 frontend/public/openapi.json (+9 -0)
📝 frontend/src/generated/examples.ts (+1 -0)
📝 frontend/src/generated/schemas.ts (+8 -0)
📝 frontend/src/generated/types.ts (+1 -0)
📝 frontend/src/generated/zod.ts (+1 -0)
📝 frontend/src/lib/xray/inbound-form-adapter.ts (+4 -0)
📝 frontend/src/models/dbinbound.ts (+3 -0)
📝 frontend/src/pages/inbounds/form/InboundFormModal.tsx (+12 -0)
📝 frontend/src/schemas/forms/inbound-form.ts (+1 -0)
📝 frontend/src/test/inbound-form-adapter.test.ts (+7 -0)
📝 internal/database/model/model.go (+1 -0)
📝 internal/web/job/periodic_traffic_reset_job.go (+24 -3)
➕ internal/web/job/periodic_traffic_reset_job_test.go (+31 -0)
📝 internal/web/runtime/remote.go (+3 -0)
📝 internal/web/runtime/remote_test.go (+6 -3)

...and 17 more files

📄 Description

Summary

Adds a configurable reset day (1–31) for monthly inbound traffic resets. Monthly jobs now check each panel-local midnight and reset only inbounds due that day; shorter months fall back to their final day.

The setting is supported by the panel form, API/OpenAPI schema, generated TypeScript types, multi-node synchronization, all UI locales, and user/architecture documentation. Existing inbounds and older API/node payloads continue to default to day 1.

Why

Monthly traffic quotas often follow billing dates other than the first day of the calendar month. This lets an inbound reset on dates such as the 15th without changing the existing hourly, daily, or weekly behavior.

Refs #3462.

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?

  • go test ./...
  • go build ./...
  • npm run typecheck
  • npm run lint
  • npm run test (96 files, 885 tests)
  • npm run build
  • npm run build-storybook
  • Opened Inbounds → Add Inbound in Chromium, selected Monthly, and entered day 15.
  • Added unit coverage for day 1 compatibility, configured dates, 31-day month ends, February fallback, and leap years.
  • Added adapter/runtime coverage for API and multi-node round trips.

Screenshots / recordings

Monthly reset day field

Breaking changes

None. The database column defaults to 1, and missing or zero values from older clients/nodes are normalized to day 1.

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.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • 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/6071 **Author:** [@Ki-Seki](https://github.com/Ki-Seki) **Created:** 7/22/2026 **Status:** ✅ Merged **Merged:** 7/28/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feat/monthly-traffic-reset-day` --- ### 📝 Commits (3) - [`1b2b457`](https://github.com/MHSanaei/3x-ui/commit/1b2b4571c5285d8a649acac7ccdf7f69832baaa3) inbounds: allow custom monthly traffic reset days - [`95806b6`](https://github.com/MHSanaei/3x-ui/commit/95806b680b00f6ec3519c7379d6d7ba7d1daee25) Merge branch 'main' into feat/monthly-traffic-reset-day - [`32609da`](https://github.com/MHSanaei/3x-ui/commit/32609da35c687f773d5eafd4f3b56d6021a48b54) Merge branch 'main' into feat/monthly-traffic-reset-day ### 📊 Changes **37 files changed** (+179 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `docs/architecture.md` (+2 -2) 📝 `docs/content/docs/en/config/inbounds.mdx` (+3 -0) 📝 `docs/content/docs/fa/config/inbounds.mdx` (+3 -0) 📝 `docs/content/docs/ru/config/inbounds.mdx` (+3 -0) 📝 `docs/content/docs/zh/config/inbounds.mdx` (+3 -0) 📝 `frontend/public/openapi.json` (+9 -0) 📝 `frontend/src/generated/examples.ts` (+1 -0) 📝 `frontend/src/generated/schemas.ts` (+8 -0) 📝 `frontend/src/generated/types.ts` (+1 -0) 📝 `frontend/src/generated/zod.ts` (+1 -0) 📝 `frontend/src/lib/xray/inbound-form-adapter.ts` (+4 -0) 📝 `frontend/src/models/dbinbound.ts` (+3 -0) 📝 `frontend/src/pages/inbounds/form/InboundFormModal.tsx` (+12 -0) 📝 `frontend/src/schemas/forms/inbound-form.ts` (+1 -0) 📝 `frontend/src/test/inbound-form-adapter.test.ts` (+7 -0) 📝 `internal/database/model/model.go` (+1 -0) 📝 `internal/web/job/periodic_traffic_reset_job.go` (+24 -3) ➕ `internal/web/job/periodic_traffic_reset_job_test.go` (+31 -0) 📝 `internal/web/runtime/remote.go` (+3 -0) 📝 `internal/web/runtime/remote_test.go` (+6 -3) _...and 17 more files_ </details> ### 📄 Description ## Summary Adds a configurable reset day (1–31) for monthly inbound traffic resets. Monthly jobs now check each panel-local midnight and reset only inbounds due that day; shorter months fall back to their final day. The setting is supported by the panel form, API/OpenAPI schema, generated TypeScript types, multi-node synchronization, all UI locales, and user/architecture documentation. Existing inbounds and older API/node payloads continue to default to day 1. ## Why Monthly traffic quotas often follow billing dates other than the first day of the calendar month. This lets an inbound reset on dates such as the 15th without changing the existing hourly, daily, or weekly behavior. Refs #3462. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Refactoring (no behavior change) - [x] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [x] Statistics / traffic counters - [x] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [x] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? - `go test ./...` - `go build ./...` - `npm run typecheck` - `npm run lint` - `npm run test` (96 files, 885 tests) - `npm run build` - `npm run build-storybook` - Opened Inbounds → Add Inbound in Chromium, selected Monthly, and entered day 15. - Added unit coverage for day 1 compatibility, configured dates, 31-day month ends, February fallback, and leap years. - Added adapter/runtime coverage for API and multi-node round trips. ## Screenshots / recordings ![Monthly reset day field](https://raw.githubusercontent.com/Ki-Seki/3x-ui/pr-assets/monthly-traffic-reset-day/.github/pr-screenshots/monthly-traffic-reset-day.png) ## Breaking changes None. The database column defaults to 1, and missing or zero values from older clients/nodes are normalized to day 1. ## 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. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [x] I updated the Wiki / README / API docs if user-facing behavior changed. - [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:06:09 +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#6070
No description provided.