inbounds: allow custom monthly traffic reset days (#6071)

This commit is contained in:
Shichao Song
2026-07-29 05:27:09 +08:00
committed by GitHub
parent 34d2591e50
commit 17e6b5a460
37 changed files with 179 additions and 16 deletions
+7 -7
View File
@@ -302,7 +302,7 @@ const (
// startTask schedules background jobs (Xray checks, traffic jobs, cron
// jobs) which the panel relies on for periodic maintenance and monitoring.
func (s *Server) startTask(restartXray bool) {
func (s *Server) startTask(restartXray bool, loc *time.Location) {
if restartXray {
err := s.xrayService.RestartXray(true)
if err != nil {
@@ -344,13 +344,13 @@ func (s *Server) startTask(restartXray bool) {
// Inbound traffic reset jobs
// Run every hour
_, _ = s.cron.AddJob("@hourly", job.NewPeriodicTrafficResetJob("hourly"))
_, _ = s.cron.AddJob("@hourly", job.NewPeriodicTrafficResetJob("hourly", loc))
// Run once a day, midnight
_, _ = s.cron.AddJob("@daily", job.NewPeriodicTrafficResetJob("daily"))
_, _ = s.cron.AddJob("@daily", job.NewPeriodicTrafficResetJob("daily", loc))
// Run once a week, midnight between Sat/Sun
_, _ = s.cron.AddJob("@weekly", job.NewPeriodicTrafficResetJob("weekly"))
// Run once a month, midnight, first of month
_, _ = s.cron.AddJob("@monthly", job.NewPeriodicTrafficResetJob("monthly"))
_, _ = s.cron.AddJob("@weekly", job.NewPeriodicTrafficResetJob("weekly", loc))
// Check monthly reset days at midnight
_, _ = s.cron.AddJob("@daily", job.NewPeriodicTrafficResetJob("monthly", loc))
// LDAP sync scheduling
if ldapEnabled, _ := s.settingService.GetLdapEnable(); ldapEnabled {
@@ -651,7 +651,7 @@ func (s *Server) start(restartXray bool, startTgBot bool) (err error) {
}
})
s.startTask(restartXray)
s.startTask(restartXray, loc)
if startTgBot {
isTgbotenabled, err := s.settingService.GetTgbotEnabled()