mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5497] [Feature]: Add individual auto-reset cycles for each client #3837
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#3837
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?
Originally created by @ruoyunfu on GitHub (Jun 22, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5497
Is your feature request related to a problem?
I'm currently managing multiple clients with different traffic plans. While 3X-UI supports periodic traffic reset at the inbound level, it resets traffic for all clients in that inbound simultaneously.
For example:
Currently, I have to manually click the "Reset Traffic" button for each client, which is inefficient and error‑prone.
Describe the solution you'd like
I would like to see a feature that allows each client to have its own independent auto‑reset cycle. This could be implemented by adding the following options in the "Edit Client" interface:
Daily,Weekly,Monthly, orCustom (Cron Expression).Weeklyis selected, an additional option to choose the day of the week (e.g., Monday, Sunday).Monthlyis selected, an option to choose the day of the month (e.g., 1st, 15th).Customis selected, a text field for a Cron expression (e.g.,0 0 5 * *for the 5th of each month).Reset to the original limitorReset to a custom value(in GB).Totaltraffic should be restored to the specified value, regardless of how much was used in the previous cycle.On the backend side, each client record should store the reset settings (e.g.,
reset_enabled,reset_period,reset_cron,reset_quota). A new scheduled job (or an extension of the existingPeriodicTrafficResetJob) should check each client’s individual settings and apply the reset accordingly.The current inbound‑level reset is a good start, but it does not support clients with varying billing cycles. This feature would greatly improve management efficiency for those of us handling many clients with diverse plans. Thank you for considering this request!
Alternatives you've considered
No response
Concrete use case
No response
Mockups, screenshots, or examples
No response
Which parts of the panel would this affect?
No response
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Jun 22, 2026):
This is a valid feature request with no exact duplicate in the issue tracker. The closest prior issue (#5285) was a generic question that was closed without any implementation.
What currently exists
Traffic reset is implemented at the inbound level only. The
Inboundmodel (internal/database/model/model.go:56) has atrafficResetfield that acceptsnever | hourly | daily | weekly | monthly. Four instances ofPeriodicTrafficResetJobare registered ininternal/web/web.go:345-351(at@hourly,@daily,@weekly,@monthly). When a job fires,PeriodicTrafficResetJob.Run()(internal/web/job/periodic_traffic_reset_job.go:26) fetches all inbounds whosetrafficResetmatches the period and callsResetAllClientTrafficsfor each — resetting every client in that inbound simultaneously.What the existing client
Resetfield does (not the same thing)The
ClientandClientRecordmodels each carry aReset intfield (model.go:606/628, comment: "Reset period in days"). This is not a periodic traffic-reset cycle. It drivesautoRenewClients(internal/web/service/inbound_traffic.go:285): when a client's traffic quota or expiry is reached, the expiry time is extended byReset * 86 400 000 ms(i.e., N days) and the Up/Down counters are zeroed as a side effect of the renewal — see line 374. This is expiry auto-renewal, not a calendar-scheduled traffic reset.What the feature request requires
There is currently no mechanism to reset a client's traffic counter on a per-client schedule independently of the inbound's own cycle. Implementing what you describe would require at minimum:
clients/ClientRecord(e.g.,client_traffic_resetstring using the samenever|hourly|daily|weekly|monthlyvocabulary, or a freeform cron expression, pluslast_client_traffic_reset_time int64) with a database migration.ClientJSON struct and onxray.ClientTrafficso the value is propagated through the existing traffic-accounting layer.PeriodicTrafficResetJob(or a new job) to also queryClientRecordrows whoseclient_traffic_resetmatches the current period, then callResetClientTrafficper matched client — independently of the inbound-level reset.ClientFormSchemainfrontend/src/schemas/client.tsand the corresponding React form component) to expose the new per-client cycle selector.The "traffic quota after reset" variant (restoring
totalGBto a specific value rather than the original limit) would additionally require storing that override value and plumbing it throughResetClientTraffic/UpdateClientStat.This request is noted as a valid enhancement. Implementation scope is non-trivial (schema migration, backend job logic, frontend form, and multi-node propagation considerations). A PR is welcome — see the contributing guidelines.
This reply was generated automatically; a maintainer may follow up.
@lthcode commented on GitHub (Jul 14, 2026):
Great feature!