@whyour/qinglong 2.21.0 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +13 -0
- package/.env.example +7 -0
- package/AGENTS.md +2 -2
- package/README-en.md +24 -0
- package/README.md +24 -0
- package/back/protos/api.proto +9 -1
- package/back/protos/cron.proto +4 -1
- package/deploy/kubernetes/README.md +81 -0
- package/deploy/kubernetes/base/kustomization.yaml +5 -0
- package/deploy/kubernetes/base/qinglong.yaml +95 -0
- package/deploy/kubernetes/overlays/example/kustomization.yaml +10 -0
- package/docker/Dockerfile +31 -12
- package/docker/Dockerfile.310 +31 -12
- package/docker/Dockerfile.debian +22 -14
- package/docker/Dockerfile.debian310 +24 -14
- package/docker/build-manifest.cjs +28 -0
- package/docker/verify-build.cjs +49 -0
- package/docs/releases/2.22.0-validation.md +49 -0
- package/docs/releases/2.22.0.md +54 -0
- package/ecosystem.config.js +10 -1
- package/package.json +11 -6
- package/sample/config.sample.sh +17 -2
- package/sample/notify.js +118 -0
- package/sample/notify.py +93 -0
- package/scripts/benchmark-execution.cjs +96 -0
- package/scripts/write-build-info.cjs +27 -0
- package/shell/api.sh +41 -14
- package/shell/check.sh +59 -19
- package/shell/lang/en.sh +6 -0
- package/shell/lang/zh.sh +6 -0
- package/shell/node_path_cache.sh +128 -0
- package/shell/otask.sh +10 -1
- package/shell/preload/sitecustomize.js +5 -1
- package/shell/share.sh +26 -9
- package/shell/start.sh +6 -3
- package/shell/task.sh +13 -3
- package/shell/update.sh +65 -4
- package/static/build/api/clientIp.js +42 -0
- package/static/build/api/config.js +8 -16
- package/static/build/api/cron.js +39 -3
- package/static/build/api/dashboard.js +50 -6
- package/static/build/api/env.js +2 -2
- package/static/build/api/health.js +2 -2
- package/static/build/api/index.js +4 -0
- package/static/build/api/log.js +39 -19
- package/static/build/api/retention.js +63 -0
- package/static/build/api/script.js +23 -22
- package/static/build/api/subscription.js +16 -2
- package/static/build/api/system.js +31 -9
- package/static/build/api/user.js +75 -15
- package/static/build/app.js +63 -54
- package/static/build/bootstrap/database.js +51 -0
- package/static/build/config/const.js +2 -0
- package/static/build/config/grpcCerts.js +4 -4
- package/static/build/config/index.js +0 -4
- package/static/build/config/share.js +5 -4
- package/static/build/config/util.js +136 -41
- package/static/build/data/cron.js +1 -0
- package/static/build/data/notify.js +18 -1
- package/static/build/data/sock.js +1 -0
- package/static/build/loaders/app.js +8 -6
- package/static/build/loaders/db.js +5 -35
- package/static/build/loaders/deps.js +30 -22
- package/static/build/loaders/express.js +44 -32
- package/static/build/loaders/initData.js +10 -7
- package/static/build/loaders/initFile.js +1 -1
- package/static/build/loaders/initTask.js +3 -2
- package/static/build/loaders/server.js +1 -1
- package/static/build/loaders/sock.js +72 -6
- package/static/build/middlewares/monitoring.js +12 -33
- package/static/build/middlewares/protectedPathCase.js +17 -0
- package/static/build/protos/api.js +78 -2
- package/static/build/protos/cron.js +21 -4
- package/static/build/protos/health.js +1 -1
- package/static/build/schedule/addCron.js +76 -10
- package/static/build/schedule/api.js +5 -2
- package/static/build/schedule/client.js +38 -6
- package/static/build/schedule/delCron.js +11 -1
- package/static/build/schedule/health.js +72 -7
- package/static/build/services/config.js +5 -42
- package/static/build/services/cron.js +353 -164
- package/static/build/services/dependence.js +66 -18
- package/static/build/services/grpc.js +2 -2
- package/static/build/services/health.js +4 -7
- package/static/build/services/http.js +9 -3
- package/static/build/services/log.js +2 -3
- package/static/build/services/metrics.js +46 -14
- package/static/build/services/notify.js +73 -5
- package/static/build/services/retention.js +123 -0
- package/static/build/services/schedule.js +57 -33
- package/static/build/services/script.js +4 -5
- package/static/build/services/subscription.js +57 -34
- package/static/build/services/system.js +49 -11
- package/static/build/services/user.js +244 -31
- package/static/build/shared/auth.js +22 -3
- package/static/build/shared/authMutation.js +17 -0
- package/static/build/shared/childProcess.js +82 -0
- package/static/build/shared/clientIp.js +27 -0
- package/static/build/shared/errors.js +9 -0
- package/static/build/shared/fileAccess.js +60 -0
- package/static/build/shared/i18n.js +62 -4
- package/static/build/shared/logReader.js +85 -0
- package/static/build/shared/logStreamManager.js +80 -60
- package/static/build/shared/pLimit.js +3 -2
- package/static/build/shared/password.js +30 -0
- package/static/build/shared/retention.js +58 -0
- package/static/build/shared/runCron.js +28 -15
- package/static/build/shared/schedulerMutationLock.js +44 -0
- package/static/build/shared/schedulerReadiness.js +82 -0
- package/static/build/shared/schemaMigrations.js +58 -0
- package/static/build/shared/startupProcess.js +48 -0
- package/static/build/shared/store.js +7 -0
- package/static/build/shared/trustProxy.js +119 -0
- package/static/build/validation/schedule.js +12 -3
- package/static/dist/{1885.e1ea09f6.async.js → 1885.b8f427bf.async.js} +1 -1
- package/static/dist/2031.6af40025.async.js +1 -0
- package/static/dist/2693.51c2636b.async.js +1 -0
- package/static/dist/{2890.9e373f5b.async.js → 2890.add55e85.async.js} +1 -1
- package/static/dist/2901.2ca95295.async.js +1 -0
- package/static/dist/445.a65ff63b.async.js +1 -0
- package/static/dist/4736.1d2b5cb6.async.js +1 -0
- package/static/dist/{4859.6592cebb.async.js → 4859.97d6653c.async.js} +1 -1
- package/static/dist/{6013.4e38de36.async.js → 6013.db535339.async.js} +1 -1
- package/static/dist/6212.9e6d9913.async.js +1 -0
- package/static/dist/{6339.ab305e96.async.js → 6431.4603ad0e.async.js} +1 -1
- package/static/dist/{6872.42f939f1.async.js → 6872.a503ef55.async.js} +1 -1
- package/static/dist/7231.f7e5b668.async.js +1 -0
- package/static/dist/{7355.f9f263d8.async.js → 7355.fca746f5.async.js} +1 -1
- package/static/dist/{7508.7dcee91c.async.js → 7508.d90eac63.async.js} +1 -1
- package/static/dist/{7984.594296a5.async.js → 7984.eaac7402.async.js} +1 -1
- package/static/dist/8844.a0fef08e.async.js +1 -0
- package/static/dist/index.html +2 -2
- package/static/dist/layouts__index.633d3553.async.js +1 -0
- package/static/dist/preload_helper.cf7de3fa.js +1 -0
- package/static/dist/{src__pages__config__index.a22ff7dc.async.js → src__pages__config__index.9aba4054.async.js} +1 -1
- package/static/dist/src__pages__crontab__detail.86b2eebb.async.js +1 -0
- package/static/dist/src__pages__crontab__index.ae4e06f2.async.js +1 -0
- package/static/dist/{src__pages__crontab__logModal.0b8cce8c.async.js → src__pages__crontab__logModal.930535e2.async.js} +1 -1
- package/static/dist/src__pages__crontab__modal.a2c8fdcc.async.js +1 -0
- package/static/dist/src__pages__crontab__viewCreateModal.7b4f9cbe.async.js +1 -0
- package/static/dist/src__pages__crontab__viewManageModal.cd454ea0.async.js +1 -0
- package/static/dist/src__pages__dashboard__index.243c5a35.async.js +1 -0
- package/static/dist/src__pages__dashboard__taskResultModal.7795d6e1.async.js +1 -0
- package/static/dist/src__pages__dependence__index.874d501f.async.js +1 -0
- package/static/dist/src__pages__dependence__logModal.154efe7a.async.js +1 -0
- package/static/dist/src__pages__dependence__modal.a29c1a0f.async.js +1 -0
- package/static/dist/{src__pages__diff__index.013b7c75.async.js → src__pages__diff__index.1714b941.async.js} +1 -1
- package/static/dist/src__pages__env__editNameModal.c13d47d2.async.js +1 -0
- package/static/dist/src__pages__env__index.fd6fd2b0.async.js +1 -0
- package/static/dist/src__pages__env__modal.4d71adb3.async.js +1 -0
- package/static/dist/src__pages__error__index.aae50c94.async.js +1 -0
- package/static/dist/src__pages__initialization__index.82a2e967.async.js +1 -0
- package/static/dist/src__pages__log__index.71250e0d.async.js +1 -0
- package/static/dist/{src__pages__login__index.8c813eb1.async.js → src__pages__login__index.a0fd5ed8.async.js} +1 -1
- package/static/dist/src__pages__script__editModal.22acdf7c.async.js +1 -0
- package/static/dist/src__pages__script__editNameModal.1a521cc0.async.js +1 -0
- package/static/dist/src__pages__script__index.a18b2692.async.js +1 -0
- package/static/dist/src__pages__script__renameModal.0ab029e7.async.js +1 -0
- package/static/dist/src__pages__script__saveModal.8965b74c.async.js +1 -0
- package/static/dist/src__pages__script__setting.35ad4f02.async.js +1 -0
- package/static/dist/src__pages__setting__appModal.7eaeb9d3.async.js +1 -0
- package/static/dist/src__pages__setting__checkUpdate.d175b154.async.js +1 -0
- package/static/dist/src__pages__setting__clientIp.3a8711ed.async.js +1 -0
- package/static/dist/src__pages__setting__dependence.9c0f749b.async.js +1 -0
- package/static/dist/src__pages__setting__index.cb397741.async.js +1 -0
- package/static/dist/src__pages__setting__loginLog.e0a1f54d.async.js +1 -0
- package/static/dist/src__pages__setting__notification.2ffe4e5a.async.js +1 -0
- package/static/dist/src__pages__setting__other.3d0b8492.async.js +1 -0
- package/static/dist/{src__pages__setting__progress.8823ac90.async.js → src__pages__setting__progress.2ccae3d7.async.js} +1 -1
- package/static/dist/src__pages__setting__security.e2d71ebb.async.js +1 -0
- package/static/dist/src__pages__setting__systemLog.b3046955.async.js +1 -0
- package/static/dist/src__pages__subscription__index.43086a06.async.js +1 -0
- package/static/dist/src__pages__subscription__logModal.cdba5139.async.js +1 -0
- package/static/dist/src__pages__subscription__modal.38991e1e.async.js +1 -0
- package/static/dist/{umi.ca04a019.js → umi.fc019050.js} +1 -1
- package/test/back/auth-security.test.cjs +74 -0
- package/test/back/build-provenance.test.cjs +150 -0
- package/test/back/cron-log-name.test.cjs +110 -0
- package/test/back/cron-validation.test.cjs +45 -0
- package/test/back/dashboard-failures.test.cjs +173 -0
- package/test/back/database-bootstrap.test.cjs +193 -0
- package/test/back/dependence-cache-status.test.cjs +125 -0
- package/test/back/deprecated-file-routes.test.cjs +82 -0
- package/test/back/ecosystem.test.cjs +28 -0
- package/test/back/env-name-parsing.test.cjs +96 -0
- package/test/back/execution-lifecycle.test.cjs +236 -0
- package/test/back/file-access-security.test.cjs +47 -0
- package/test/back/fileTreeListing.test.cjs +57 -0
- package/test/back/grpc-cron-response.test.cjs +60 -0
- package/test/back/http-exclusive-listen.test.cjs +31 -0
- package/test/back/http-security.test.cjs +213 -0
- package/test/back/listen-security.test.cjs +67 -0
- package/test/back/log-path-security.test.cjs +158 -0
- package/test/back/logReader.test.cjs +72 -0
- package/test/back/manual-execution.test.cjs +85 -0
- package/test/back/manual-stop-claim.test.cjs +220 -0
- package/test/back/metrics.test.cjs +34 -0
- package/test/back/monitoring.test.cjs +73 -0
- package/test/back/node-path-cache.test.cjs +173 -0
- package/test/back/node-path-lock.test.cjs +178 -0
- package/test/back/npm-publication.test.cjs +70 -0
- package/test/back/primary-apm.test.cjs +24 -0
- package/test/back/process-exit-state.test.cjs +81 -0
- package/test/back/process-stop-signal.test.cjs +77 -0
- package/test/back/protected-path-case.test.cjs +58 -0
- package/test/back/qlServiceLogCommand.test.cjs +128 -0
- package/test/back/retention.test.cjs +131 -0
- package/test/back/role-loading.test.cjs +118 -0
- package/test/back/schedule-health.test.cjs +86 -0
- package/test/back/scheduler-file-lock.test.cjs +51 -0
- package/test/back/scheduler-mutation.test.cjs +312 -0
- package/test/back/scheduler-readiness.test.cjs +85 -0
- package/test/back/scheduler-reconciliation.test.cjs +152 -0
- package/test/back/scheduler-rpc-timeout.test.cjs +49 -0
- package/test/back/schema-migrations.test.cjs +127 -0
- package/test/back/shell-api-parsing.test.cjs +184 -0
- package/test/back/sock-polling.test.cjs +297 -0
- package/test/back/sock-security.test.cjs +72 -0
- package/test/back/start-env-preservation.test.cjs +53 -0
- package/test/back/stop-failure-feedback.test.cjs +158 -0
- package/test/back/stop-race.test.cjs +167 -0
- package/test/back/subscription-cleanup.test.cjs +53 -0
- package/test/back/subscription-stop-state.test.cjs +66 -0
- package/test/back/system-dependence-cache.test.cjs +126 -0
- package/test/back/task-time.test.cjs +116 -0
- package/test/back/user-api.test.cjs +99 -0
- package/test/back/user-security.test.cjs +248 -0
- package/test/back/worker-apm.test.cjs +84 -0
- package/test/back/wpush-grpc.test.cjs +115 -0
- package/test/front/cron-log-pagination.test.cjs +214 -0
- package/test/front/http-auth.test.cjs +152 -0
- package/test/front/http-error.test.cjs +29 -0
- package/test/helpers/load-security-module.cjs +42 -0
- package/version.yaml +19 -34
- package/CLAUDE.md +0 -43
- package/static/dist/1147.c420132e.async.js +0 -1
- package/static/dist/134.54df9e38.async.js +0 -1
- package/static/dist/2208.f7ba3dfa.async.js +0 -1
- package/static/dist/2286.164bb089.async.js +0 -1
- package/static/dist/3191.63263871.async.js +0 -1
- package/static/dist/4902.555f92ab.async.js +0 -1
- package/static/dist/5520.ff2cfd6b.async.js +0 -1
- package/static/dist/6431.c50479be.async.js +0 -1
- package/static/dist/8826.2447a104.async.js +0 -1
- package/static/dist/layouts__index.a7a2bfe0.async.js +0 -1
- package/static/dist/preload_helper.0431c0f3.js +0 -1
- package/static/dist/src__pages__crontab__detail.b9c36808.async.js +0 -1
- package/static/dist/src__pages__crontab__index.fed99fd0.async.js +0 -1
- package/static/dist/src__pages__crontab__modal.f7041c7c.async.js +0 -1
- package/static/dist/src__pages__crontab__viewCreateModal.4d589f66.async.js +0 -1
- package/static/dist/src__pages__crontab__viewManageModal.0e317746.async.js +0 -1
- package/static/dist/src__pages__dashboard__index.b30f2f47.async.js +0 -1
- package/static/dist/src__pages__dependence__index.3d87ceac.async.js +0 -1
- package/static/dist/src__pages__dependence__logModal.0681830b.async.js +0 -1
- package/static/dist/src__pages__dependence__modal.11124896.async.js +0 -1
- package/static/dist/src__pages__env__editNameModal.5d264b25.async.js +0 -1
- package/static/dist/src__pages__env__index.baa27d4e.async.js +0 -1
- package/static/dist/src__pages__env__modal.7f2ef1bc.async.js +0 -1
- package/static/dist/src__pages__error__index.f156b45e.async.js +0 -1
- package/static/dist/src__pages__initialization__index.e96d4ba8.async.js +0 -1
- package/static/dist/src__pages__log__index.e0978bae.async.js +0 -1
- package/static/dist/src__pages__script__editModal.cbf4ec0e.async.js +0 -1
- package/static/dist/src__pages__script__editNameModal.3e7e100d.async.js +0 -1
- package/static/dist/src__pages__script__index.2765d1b8.async.js +0 -1
- package/static/dist/src__pages__script__renameModal.5e987ef5.async.js +0 -1
- package/static/dist/src__pages__script__saveModal.3f9d23d6.async.js +0 -1
- package/static/dist/src__pages__script__setting.a535793a.async.js +0 -1
- package/static/dist/src__pages__setting__appModal.251cd14f.async.js +0 -1
- package/static/dist/src__pages__setting__checkUpdate.46efe057.async.js +0 -1
- package/static/dist/src__pages__setting__dependence.8a7a9529.async.js +0 -1
- package/static/dist/src__pages__setting__index.cc85fdfb.async.js +0 -1
- package/static/dist/src__pages__setting__loginLog.cea6056c.async.js +0 -1
- package/static/dist/src__pages__setting__notification.390fc905.async.js +0 -1
- package/static/dist/src__pages__setting__other.b22d2165.async.js +0 -1
- package/static/dist/src__pages__setting__security.598720a8.async.js +0 -1
- package/static/dist/src__pages__setting__systemLog.67406721.async.js +0 -1
- package/static/dist/src__pages__subscription__index.d0ab2abc.async.js +0 -1
- package/static/dist/src__pages__subscription__logModal.3864b37f.async.js +0 -1
- package/static/dist/src__pages__subscription__modal.3562c670.async.js +0 -1
|
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.updateLinuxMirrorFile = exports.detectOS = exports.isDemoEnv = exports.getUninstallCommand = exports.getInstallCommand = exports.getGetCommand = exports.setSystemTimezone = exports.rmPath = exports.safeJSONParse = exports.getUniqPath = exports.parseContentVersion = exports.parseVersion = exports.killAllTasks = exports.getAllPids = exports.getPid = exports.killTask = exports.psTree = exports.parseBody = exports.parseHeaders = exports.promiseExecSuccess = exports.promiseExec = exports.readDir = exports.readDirs = exports.dirSort = exports.concurrentRun = exports.handleLogPath = exports.createFile = exports.fileExist = exports.getPlatform = exports.getToken = exports.getLastModifyFilePath = exports.removeAnsi = exports.getFileContentByName = void 0;
|
|
32
|
+
exports.updateLinuxMirrorFile = exports.detectOS = exports.isDemoEnv = exports.getUninstallCommand = exports.getInstallCommand = exports.getGetCommand = exports.setSystemTimezone = exports.rmPath = exports.errStack = exports.safeJSONParse = exports.getUniqPath = exports.parseContentVersion = exports.parseVersion = exports.killAllTasks = exports.getAllPids = exports.getPid = exports.killTask = exports.psTree = exports.parseBody = exports.parseHeaders = exports.promiseExecSuccess = exports.promiseExec = exports.readDir = exports.readDirs = exports.dirSort = exports.concurrentRun = exports.handleLogPath = exports.createFile = exports.fileExist = exports.getPlatform = exports.getToken = exports.getLastModifyFilePath = exports.removeAnsi = exports.getFileContentByName = void 0;
|
|
33
33
|
const fs = __importStar(require("fs/promises"));
|
|
34
34
|
const path = __importStar(require("path"));
|
|
35
35
|
const child_process_1 = require("child_process");
|
|
@@ -44,6 +44,7 @@ const dependence_1 = require("../data/dependence");
|
|
|
44
44
|
const undici_1 = require("undici");
|
|
45
45
|
const os_1 = __importDefault(require("os"));
|
|
46
46
|
const container_1 = require("./container");
|
|
47
|
+
const fileAccess_1 = require("../shared/fileAccess");
|
|
47
48
|
__exportStar(require("./share"), exports);
|
|
48
49
|
let osType;
|
|
49
50
|
function getOsTypeSync() {
|
|
@@ -172,7 +173,9 @@ async function createFile(file, data = '') {
|
|
|
172
173
|
}
|
|
173
174
|
exports.createFile = createFile;
|
|
174
175
|
async function handleLogPath(logPath, data = '') {
|
|
175
|
-
const absolutePath =
|
|
176
|
+
const absolutePath = (0, fileAccess_1.resolveFileAccess)(index_1.default.logPath, [logPath]);
|
|
177
|
+
if (!absolutePath)
|
|
178
|
+
throw new Error('Log path is outside the log directory');
|
|
176
179
|
const logFileExist = await fileExist(absolutePath);
|
|
177
180
|
if (!logFileExist) {
|
|
178
181
|
await createFile(absolutePath, data);
|
|
@@ -226,40 +229,66 @@ function dirSort(a, b) {
|
|
|
226
229
|
}
|
|
227
230
|
}
|
|
228
231
|
exports.dirSort = dirSort;
|
|
229
|
-
|
|
232
|
+
const FILE_SYSTEM_READ_CONCURRENCY = 32;
|
|
233
|
+
function createFileSystemTaskRunner(concurrency) {
|
|
234
|
+
let activeCount = 0;
|
|
235
|
+
const queue = [];
|
|
236
|
+
const runNext = () => {
|
|
237
|
+
var _a;
|
|
238
|
+
while (activeCount < concurrency && queue.length > 0) {
|
|
239
|
+
activeCount += 1;
|
|
240
|
+
(_a = queue.shift()) === null || _a === void 0 ? void 0 : _a();
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
return (task) => new Promise((resolve, reject) => {
|
|
244
|
+
queue.push(() => {
|
|
245
|
+
task()
|
|
246
|
+
.then(resolve, reject)
|
|
247
|
+
.finally(() => {
|
|
248
|
+
activeCount -= 1;
|
|
249
|
+
runNext();
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
runNext();
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
async function readDirsWithRunner(dir, baseDir, blacklist, sort, runFileSystemTask) {
|
|
230
256
|
const relativePath = path.relative(baseDir, dir);
|
|
231
|
-
const
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
257
|
+
const entries = await runFileSystemTask(() => fs.readdir(dir, { withFileTypes: true }));
|
|
258
|
+
const items = await Promise.all(entries.map(async (entry) => {
|
|
259
|
+
if (blacklist.includes(entry.name) || entry.isSymbolicLink()) {
|
|
260
|
+
return undefined;
|
|
261
|
+
}
|
|
262
|
+
const subPath = path.join(dir, entry.name);
|
|
263
|
+
const stats = await runFileSystemTask(() => fs.lstat(subPath));
|
|
264
|
+
if (stats.isSymbolicLink()) {
|
|
265
|
+
return undefined;
|
|
239
266
|
}
|
|
267
|
+
const key = path.join(relativePath, entry.name);
|
|
240
268
|
if (stats.isDirectory()) {
|
|
241
|
-
const children = await
|
|
242
|
-
|
|
243
|
-
title:
|
|
269
|
+
const children = await readDirsWithRunner(subPath, baseDir, blacklist, sort, runFileSystemTask);
|
|
270
|
+
return {
|
|
271
|
+
title: entry.name,
|
|
244
272
|
key,
|
|
245
273
|
type: 'directory',
|
|
246
274
|
parent: relativePath,
|
|
247
275
|
createTime: stats.birthtime.getTime(),
|
|
248
|
-
children
|
|
249
|
-
}
|
|
276
|
+
children,
|
|
277
|
+
};
|
|
250
278
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
279
|
+
return {
|
|
280
|
+
title: entry.name,
|
|
281
|
+
type: 'file',
|
|
282
|
+
key,
|
|
283
|
+
parent: relativePath,
|
|
284
|
+
size: stats.size,
|
|
285
|
+
createTime: stats.birthtime.getTime(),
|
|
286
|
+
};
|
|
287
|
+
}));
|
|
288
|
+
return items.filter((item) => Boolean(item)).sort(sort);
|
|
289
|
+
}
|
|
290
|
+
async function readDirs(dir, baseDir = '', blacklist = [], sort = dirSort) {
|
|
291
|
+
return readDirsWithRunner(dir, baseDir, blacklist, sort, createFileSystemTaskRunner(FILE_SYSTEM_READ_CONCURRENCY));
|
|
263
292
|
}
|
|
264
293
|
exports.readDirs = readDirs;
|
|
265
294
|
async function readDir(dir, baseDir = '', blacklist = []) {
|
|
@@ -407,19 +436,83 @@ function psTree(pid) {
|
|
|
407
436
|
});
|
|
408
437
|
}
|
|
409
438
|
exports.psTree = psTree;
|
|
410
|
-
async function killTask(pid) {
|
|
411
|
-
const
|
|
412
|
-
|
|
439
|
+
async function killTask(pid, waitForExit = false) {
|
|
440
|
+
const descendants = await psTree(pid);
|
|
441
|
+
const signal = (target, sig) => {
|
|
413
442
|
try {
|
|
414
|
-
|
|
415
|
-
process.kill(x, 15);
|
|
416
|
-
});
|
|
443
|
+
process.kill(target, sig);
|
|
417
444
|
}
|
|
418
|
-
catch (error) {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
445
|
+
catch (error) {
|
|
446
|
+
if (error.code !== 'ESRCH')
|
|
447
|
+
throw error;
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
if (!waitForExit) {
|
|
451
|
+
if (descendants.length) {
|
|
452
|
+
// A child may exit after psTree; keep signalling the remaining tree.
|
|
453
|
+
for (const target of [pid, ...descendants].reverse()) {
|
|
454
|
+
signal(target, 'SIGTERM');
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
else
|
|
458
|
+
signal(pid, 'SIGINT');
|
|
459
|
+
return;
|
|
422
460
|
}
|
|
461
|
+
const pids = [...descendants.reverse(), pid];
|
|
462
|
+
for (const target of pids)
|
|
463
|
+
signal(target, 'SIGTERM');
|
|
464
|
+
const alive = async (target) => {
|
|
465
|
+
try {
|
|
466
|
+
process.kill(target, 0);
|
|
467
|
+
}
|
|
468
|
+
catch (error) {
|
|
469
|
+
if (error.code === 'ESRCH')
|
|
470
|
+
return false;
|
|
471
|
+
throw error;
|
|
472
|
+
}
|
|
473
|
+
if (process.platform === 'linux') {
|
|
474
|
+
try {
|
|
475
|
+
const stat = await fs.readFile(`/proc/${target}/stat`, 'utf8');
|
|
476
|
+
// The command field may contain spaces and parentheses. Zombies have
|
|
477
|
+
// exited even while their parent has not reaped the PID yet.
|
|
478
|
+
const state = stat.slice(stat.lastIndexOf(')') + 2).split(' ')[0];
|
|
479
|
+
if (['Z', 'X', 'x'].includes(state))
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
catch (_a) {
|
|
483
|
+
// /proc may be unavailable, or the process may have just exited.
|
|
484
|
+
// Retain the portable signal probe rather than assuming it is dead.
|
|
485
|
+
try {
|
|
486
|
+
process.kill(target, 0);
|
|
487
|
+
}
|
|
488
|
+
catch (error) {
|
|
489
|
+
if (error.code === 'ESRCH')
|
|
490
|
+
return false;
|
|
491
|
+
throw error;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return true;
|
|
496
|
+
};
|
|
497
|
+
const wait = async () => {
|
|
498
|
+
const deadline = Date.now() + 1000;
|
|
499
|
+
let remaining = pids;
|
|
500
|
+
while (true) {
|
|
501
|
+
const states = await Promise.all(remaining.map(alive));
|
|
502
|
+
remaining = remaining.filter((_, index) => states[index]);
|
|
503
|
+
if (!remaining.length || Date.now() >= deadline)
|
|
504
|
+
return remaining;
|
|
505
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
let remaining = await wait();
|
|
509
|
+
if (!remaining.length)
|
|
510
|
+
return;
|
|
511
|
+
for (const target of remaining)
|
|
512
|
+
signal(target, 'SIGKILL');
|
|
513
|
+
remaining = await wait();
|
|
514
|
+
if (remaining.length)
|
|
515
|
+
throw new Error(`Task processes did not exit: ${remaining.join(', ')}`);
|
|
423
516
|
}
|
|
424
517
|
exports.killTask = killTask;
|
|
425
518
|
async function getPid(cmd) {
|
|
@@ -498,11 +591,13 @@ function safeJSONParse(value) {
|
|
|
498
591
|
return JSON.parse(value);
|
|
499
592
|
}
|
|
500
593
|
catch (error) {
|
|
501
|
-
logger_1.default.error('[safeJSONParse
|
|
594
|
+
logger_1.default.error('[safeJSONParse error]', error);
|
|
502
595
|
return {};
|
|
503
596
|
}
|
|
504
597
|
}
|
|
505
598
|
exports.safeJSONParse = safeJSONParse;
|
|
599
|
+
var errors_1 = require("../shared/errors");
|
|
600
|
+
Object.defineProperty(exports, "errStack", { enumerable: true, get: function () { return errors_1.errStack; } });
|
|
506
601
|
async function rmPath(path) {
|
|
507
602
|
try {
|
|
508
603
|
const _exsit = await fileExist(path);
|
|
@@ -511,7 +606,7 @@ async function rmPath(path) {
|
|
|
511
606
|
}
|
|
512
607
|
}
|
|
513
608
|
catch (error) {
|
|
514
|
-
logger_1.default.error('[rmPath
|
|
609
|
+
logger_1.default.error('[rmPath error]', error);
|
|
515
610
|
}
|
|
516
611
|
}
|
|
517
612
|
exports.rmPath = rmPath;
|
|
@@ -525,7 +620,7 @@ async function setSystemTimezone(timezone) {
|
|
|
525
620
|
return true;
|
|
526
621
|
}
|
|
527
622
|
catch (error) {
|
|
528
|
-
logger_1.default.error('[setSystemTimezone
|
|
623
|
+
logger_1.default.error('[setSystemTimezone error]', error);
|
|
529
624
|
return false;
|
|
530
625
|
}
|
|
531
626
|
}
|
|
@@ -61,6 +61,7 @@ exports.CrontabModel = _1.sequelize.define('Crontab', {
|
|
|
61
61
|
isDisabled: sequelize_1.DataTypes.NUMBER,
|
|
62
62
|
isPinned: sequelize_1.DataTypes.NUMBER,
|
|
63
63
|
log_path: sequelize_1.DataTypes.STRING,
|
|
64
|
+
queued_token: sequelize_1.DataTypes.STRING,
|
|
64
65
|
labels: sequelize_1.DataTypes.JSON,
|
|
65
66
|
last_running_time: sequelize_1.DataTypes.NUMBER,
|
|
66
67
|
last_execution_time: sequelize_1.DataTypes.NUMBER,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OpeniLinkNotification = exports.WxPusherBotNotification = exports.NtfyNotification = exports.LarkNotification = exports.WebhookNotification = exports.ChronocatNotification = exports.PushMeNotification = exports.EmailNotification = exports.WePlusBotNotification = exports.PushPlusNotification = exports.IGotNotification = exports.AibotkNotification = exports.WeWorkAppNotification = exports.WeWorkBotNotification = exports.DingtalkBotNotification = exports.TelegramBotNotification = exports.BarkNotification = exports.synologyChatNotification = exports.PushDeerNotification = exports.ServerChanNotification = exports.GoCqHttpBotNotification = exports.GotifyNotification = exports.NotificationMode = void 0;
|
|
3
|
+
exports.WpushNotification = exports.OpeniLinkNotification = exports.WxPusherSptNotification = exports.WxPusherBotNotification = exports.NtfyNotification = exports.LarkNotification = exports.WebhookNotification = exports.ChronocatNotification = exports.PushMeNotification = exports.EmailNotification = exports.WePlusBotNotification = exports.PushPlusNotification = exports.IGotNotification = exports.AibotkNotification = exports.WeWorkAppNotification = exports.WeWorkBotNotification = exports.DingtalkBotNotification = exports.TelegramBotNotification = exports.BarkNotification = exports.synologyChatNotification = exports.PushDeerNotification = exports.ServerChanNotification = exports.GoCqHttpBotNotification = exports.GotifyNotification = exports.NotificationMode = void 0;
|
|
4
4
|
var NotificationMode;
|
|
5
5
|
(function (NotificationMode) {
|
|
6
6
|
NotificationMode["gotify"] = "gotify";
|
|
@@ -25,6 +25,7 @@ var NotificationMode;
|
|
|
25
25
|
NotificationMode["ntfy"] = "ntfy";
|
|
26
26
|
NotificationMode["wxPusherBot"] = "wxPusherBot";
|
|
27
27
|
NotificationMode["openiLink"] = "openiLink";
|
|
28
|
+
NotificationMode["wpush"] = "wpush";
|
|
28
29
|
})(NotificationMode || (exports.NotificationMode = NotificationMode = {}));
|
|
29
30
|
class NotificationBaseInfo {
|
|
30
31
|
}
|
|
@@ -223,6 +224,13 @@ class WxPusherBotNotification extends NotificationBaseInfo {
|
|
|
223
224
|
}
|
|
224
225
|
}
|
|
225
226
|
exports.WxPusherBotNotification = WxPusherBotNotification;
|
|
227
|
+
class WxPusherSptNotification extends NotificationBaseInfo {
|
|
228
|
+
constructor() {
|
|
229
|
+
super(...arguments);
|
|
230
|
+
this.wxPusherSptList = '';
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
exports.WxPusherSptNotification = WxPusherSptNotification;
|
|
226
234
|
class OpeniLinkNotification extends NotificationBaseInfo {
|
|
227
235
|
constructor() {
|
|
228
236
|
super(...arguments);
|
|
@@ -232,4 +240,13 @@ class OpeniLinkNotification extends NotificationBaseInfo {
|
|
|
232
240
|
}
|
|
233
241
|
}
|
|
234
242
|
exports.OpeniLinkNotification = OpeniLinkNotification;
|
|
243
|
+
class WpushNotification extends NotificationBaseInfo {
|
|
244
|
+
constructor() {
|
|
245
|
+
super(...arguments);
|
|
246
|
+
this.wpushApiKey = '';
|
|
247
|
+
this.wpushChannel = '';
|
|
248
|
+
this.wpushTopicCode = '';
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
exports.WpushNotification = WpushNotification;
|
|
235
252
|
//# sourceMappingURL=notify.js.map
|
|
@@ -10,18 +10,20 @@ const initData_1 = __importDefault(require("./initData"));
|
|
|
10
10
|
const deps_1 = __importDefault(require("./deps"));
|
|
11
11
|
const initTask_1 = __importDefault(require("./initTask"));
|
|
12
12
|
const initFile_1 = __importDefault(require("./initFile"));
|
|
13
|
+
const trustProxy_1 = require("../shared/trustProxy");
|
|
13
14
|
exports.default = async ({ app }) => {
|
|
14
15
|
(0, depInjector_1.default)();
|
|
15
|
-
logger_1.default.info('
|
|
16
|
+
logger_1.default.info('[boot] Dependency loaded');
|
|
16
17
|
await (0, deps_1.default)();
|
|
17
|
-
logger_1.default.info('
|
|
18
|
+
logger_1.default.info('[boot] Link deps loaded');
|
|
18
19
|
await (0, initFile_1.default)();
|
|
19
|
-
logger_1.default.info('
|
|
20
|
+
logger_1.default.info('[boot] Init file loaded');
|
|
20
21
|
await (0, initData_1.default)();
|
|
21
|
-
logger_1.default.info('
|
|
22
|
+
logger_1.default.info('[boot] Init data loaded');
|
|
22
23
|
(0, initTask_1.default)();
|
|
23
|
-
logger_1.default.info('
|
|
24
|
+
logger_1.default.info('[boot] Init task loaded');
|
|
24
25
|
(0, express_1.default)({ app });
|
|
25
|
-
|
|
26
|
+
await (0, trustProxy_1.initializeTrustProxy)(app);
|
|
27
|
+
logger_1.default.info('[boot] Express loaded');
|
|
26
28
|
};
|
|
27
29
|
//# sourceMappingURL=app.js.map
|
|
@@ -14,6 +14,7 @@ const cronView_1 = require("../data/cronView");
|
|
|
14
14
|
const cronStats_1 = require("../data/cronStats");
|
|
15
15
|
const runningInstance_1 = require("../data/runningInstance");
|
|
16
16
|
const data_1 = require("../data");
|
|
17
|
+
const schemaMigrations_1 = require("../shared/schemaMigrations");
|
|
17
18
|
exports.default = async () => {
|
|
18
19
|
try {
|
|
19
20
|
await cron_1.CrontabModel.sync();
|
|
@@ -25,43 +26,12 @@ exports.default = async () => {
|
|
|
25
26
|
await cronView_1.CrontabViewModel.sync();
|
|
26
27
|
await cronStats_1.CrontabStatModel.sync();
|
|
27
28
|
await runningInstance_1.RunningInstanceModel.sync();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
{
|
|
31
|
-
table: 'CrontabViews',
|
|
32
|
-
column: 'filterRelation',
|
|
33
|
-
type: 'VARCHAR(255)',
|
|
34
|
-
},
|
|
35
|
-
{ table: 'Subscriptions', column: 'proxy', type: 'VARCHAR(255)' },
|
|
36
|
-
{ table: 'CrontabViews', column: 'type', type: 'NUMBER' },
|
|
37
|
-
{ table: 'Subscriptions', column: 'autoAddCron', type: 'NUMBER' },
|
|
38
|
-
{ table: 'Subscriptions', column: 'autoDelCron', type: 'NUMBER' },
|
|
39
|
-
{ table: 'Crontabs', column: 'sub_id', type: 'NUMBER' },
|
|
40
|
-
{ table: 'Crontabs', column: 'extra_schedules', type: 'JSON' },
|
|
41
|
-
{ table: 'Crontabs', column: 'task_before', type: 'TEXT' },
|
|
42
|
-
{ table: 'Crontabs', column: 'task_after', type: 'TEXT' },
|
|
43
|
-
{ table: 'Crontabs', column: 'log_name', type: 'VARCHAR(255)' },
|
|
44
|
-
{
|
|
45
|
-
table: 'Crontabs',
|
|
46
|
-
column: 'allow_multiple_instances',
|
|
47
|
-
type: 'NUMBER',
|
|
48
|
-
},
|
|
49
|
-
{ table: 'Crontabs', column: 'work_dir', type: 'VARCHAR(255)' },
|
|
50
|
-
{ table: 'Envs', column: 'isPinned', type: 'NUMBER' },
|
|
51
|
-
{ table: 'Envs', column: 'labels', type: 'JSON' },
|
|
52
|
-
];
|
|
53
|
-
for (const migration of migrations) {
|
|
54
|
-
try {
|
|
55
|
-
await data_1.sequelize.query(`alter table ${migration.table} add column ${migration.column} ${migration.type}`);
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
// Column already exists or other error, continue
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
logger_1.default.info('✌️ DB loaded');
|
|
29
|
+
await (0, schemaMigrations_1.migrateSchema)(data_1.sequelize);
|
|
30
|
+
logger_1.default.info('[boot] DB loaded');
|
|
62
31
|
}
|
|
63
32
|
catch (error) {
|
|
64
|
-
logger_1.default.error('
|
|
33
|
+
logger_1.default.error('[boot] DB load failed', error);
|
|
34
|
+
throw error;
|
|
65
35
|
}
|
|
66
36
|
};
|
|
67
37
|
//# sourceMappingURL=db.js.map
|
|
@@ -6,20 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const path_1 = __importDefault(require("path"));
|
|
7
7
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
|
-
const chokidar_1 = __importDefault(require("chokidar"));
|
|
10
9
|
const index_1 = __importDefault(require("../config/index"));
|
|
11
10
|
const logger_1 = __importDefault(require("./logger"));
|
|
12
|
-
async function linkToNodeModule(src, dst) {
|
|
13
|
-
const target = path_1.default.join(index_1.default.rootPath, 'node_modules', dst || src);
|
|
14
|
-
const source = path_1.default.join(index_1.default.rootPath, src);
|
|
15
|
-
try {
|
|
16
|
-
const stats = await promises_1.default.lstat(target);
|
|
17
|
-
if (!stats) {
|
|
18
|
-
await promises_1.default.symlink(source, target, 'dir');
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
catch (error) { }
|
|
22
|
-
}
|
|
23
11
|
async function linkCommand() {
|
|
24
12
|
const homeDir = os_1.default.homedir();
|
|
25
13
|
let userBinDir = path_1.default.join(homeDir, 'bin');
|
|
@@ -32,6 +20,35 @@ async function linkCommand() {
|
|
|
32
20
|
}
|
|
33
21
|
}
|
|
34
22
|
async function linkCommandToDir(commandDir) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
const cliRoot = process.env.QL_CLI_ROOT;
|
|
25
|
+
if (cliRoot) {
|
|
26
|
+
if (!path_1.default.isAbsolute(cliRoot)) {
|
|
27
|
+
throw new Error('QL_CLI_ROOT must be an absolute CLI installation path');
|
|
28
|
+
}
|
|
29
|
+
const { installCliEntrypoints } = require(path_1.default.join(cliRoot, 'dist/local/entrypoints.js'));
|
|
30
|
+
await installCliEntrypoints(commandDir, cliRoot);
|
|
31
|
+
const { installCronEntrypoint } = require(path_1.default.join(cliRoot, 'dist/local/cronEntrypoint.js'));
|
|
32
|
+
await installCronEntrypoint(commandDir, cliRoot, index_1.default.crontabFile, Object.assign(Object.assign({}, process.env), { QL_DIR: index_1.default.rootPath, QL_DATA_DIR: index_1.default.dataPath }));
|
|
33
|
+
// Container-wide legacy links may precede ~/bin. Ensure panel children use
|
|
34
|
+
// the explicitly selected entries without changing system-wide links.
|
|
35
|
+
process.env.PATH = [
|
|
36
|
+
commandDir,
|
|
37
|
+
...((_b = (_a = process.env.PATH) === null || _a === void 0 ? void 0 : _a.split(path_1.default.delimiter)) !== null && _b !== void 0 ? _b : []).filter((entry) => entry !== commandDir),
|
|
38
|
+
].join(path_1.default.delimiter);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const cronBridge = path_1.default.join(commandDir, 'crontab');
|
|
42
|
+
try {
|
|
43
|
+
if ((await promises_1.default.lstat(cronBridge)).isFile() &&
|
|
44
|
+
(await promises_1.default.readFile(cronBridge, 'utf8')).includes('// QingLong CLI crontab bridge')) {
|
|
45
|
+
await promises_1.default.unlink(cronBridge);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (error.code !== 'ENOENT')
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
35
52
|
const linkShell = [
|
|
36
53
|
{
|
|
37
54
|
src: 'update.sh',
|
|
@@ -59,16 +76,7 @@ async function linkCommandToDir(commandDir) {
|
|
|
59
76
|
await promises_1.default.rename(tmpTarget, target);
|
|
60
77
|
}
|
|
61
78
|
}
|
|
62
|
-
exports.default = async (
|
|
79
|
+
exports.default = async () => {
|
|
63
80
|
await linkCommand();
|
|
64
|
-
await linkToNodeModule(src);
|
|
65
|
-
const source = path_1.default.join(index_1.default.rootPath, src);
|
|
66
|
-
const watcher = chokidar_1.default.watch(source, {
|
|
67
|
-
ignored: /(^|[\/\\])\../,
|
|
68
|
-
persistent: true,
|
|
69
|
-
});
|
|
70
|
-
watcher
|
|
71
|
-
.on('add', () => linkToNodeModule(src))
|
|
72
|
-
.on('change', () => linkToNodeModule(src));
|
|
73
81
|
};
|
|
74
82
|
//# sourceMappingURL=deps.js.map
|
|
@@ -17,33 +17,43 @@ const store_1 = require("../shared/store");
|
|
|
17
17
|
const auth_1 = require("../shared/auth");
|
|
18
18
|
const path_1 = __importDefault(require("path"));
|
|
19
19
|
const i18n_1 = require("../shared/i18n");
|
|
20
|
+
const protectedPathCase_1 = __importDefault(require("../middlewares/protectedPathCase"));
|
|
21
|
+
function resolveTrustProxy(value = process.env.QL_TRUST_PROXY) {
|
|
22
|
+
const setting = value === null || value === void 0 ? void 0 : value.trim();
|
|
23
|
+
if (!setting) {
|
|
24
|
+
return 'loopback';
|
|
25
|
+
}
|
|
26
|
+
if (setting === 'true' || setting === 'false') {
|
|
27
|
+
return setting === 'true';
|
|
28
|
+
}
|
|
29
|
+
if (/^\d+$/.test(setting)) {
|
|
30
|
+
return Number(setting);
|
|
31
|
+
}
|
|
32
|
+
return setting;
|
|
33
|
+
}
|
|
20
34
|
exports.default = ({ app }) => {
|
|
21
35
|
// Security: Enable strict routing to prevent case-insensitive path bypass
|
|
22
36
|
app.set('case sensitive routing', true);
|
|
23
37
|
app.set('strict routing', true);
|
|
24
|
-
app.set('trust proxy',
|
|
38
|
+
app.set('trust proxy', resolveTrustProxy());
|
|
25
39
|
app.use((0, cors_1.default)());
|
|
26
|
-
// Security:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const normalizedPath = originalPath.toLowerCase();
|
|
30
|
-
// Block requests with case variations on protected paths
|
|
31
|
-
if (originalPath !== normalizedPath &&
|
|
32
|
-
(normalizedPath.startsWith('/api/') || normalizedPath.startsWith('/open/'))) {
|
|
33
|
-
return res.status(400).json({
|
|
34
|
-
code: 400,
|
|
35
|
-
message: 'Invalid path format'
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
next();
|
|
39
|
-
});
|
|
40
|
+
// Security: Reject case variations under protected API namespaces before
|
|
41
|
+
// authentication checks can interpret the request differently from routing.
|
|
42
|
+
app.use(protectedPathCase_1.default);
|
|
40
43
|
// Rewrite URLs to strip baseUrl prefix if configured
|
|
41
44
|
// This allows the rest of the app to work without baseUrl awareness
|
|
42
45
|
if (config_1.default.baseUrl) {
|
|
43
46
|
app.use((0, express_urlrewrite_1.default)(`${config_1.default.baseUrl}/*`, '/$1'));
|
|
44
47
|
}
|
|
45
48
|
app.get(`${config_1.default.api.prefix}/env.js`, serverEnv_1.serveEnv);
|
|
46
|
-
app.use(`${config_1.default.api.prefix}/static`, express_1.default.static(config_1.default.uploadPath
|
|
49
|
+
app.use(`${config_1.default.api.prefix}/static`, express_1.default.static(config_1.default.uploadPath, {
|
|
50
|
+
setHeaders: (res) => {
|
|
51
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
52
|
+
res.setHeader('Content-Security-Policy', "sandbox; default-src 'none'");
|
|
53
|
+
},
|
|
54
|
+
}));
|
|
55
|
+
const credentialPaths = ['/api', '/open'].flatMap((prefix) => ['/user/login', '/user/init', '/user/two-factor/login'].map((route) => `${prefix}${route}`));
|
|
56
|
+
app.use(credentialPaths, body_parser_1.default.json({ limit: '16kb' }), body_parser_1.default.urlencoded({ limit: '16kb', extended: false }));
|
|
47
57
|
app.use(body_parser_1.default.json({ limit: '50mb' }));
|
|
48
58
|
app.use(body_parser_1.default.urlencoded({ limit: '50mb', extended: true }));
|
|
49
59
|
const frontendPath = path_1.default.join(config_1.default.rootPath, 'static/dist');
|
|
@@ -78,27 +88,34 @@ exports.default = ({ app }) => {
|
|
|
78
88
|
const currentToken = doc.tokens.find((x) => x.value === headerToken);
|
|
79
89
|
const keyMatch = pathLower.match(/\/open\/([a-z]+)\/*/);
|
|
80
90
|
const key = keyMatch && keyMatch[1];
|
|
81
|
-
if (doc.scopes.includes(key)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
91
|
+
if (!doc.scopes.includes(key)) {
|
|
92
|
+
const err = new express_jwt_1.UnauthorizedError('credentials_bad_scheme', {
|
|
93
|
+
message: (0, i18n_1.t)('暂无权限'),
|
|
94
|
+
});
|
|
95
|
+
return next(err);
|
|
85
96
|
}
|
|
97
|
+
if (!currentToken ||
|
|
98
|
+
currentToken.expiration < Math.round(Date.now() / 1000)) {
|
|
99
|
+
const err = new express_jwt_1.UnauthorizedError('invalid_token', {
|
|
100
|
+
message: (0, i18n_1.t)('Token 已失效'),
|
|
101
|
+
});
|
|
102
|
+
return next(err);
|
|
103
|
+
}
|
|
104
|
+
return next();
|
|
86
105
|
}
|
|
87
106
|
}
|
|
88
|
-
const originPath = `${req.baseUrl}${
|
|
107
|
+
const originPath = `${req.baseUrl}${pathLower === '/' ? '' : pathLower}`;
|
|
89
108
|
if (!headerToken &&
|
|
90
109
|
originPath &&
|
|
91
110
|
config_1.default.apiWhiteList.includes(originPath)) {
|
|
92
111
|
return next();
|
|
93
112
|
}
|
|
94
113
|
const authInfo = await store_1.shareStore.getAuthInfo();
|
|
95
|
-
if ((0, auth_1.isValidToken)(authInfo, headerToken, req.platform)) {
|
|
114
|
+
if ((0, auth_1.isValidToken)(authInfo, headerToken, req.platform, config_1.default.jwt.secret)) {
|
|
96
115
|
return next();
|
|
97
116
|
}
|
|
98
117
|
const errorCode = headerToken ? 'invalid_token' : 'credentials_required';
|
|
99
|
-
const errorMessage = headerToken
|
|
100
|
-
? 'jwt malformed'
|
|
101
|
-
: 'No authorization token was found';
|
|
118
|
+
const errorMessage = headerToken ? (0, i18n_1.t)('Token 已失效') : (0, i18n_1.t)('请先登录');
|
|
102
119
|
const err = new express_jwt_1.UnauthorizedError(errorCode, { message: errorMessage });
|
|
103
120
|
next(err);
|
|
104
121
|
});
|
|
@@ -109,16 +126,11 @@ exports.default = ({ app }) => {
|
|
|
109
126
|
'/api/user/notification/init',
|
|
110
127
|
'/open/user/init',
|
|
111
128
|
'/open/user/notification/init',
|
|
112
|
-
].includes(
|
|
129
|
+
].includes(pathLower)) {
|
|
113
130
|
return next();
|
|
114
131
|
}
|
|
115
132
|
const authInfo = (await store_1.shareStore.getAuthInfo()) || {};
|
|
116
|
-
let isInitialized =
|
|
117
|
-
if (Object.keys(authInfo).length === 2 &&
|
|
118
|
-
authInfo.username === 'admin' &&
|
|
119
|
-
authInfo.password === 'admin') {
|
|
120
|
-
isInitialized = false;
|
|
121
|
-
}
|
|
133
|
+
let isInitialized = !(0, auth_1.isDefaultAuthInfo)(authInfo);
|
|
122
134
|
if (isInitialized) {
|
|
123
135
|
return res.send({ code: 450, message: (0, i18n_1.t)('未知错误') });
|
|
124
136
|
}
|
|
@@ -45,11 +45,12 @@ const util_1 = require("../config/util");
|
|
|
45
45
|
const open_1 = __importDefault(require("../services/open"));
|
|
46
46
|
const store_1 = require("../shared/store");
|
|
47
47
|
const logger_1 = __importDefault(require("./logger"));
|
|
48
|
+
const client_1 = __importDefault(require("../schedule/client"));
|
|
48
49
|
const open_2 = require("../data/open");
|
|
49
50
|
const runningInstance_1 = require("../data/runningInstance");
|
|
50
51
|
const i18n_1 = require("../shared/i18n");
|
|
51
52
|
exports.default = async () => {
|
|
52
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
53
54
|
const cronService = typedi_1.Container.get(cron_2.default);
|
|
54
55
|
const envService = typedi_1.Container.get(env_1.default);
|
|
55
56
|
const dependenceService = typedi_1.Container.get(dependence_1.default);
|
|
@@ -206,18 +207,20 @@ exports.default = async () => {
|
|
|
206
207
|
}
|
|
207
208
|
}
|
|
208
209
|
});
|
|
209
|
-
//
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
// 初始化语言(必须在 autosave_crontab 之前)
|
|
211
|
+
const lang = ((_h = systemConfig.info) === null || _h === void 0 ? void 0 : _h.lang) || (0, i18n_1.systemLang)();
|
|
212
|
+
(0, i18n_1.setLang)(lang);
|
|
213
|
+
// 确保 lang_env.sh 存在
|
|
212
214
|
try {
|
|
213
215
|
const langEnvExist = await (0, util_1.fileExist)(config_1.default.langEnvFile);
|
|
214
216
|
if (!langEnvExist) {
|
|
215
|
-
const lang = ((_h = systemConfig.info) === null || _h === void 0 ? void 0 : _h.lang) || 'zh';
|
|
216
217
|
await (0, promises_1.writeFile)(config_1.default.langEnvFile, `export QL_LANG='${lang}'\n`);
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
|
-
catch (
|
|
220
|
-
|
|
220
|
+
catch (_j) { }
|
|
221
|
+
// 初始化保存一次ck和定时任务数据
|
|
222
|
+
client_1.default.readiness.configure(() => cronService.autosave_crontab(true));
|
|
223
|
+
await client_1.default.readiness.recover();
|
|
221
224
|
await envService.set_envs();
|
|
222
225
|
const authInfo = await userService.getAuthInfo();
|
|
223
226
|
const apps = await openService.findApps();
|