feat(shell): 插件密码加密、失败熔断与客户端自动更新(v1.11.3)
- 插件配置中 format=password 字段改为 AES-256-GCM 密文落盘(本机密钥,历史明文自动迁移) - 同一插件连续失败 3 次自动禁用(仅统计进程启动后失败),升级自动解除 - 检测到新版本后台下载,空闲窗口提前提示并自动重启升级,设置页可配安全窗口
This commit is contained in:
@@ -269,6 +269,29 @@ function nextRunAt(s) {
|
||||
return nextMatch(cron, last || new Date());
|
||||
}
|
||||
|
||||
/** 未来 windowMs 内(含到点容差回看)是否有启用的定时任务到点;供壳子自动升级判断安全窗口 */
|
||||
function hasRunWithin(windowMs) {
|
||||
const now = Date.now();
|
||||
// 直接从 now-容差 起算,而不是走 nextRunAt(s):后者以 last_run_at 为锚点,
|
||||
// 壳子停机后重启、tick 尚未推进 last_run_at 时会算出过去的点,导致漏判下一到点。
|
||||
const from = new Date(now - CATCHUP_SKIP_MS);
|
||||
for (const s of _schedules) {
|
||||
if (!s.enabled) continue;
|
||||
let cron;
|
||||
try {
|
||||
cron = parseCron(s.cron || "");
|
||||
// 防御:分钟级历史任务本就不会触发,不计入安全窗口
|
||||
if (minGapMinutes(cron) < 60) continue;
|
||||
} catch (e) {
|
||||
continue;
|
||||
}
|
||||
const t = nextMatch(cron, from);
|
||||
if (!t) continue;
|
||||
if (t.getTime() - now <= windowMs) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function publicView(s) {
|
||||
const out = { ...s };
|
||||
out.enabled = !!out.enabled;
|
||||
@@ -548,6 +571,7 @@ module.exports = {
|
||||
deleteSchedule,
|
||||
toggleSchedule,
|
||||
nextRunAt,
|
||||
hasRunWithin,
|
||||
watchRun,
|
||||
pushBackup,
|
||||
restoreFromCloud,
|
||||
|
||||
Reference in New Issue
Block a user