fix(settings): accept five-field crontab for report and LDAP schedules

The panel scheduler runs WithSeconds(), whose parser rejects a standard
five-field crontab such as "30 8 * * *". An admin who typed one into the
Telegram/Discord notify time or the LDAP sync schedule saved it without
error, AddJob then failed at startup, and the job silently never ran.

Admin-typed schedules now go through internal/util/cronspec, which takes
an optional seconds column plus the @descriptors and hands the scheduler
a parsed cron.Schedule. CheckValid rejects an unparseable schedule on
save, and a stored legacy value falls back to the job's default instead
of dropping the job.
This commit is contained in:
MHSanaei
2026-10-11 20:33:08 +02:00
parent 0466e8b0bd
commit b124af2a1b
7 changed files with 179 additions and 44 deletions
+14
View File
@@ -10,6 +10,7 @@ import (
"time"
"github.com/mhsanaei/3x-ui/v3/internal/util/common"
"github.com/mhsanaei/3x-ui/v3/internal/util/cronspec"
)
type Msg struct {
@@ -352,6 +353,19 @@ func (s *AllSetting) CheckValid() error {
s.SubClashPath += "/"
}
for _, sched := range []struct{ name, spec string }{
{"tgRunTime", s.TgRunTime},
{"discordRunTime", s.DiscordRunTime},
{"ldapSyncCron", s.LdapSyncCron},
} {
if strings.TrimSpace(sched.spec) == "" {
continue
}
if _, err := cronspec.Parse(sched.spec); err != nil {
return common.NewError(sched.name+":", err)
}
}
if err := checkIPOrCIDRList(s.TrustedProxyCIDRs, "trusted proxy CIDR is not valid:"); err != nil {
return err
}