@whyour/qinglong 2.21.0 → 2.23.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.
Files changed (362) hide show
  1. package/.dockerignore +13 -0
  2. package/.env.example +7 -0
  3. package/AGENTS.md +2 -2
  4. package/README-en.md +24 -0
  5. package/README.md +24 -0
  6. package/back/protos/api.proto +9 -1
  7. package/back/protos/cron.proto +8 -1
  8. package/deploy/kubernetes/README.md +81 -0
  9. package/deploy/kubernetes/base/kustomization.yaml +5 -0
  10. package/deploy/kubernetes/base/qinglong.yaml +95 -0
  11. package/deploy/kubernetes/overlays/example/kustomization.yaml +10 -0
  12. package/docker/Dockerfile +31 -12
  13. package/docker/Dockerfile.310 +31 -12
  14. package/docker/Dockerfile.debian +22 -14
  15. package/docker/Dockerfile.debian310 +24 -14
  16. package/docker/build-manifest.cjs +28 -0
  17. package/docker/verify-build.cjs +49 -0
  18. package/docs/development/node-cron-migration.md +49 -0
  19. package/docs/development/task-startup.md +78 -0
  20. package/docs/releases/2.22.0-validation.md +49 -0
  21. package/docs/releases/2.22.0.md +62 -0
  22. package/docs/releases/2.23.0.md +33 -0
  23. package/docs/script-history.md +53 -0
  24. package/ecosystem.config.js +10 -1
  25. package/package.json +19 -13
  26. package/sample/config.sample.sh +17 -2
  27. package/sample/notify.js +118 -0
  28. package/sample/notify.py +93 -0
  29. package/scripts/benchmark-execution.cjs +96 -0
  30. package/scripts/benchmark-script-history.cjs +39 -0
  31. package/scripts/publish-static.sh +34 -0
  32. package/scripts/sync-static.sh +20 -0
  33. package/scripts/wait-for-mirror.sh +214 -0
  34. package/scripts/write-build-info.cjs +27 -0
  35. package/shell/api.sh +96 -83
  36. package/shell/check.sh +59 -19
  37. package/shell/lang/en.sh +6 -0
  38. package/shell/lang/zh.sh +6 -0
  39. package/shell/node_path_cache.sh +136 -0
  40. package/shell/otask.sh +17 -10
  41. package/shell/preload/sitecustomize.js +11 -3
  42. package/shell/preload/sitecustomize.py +4 -2
  43. package/shell/share.sh +27 -10
  44. package/shell/start.sh +6 -3
  45. package/shell/task-timeout.sh +63 -0
  46. package/shell/task.sh +21 -9
  47. package/shell/update.sh +104 -98
  48. package/shell/upgrade.cjs +8 -0
  49. package/static/build/api/clientIp.js +42 -0
  50. package/static/build/api/config.js +9 -21
  51. package/static/build/api/cron.js +39 -3
  52. package/static/build/api/dashboard.js +50 -6
  53. package/static/build/api/env.js +17 -16
  54. package/static/build/api/health.js +2 -2
  55. package/static/build/api/index.js +4 -0
  56. package/static/build/api/log.js +39 -19
  57. package/static/build/api/open.js +2 -1
  58. package/static/build/api/retention.js +63 -0
  59. package/static/build/api/script.js +172 -25
  60. package/static/build/api/subscription.js +19 -8
  61. package/static/build/api/system.js +66 -12
  62. package/static/build/api/user.js +75 -15
  63. package/static/build/app.js +63 -54
  64. package/static/build/bootstrap/database.js +51 -0
  65. package/static/build/config/const.js +2 -0
  66. package/static/build/config/grpcCerts.js +93 -44
  67. package/static/build/config/index.js +0 -4
  68. package/static/build/config/share.js +5 -4
  69. package/static/build/config/subscription.js +19 -11
  70. package/static/build/config/util.js +142 -45
  71. package/static/build/data/cron.js +1 -0
  72. package/static/build/data/notify.js +18 -1
  73. package/static/build/data/sock.js +1 -0
  74. package/static/build/loaders/app.js +8 -6
  75. package/static/build/loaders/db.js +5 -35
  76. package/static/build/loaders/deps.js +30 -22
  77. package/static/build/loaders/express.js +46 -32
  78. package/static/build/loaders/initData.js +26 -33
  79. package/static/build/loaders/initFile.js +1 -1
  80. package/static/build/loaders/initTask.js +14 -3
  81. package/static/build/loaders/server.js +1 -1
  82. package/static/build/loaders/sock.js +72 -6
  83. package/static/build/middlewares/monitoring.js +12 -33
  84. package/static/build/middlewares/protectedPathCase.js +17 -0
  85. package/static/build/middlewares/uniqueConstraintError.js +15 -0
  86. package/static/build/protos/api.js +78 -2
  87. package/static/build/protos/cron.js +83 -5
  88. package/static/build/protos/health.js +1 -1
  89. package/static/build/schedule/addCron.js +67 -19
  90. package/static/build/schedule/api.js +5 -2
  91. package/static/build/schedule/client.js +56 -6
  92. package/static/build/schedule/delCron.js +11 -1
  93. package/static/build/schedule/health.js +72 -7
  94. package/static/build/schedule/setConcurrency.js +27 -0
  95. package/static/build/services/config.js +5 -43
  96. package/static/build/services/cron.js +389 -174
  97. package/static/build/services/dependence.js +66 -18
  98. package/static/build/services/env.js +1 -1
  99. package/static/build/services/grpc.js +4 -3
  100. package/static/build/services/health.js +4 -7
  101. package/static/build/services/http.js +9 -3
  102. package/static/build/services/log.js +2 -3
  103. package/static/build/services/metrics.js +46 -14
  104. package/static/build/services/notify.js +73 -5
  105. package/static/build/services/open.js +106 -31
  106. package/static/build/services/retention.js +123 -0
  107. package/static/build/services/schedule.js +77 -43
  108. package/static/build/services/script.js +4 -5
  109. package/static/build/services/scriptHistory.js +30 -0
  110. package/static/build/services/sshKey.js +39 -14
  111. package/static/build/services/subscription.js +161 -87
  112. package/static/build/services/system.js +116 -43
  113. package/static/build/services/user.js +255 -37
  114. package/static/build/shared/auth.js +22 -3
  115. package/static/build/shared/authMutation.js +17 -0
  116. package/static/build/shared/childProcess.js +82 -0
  117. package/static/build/shared/clientIp.js +27 -0
  118. package/static/build/shared/cronCommand.js +17 -0
  119. package/static/build/shared/cronSchedule.js +101 -0
  120. package/static/build/shared/cronScheduler.js +73 -0
  121. package/static/build/shared/errors.js +9 -0
  122. package/static/build/shared/fileAccess.js +60 -0
  123. package/static/build/shared/i18n.js +63 -4
  124. package/static/build/shared/logPath.js +15 -0
  125. package/static/build/shared/logReader.js +85 -0
  126. package/static/build/shared/logStreamManager.js +80 -60
  127. package/static/build/shared/loginThrottle.js +45 -0
  128. package/static/build/shared/pLimit.js +22 -8
  129. package/static/build/shared/password.js +30 -0
  130. package/static/build/shared/retention.js +58 -0
  131. package/static/build/shared/runCron.js +39 -17
  132. package/static/build/shared/schedulerMutationLock.js +44 -0
  133. package/static/build/shared/schedulerReadiness.js +82 -0
  134. package/static/build/shared/schemaMigrations.js +58 -0
  135. package/static/build/shared/scriptHistory.js +445 -0
  136. package/static/build/shared/shellQuote.js +11 -0
  137. package/static/build/shared/startupProcess.js +48 -0
  138. package/static/build/shared/store.js +7 -0
  139. package/static/build/shared/subscriptionMutationLock.js +34 -0
  140. package/static/build/shared/subscriptionPath.js +41 -0
  141. package/static/build/shared/subscriptionStorage.js +98 -0
  142. package/static/build/shared/trustProxy.js +119 -0
  143. package/static/build/shared/utils.js +2 -1
  144. package/static/build/token.js +3 -14
  145. package/static/build/validation/schedule.js +6 -12
  146. package/static/dist/{1885.e1ea09f6.async.js → 1885.b8f427bf.async.js} +1 -1
  147. package/static/dist/2031.6af40025.async.js +1 -0
  148. package/static/dist/2693.51c2636b.async.js +1 -0
  149. package/static/dist/{2890.9e373f5b.async.js → 2890.add55e85.async.js} +1 -1
  150. package/static/dist/2901.2ca95295.async.js +1 -0
  151. package/static/dist/292.264757f0.async.js +1 -0
  152. package/static/dist/3512.95e41255.async.js +1 -0
  153. package/static/dist/445.a65ff63b.async.js +1 -0
  154. package/static/dist/4736.1d2b5cb6.async.js +1 -0
  155. package/static/dist/{6013.4e38de36.async.js → 6013.db535339.async.js} +1 -1
  156. package/static/dist/6212.9e6d9913.async.js +1 -0
  157. package/static/dist/{6339.ab305e96.async.js → 6431.4603ad0e.async.js} +1 -1
  158. package/static/dist/{6872.42f939f1.async.js → 6872.a503ef55.async.js} +1 -1
  159. package/static/dist/7231.f7e5b668.async.js +1 -0
  160. package/static/dist/{7355.f9f263d8.async.js → 7355.fca746f5.async.js} +1 -1
  161. package/static/dist/{7508.7dcee91c.async.js → 7508.d90eac63.async.js} +1 -1
  162. package/static/dist/{7984.594296a5.async.js → 7984.eaac7402.async.js} +1 -1
  163. package/static/dist/8844.a0fef08e.async.js +1 -0
  164. package/static/dist/index.html +2 -2
  165. package/static/dist/layouts__index.633d3553.async.js +1 -0
  166. package/static/dist/preload_helper.01fcd534.js +1 -0
  167. package/static/dist/{src__pages__config__index.a22ff7dc.async.js → src__pages__config__index.9aba4054.async.js} +1 -1
  168. package/static/dist/src__pages__crontab__detail.86b2eebb.async.js +1 -0
  169. package/static/dist/src__pages__crontab__index.ae4e06f2.async.js +1 -0
  170. package/static/dist/{src__pages__crontab__logModal.0b8cce8c.async.js → src__pages__crontab__logModal.930535e2.async.js} +1 -1
  171. package/static/dist/src__pages__crontab__modal.a2c8fdcc.async.js +1 -0
  172. package/static/dist/src__pages__crontab__viewCreateModal.7b4f9cbe.async.js +1 -0
  173. package/static/dist/src__pages__crontab__viewManageModal.cd454ea0.async.js +1 -0
  174. package/static/dist/src__pages__dashboard__index.243c5a35.async.js +1 -0
  175. package/static/dist/src__pages__dashboard__taskResultModal.7795d6e1.async.js +1 -0
  176. package/static/dist/src__pages__dependence__index.874d501f.async.js +1 -0
  177. package/static/dist/src__pages__dependence__logModal.154efe7a.async.js +1 -0
  178. package/static/dist/src__pages__dependence__modal.0fa8b421.async.js +1 -0
  179. package/static/dist/src__pages__diff__index.b94e5dc5.async.js +1 -0
  180. package/static/dist/src__pages__env__editNameModal.c13d47d2.async.js +1 -0
  181. package/static/dist/src__pages__env__index.fd6fd2b0.async.js +1 -0
  182. package/static/dist/src__pages__env__modal.4d71adb3.async.js +1 -0
  183. package/static/dist/src__pages__error__index.aae50c94.async.js +1 -0
  184. package/static/dist/src__pages__initialization__index.82a2e967.async.js +1 -0
  185. package/static/dist/src__pages__log__index.71250e0d.async.js +1 -0
  186. package/static/dist/{src__pages__login__index.8c813eb1.async.js → src__pages__login__index.a0fd5ed8.async.js} +1 -1
  187. package/static/dist/src__pages__script__editModal.afabf073.async.js +1 -0
  188. package/static/dist/src__pages__script__editNameModal.789ad87b.async.js +1 -0
  189. package/static/dist/src__pages__script__historyDrawer.8c58d958.async.js +1 -0
  190. package/static/dist/src__pages__script__historyDrawer.a449193a.chunk.css +1 -0
  191. package/static/dist/src__pages__script__index.ab360776.chunk.css +1 -0
  192. package/static/dist/src__pages__script__index.fc575945.async.js +1 -0
  193. package/static/dist/src__pages__script__renameModal.0ab029e7.async.js +1 -0
  194. package/static/dist/src__pages__script__saveModal.8fca1a22.async.js +1 -0
  195. package/static/dist/src__pages__script__saveWithHistory.99ece830.async.js +1 -0
  196. package/static/dist/src__pages__script__setting.35ad4f02.async.js +1 -0
  197. package/static/dist/src__pages__setting__appModal.7eaeb9d3.async.js +1 -0
  198. package/static/dist/src__pages__setting__checkUpdate.d175b154.async.js +1 -0
  199. package/static/dist/src__pages__setting__clientIp.3a8711ed.async.js +1 -0
  200. package/static/dist/src__pages__setting__dependence.9c0f749b.async.js +1 -0
  201. package/static/dist/src__pages__setting__index.cb397741.async.js +1 -0
  202. package/static/dist/src__pages__setting__loginLog.e0a1f54d.async.js +1 -0
  203. package/static/dist/src__pages__setting__notification.2ffe4e5a.async.js +1 -0
  204. package/static/dist/src__pages__setting__other.3d0b8492.async.js +1 -0
  205. package/static/dist/{src__pages__setting__progress.8823ac90.async.js → src__pages__setting__progress.2ccae3d7.async.js} +1 -1
  206. package/static/dist/src__pages__setting__security.e2d71ebb.async.js +1 -0
  207. package/static/dist/src__pages__setting__systemLog.b3046955.async.js +1 -0
  208. package/static/dist/src__pages__subscription__index.43086a06.async.js +1 -0
  209. package/static/dist/src__pages__subscription__logModal.cdba5139.async.js +1 -0
  210. package/static/dist/src__pages__subscription__modal.30868ba8.async.js +1 -0
  211. package/static/dist/{umi.ca04a019.js → umi.3a24a9fa.js} +1 -1
  212. package/test/back/advisory-input-security.test.cjs +416 -0
  213. package/test/back/auth-security.test.cjs +74 -0
  214. package/test/back/build-provenance.test.cjs +150 -0
  215. package/test/back/code-scanning-security.test.cjs +189 -0
  216. package/test/back/cron-log-name.test.cjs +110 -0
  217. package/test/back/cron-macros.test.cjs +51 -0
  218. package/test/back/cron-schedule-compatibility.test.cjs +69 -0
  219. package/test/back/cron-scheduler-routing.test.cjs +59 -0
  220. package/test/back/cron-validation.test.cjs +45 -0
  221. package/test/back/dashboard-failures.test.cjs +173 -0
  222. package/test/back/database-bootstrap.test.cjs +193 -0
  223. package/test/back/dependence-cache-status.test.cjs +125 -0
  224. package/test/back/deprecated-file-routes.test.cjs +82 -0
  225. package/test/back/draft-path-security.test.cjs +235 -0
  226. package/test/back/ecosystem.test.cjs +28 -0
  227. package/test/back/env-import-security.test.cjs +91 -0
  228. package/test/back/env-name-parsing.test.cjs +96 -0
  229. package/test/back/execution-lifecycle.test.cjs +236 -0
  230. package/test/back/file-access-scope.test.cjs +180 -0
  231. package/test/back/file-access-security.test.cjs +47 -0
  232. package/test/back/fileTreeListing.test.cjs +57 -0
  233. package/test/back/grpc-cron-response.test.cjs +60 -0
  234. package/test/back/grpc-mtls-security.test.cjs +136 -0
  235. package/test/back/http-exclusive-listen.test.cjs +31 -0
  236. package/test/back/http-security.test.cjs +313 -0
  237. package/test/back/legacy-cron-recovery.test.cjs +76 -0
  238. package/test/back/linux-mirror-result.test.cjs +176 -0
  239. package/test/back/listen-security.test.cjs +68 -0
  240. package/test/back/log-path-security.test.cjs +158 -0
  241. package/test/back/logReader.test.cjs +72 -0
  242. package/test/back/manual-execution.test.cjs +85 -0
  243. package/test/back/manual-stop-claim.test.cjs +220 -0
  244. package/test/back/metrics.test.cjs +34 -0
  245. package/test/back/mirror-status.test.cjs +257 -0
  246. package/test/back/monitoring.test.cjs +73 -0
  247. package/test/back/node-cron-migration.test.cjs +65 -0
  248. package/test/back/node-path-cache.test.cjs +202 -0
  249. package/test/back/node-path-lock.test.cjs +182 -0
  250. package/test/back/npm-publication.test.cjs +70 -0
  251. package/test/back/preload-lazy-notify.test.cjs +168 -0
  252. package/test/back/primary-apm.test.cjs +24 -0
  253. package/test/back/process-exit-state.test.cjs +81 -0
  254. package/test/back/process-stop-signal.test.cjs +77 -0
  255. package/test/back/protected-path-case.test.cjs +58 -0
  256. package/test/back/qlServiceLogCommand.test.cjs +128 -0
  257. package/test/back/queued-cron-invalidation.test.cjs +98 -0
  258. package/test/back/restart-instance-recovery.test.cjs +116 -0
  259. package/test/back/retention.test.cjs +131 -0
  260. package/test/back/role-loading.test.cjs +118 -0
  261. package/test/back/schedule-health.test.cjs +86 -0
  262. package/test/back/scheduler-bulk-recovery.test.cjs +40 -0
  263. package/test/back/scheduler-concurrency.test.cjs +411 -0
  264. package/test/back/scheduler-file-lock.test.cjs +51 -0
  265. package/test/back/scheduler-mutation.test.cjs +312 -0
  266. package/test/back/scheduler-readiness.test.cjs +85 -0
  267. package/test/back/scheduler-reconciliation.test.cjs +206 -0
  268. package/test/back/scheduler-rpc-timeout.test.cjs +49 -0
  269. package/test/back/schema-migrations.test.cjs +127 -0
  270. package/test/back/script-file-access.test.cjs +210 -0
  271. package/test/back/script-history-api.test.cjs +551 -0
  272. package/test/back/script-history.test.cjs +383 -0
  273. package/test/back/shell-api-parsing.test.cjs +184 -0
  274. package/test/back/shell-translation-output.test.cjs +16 -0
  275. package/test/back/shell-upgrade.test.cjs +312 -0
  276. package/test/back/shellApiToken.test.cjs +151 -0
  277. package/test/back/sock-polling.test.cjs +297 -0
  278. package/test/back/sock-security.test.cjs +72 -0
  279. package/test/back/ssh-config-home.test.cjs +113 -0
  280. package/test/back/start-env-preservation.test.cjs +53 -0
  281. package/test/back/static-mirror-trigger.test.cjs +441 -0
  282. package/test/back/static-mirror.test.cjs +179 -0
  283. package/test/back/stop-failure-feedback.test.cjs +158 -0
  284. package/test/back/stop-race.test.cjs +171 -0
  285. package/test/back/subscription-cleanup.test.cjs +53 -0
  286. package/test/back/subscription-mutation-lock.test.cjs +83 -0
  287. package/test/back/subscription-review-regression.test.cjs +607 -0
  288. package/test/back/subscription-stop-state.test.cjs +66 -0
  289. package/test/back/subscription-storage-regression.test.cjs +553 -0
  290. package/test/back/system-dependence-cache.test.cjs +127 -0
  291. package/test/back/system-export-history.test.cjs +119 -0
  292. package/test/back/systemTokenRenewal.test.cjs +497 -0
  293. package/test/back/task-shell-lifecycle.test.cjs +194 -0
  294. package/test/back/task-time.test.cjs +116 -0
  295. package/test/back/unique-constraint-error.test.cjs +72 -0
  296. package/test/back/upgrade-guards.test.cjs +285 -0
  297. package/test/back/upgrade-lifecycle.test.cjs +288 -0
  298. package/test/back/upgrade-transaction.test.cjs +133 -0
  299. package/test/back/user-api.test.cjs +99 -0
  300. package/test/back/user-security.test.cjs +349 -0
  301. package/test/back/worker-apm.test.cjs +84 -0
  302. package/test/back/wpush-grpc.test.cjs +116 -0
  303. package/test/fixtures/legacy-cron.json +1371 -0
  304. package/test/front/cron-log-pagination.test.cjs +214 -0
  305. package/test/front/diff-file-routing.test.cjs +126 -0
  306. package/test/front/http-auth.test.cjs +152 -0
  307. package/test/front/http-error.test.cjs +29 -0
  308. package/test/front/script-history-save.test.cjs +121 -0
  309. package/test/helpers/load-security-module.cjs +42 -0
  310. package/test/helpers/upgrade-fixture.cjs +30 -0
  311. package/version.yaml +14 -34
  312. package/CLAUDE.md +0 -43
  313. package/static/dist/1147.c420132e.async.js +0 -1
  314. package/static/dist/134.54df9e38.async.js +0 -1
  315. package/static/dist/2096.6d98fd12.async.js +0 -1
  316. package/static/dist/2208.f7ba3dfa.async.js +0 -1
  317. package/static/dist/2286.164bb089.async.js +0 -1
  318. package/static/dist/3191.63263871.async.js +0 -1
  319. package/static/dist/4859.6592cebb.async.js +0 -1
  320. package/static/dist/4902.555f92ab.async.js +0 -1
  321. package/static/dist/5520.ff2cfd6b.async.js +0 -1
  322. package/static/dist/6431.c50479be.async.js +0 -1
  323. package/static/dist/6707.801b886b.async.js +0 -1
  324. package/static/dist/8826.2447a104.async.js +0 -1
  325. package/static/dist/layouts__index.a7a2bfe0.async.js +0 -1
  326. package/static/dist/preload_helper.0431c0f3.js +0 -1
  327. package/static/dist/src__pages__crontab__detail.b9c36808.async.js +0 -1
  328. package/static/dist/src__pages__crontab__index.fed99fd0.async.js +0 -1
  329. package/static/dist/src__pages__crontab__modal.f7041c7c.async.js +0 -1
  330. package/static/dist/src__pages__crontab__viewCreateModal.4d589f66.async.js +0 -1
  331. package/static/dist/src__pages__crontab__viewManageModal.0e317746.async.js +0 -1
  332. package/static/dist/src__pages__dashboard__index.b30f2f47.async.js +0 -1
  333. package/static/dist/src__pages__dependence__index.3d87ceac.async.js +0 -1
  334. package/static/dist/src__pages__dependence__logModal.0681830b.async.js +0 -1
  335. package/static/dist/src__pages__dependence__modal.11124896.async.js +0 -1
  336. package/static/dist/src__pages__diff__index.013b7c75.async.js +0 -1
  337. package/static/dist/src__pages__env__editNameModal.5d264b25.async.js +0 -1
  338. package/static/dist/src__pages__env__index.baa27d4e.async.js +0 -1
  339. package/static/dist/src__pages__env__modal.7f2ef1bc.async.js +0 -1
  340. package/static/dist/src__pages__error__index.f156b45e.async.js +0 -1
  341. package/static/dist/src__pages__initialization__index.e96d4ba8.async.js +0 -1
  342. package/static/dist/src__pages__log__index.e0978bae.async.js +0 -1
  343. package/static/dist/src__pages__script__editModal.cbf4ec0e.async.js +0 -1
  344. package/static/dist/src__pages__script__editNameModal.3e7e100d.async.js +0 -1
  345. package/static/dist/src__pages__script__index.2765d1b8.async.js +0 -1
  346. package/static/dist/src__pages__script__index.60b6f827.chunk.css +0 -1
  347. package/static/dist/src__pages__script__renameModal.5e987ef5.async.js +0 -1
  348. package/static/dist/src__pages__script__saveModal.3f9d23d6.async.js +0 -1
  349. package/static/dist/src__pages__script__setting.a535793a.async.js +0 -1
  350. package/static/dist/src__pages__setting__appModal.251cd14f.async.js +0 -1
  351. package/static/dist/src__pages__setting__checkUpdate.46efe057.async.js +0 -1
  352. package/static/dist/src__pages__setting__dependence.8a7a9529.async.js +0 -1
  353. package/static/dist/src__pages__setting__index.cc85fdfb.async.js +0 -1
  354. package/static/dist/src__pages__setting__loginLog.cea6056c.async.js +0 -1
  355. package/static/dist/src__pages__setting__notification.390fc905.async.js +0 -1
  356. package/static/dist/src__pages__setting__other.b22d2165.async.js +0 -1
  357. package/static/dist/src__pages__setting__security.598720a8.async.js +0 -1
  358. package/static/dist/src__pages__setting__systemLog.67406721.async.js +0 -1
  359. package/static/dist/src__pages__subscription__index.d0ab2abc.async.js +0 -1
  360. package/static/dist/src__pages__subscription__logModal.3864b37f.async.js +0 -1
  361. package/static/dist/src__pages__subscription__modal.3562c670.async.js +0 -1
  362. /package/static/dist/{4859.1b962b29.chunk.css → 292.1b962b29.chunk.css} +0 -0
@@ -98,7 +98,11 @@ function run() {
98
98
  const newEnvObject = JSON.parse(envStr);
99
99
  if (typeof newEnvObject === 'object' && newEnvObject !== null) {
100
100
  for (const key in newEnvObject) {
101
- if (Object.prototype.hasOwnProperty.call(newEnvObject, key)) {
101
+ if (
102
+ Object.prototype.hasOwnProperty.call(newEnvObject, key) &&
103
+ key !== 'NODE_PATH' &&
104
+ key !== 'QL_NODE_GLOBAL_PATH'
105
+ ) {
102
106
  process.env[key] = newEnvObject[key];
103
107
  }
104
108
  }
@@ -155,9 +159,13 @@ try {
155
159
 
156
160
  run();
157
161
 
158
- const { sendNotify } = require('./__ql_notify__.js');
159
162
  global.QLAPI = {
160
- notify: sendNotify,
163
+ notify(...args) {
164
+ // Keep notification dependencies out of ordinary script startup.
165
+ // require caches the module after the first notification.
166
+ const { sendNotify } = require('./__ql_notify__.js');
167
+ return sendNotify.apply(this, args);
168
+ },
161
169
  ...client,
162
170
  };
163
171
  } catch (error) {
@@ -129,10 +129,12 @@ try:
129
129
 
130
130
  run()
131
131
 
132
- from __ql_notify__ import send
133
-
134
132
  class BaseApi(Client):
135
133
  def notify(self, *args, **kwargs):
134
+ # Most scripts never send a notification. Python caches this
135
+ # module after the first call, including its channel dependencies.
136
+ from __ql_notify__ import send
137
+
136
138
  return send(*args, **kwargs)
137
139
 
138
140
  QLAPI = BaseApi()
package/shell/share.sh CHANGED
@@ -110,7 +110,7 @@ t() {
110
110
  fi
111
111
  [[ -z $msg ]] && msg="$key"
112
112
  # shellcheck disable=SC2059
113
- printf "$msg\n" "$@"
113
+ printf -- "$msg\n" "$@"
114
114
  }
115
115
 
116
116
  set_proxy() {
@@ -305,8 +305,13 @@ reload_pm2() {
305
305
  # Kill any existing node processes for qinglong
306
306
  pkill -f "node.*static/build/app.js" 2>/dev/null || true
307
307
 
308
- # Start node directly in the background
309
- nohup node static/build/app.js > $dir_log/qinglong.log 2>&1 &
308
+ # Start node directly in the background. In containers, keep application
309
+ # output on the container streams instead of duplicating Winston logs on disk.
310
+ if [[ "$QL_CONTAINER" == "true" ]]; then
311
+ nohup node static/build/app.js >/proc/1/fd/1 2>/proc/1/fd/2 &
312
+ else
313
+ nohup node static/build/app.js >$dir_log/qinglong.log 2>&1 &
314
+ fi
310
315
  local node_pid=$!
311
316
 
312
317
  t '已使用 Node.js 直接启动服务 (PID: %s)' "$node_pid"
@@ -363,9 +368,16 @@ format_timestamp() {
363
368
 
364
369
  get_env_array() {
365
370
  exported_variables=()
366
- while IFS= read -r line; do
367
- exported_variables+=("$line")
368
- done < <(grep '^export ' $file_env | awk '{print $2}' | cut -d= -f1)
371
+ # Preserve the legacy export-line/second-field rules without evaluating values.
372
+ local export_name_program='/^export / { name = $2; sub(/=.*/, "", name); print name }'
373
+ if [[ ${BASH_VERSINFO[0]} -ge 4 ]]; then
374
+ builtin mapfile -t exported_variables < <(awk "$export_name_program" "$file_env")
375
+ else
376
+ # macOS still ships Bash 3, which does not provide mapfile.
377
+ while IFS= read -r line; do
378
+ exported_variables+=("$line")
379
+ done < <(awk "$export_name_program" "$file_env")
380
+ fi
369
381
  }
370
382
 
371
383
  clear_env() {
@@ -406,15 +418,20 @@ run_task_after() {
406
418
  }
407
419
 
408
420
  handle_task_end() {
409
- local etime=$(date "+$time_format")
410
- local end_time=$(format_time "$time_format" "$etime")
411
- local end_timestamp=$(format_timestamp "$time_format" "$etime")
421
+ local etime end_time end_timestamp
422
+ if [[ $is_macos -ne 1 && $time_format == '%Y-%m-%d %H:%M:%S' ]]; then
423
+ IFS='|' read -r end_time end_timestamp < <(date "+$time_format|%s")
424
+ else
425
+ etime=$(date "+$time_format")
426
+ end_time=$(format_time "$time_format" "$etime")
427
+ end_timestamp=$(format_timestamp "$time_format" "$etime")
428
+ fi
412
429
  local diff_time=$(($end_timestamp - $begin_timestamp))
413
430
  local exit_code="${_task_exit_code:-0}"
414
431
  [[ "$diff_time" == 0 ]] && diff_time=1
415
432
 
416
433
  if [[ $ID ]]; then
417
- local error=$(update_cron "\"$ID\"" "1" "$$" "$log_path" "$begin_timestamp" "$diff_time")
434
+ local error=$(update_cron "\"$ID\"" "1" "$$" "$log_path" "$begin_timestamp" "$diff_time" "$exit_code")
418
435
  if [[ $error ]]; then
419
436
  error_message=", 状态更新失败(${error})"
420
437
  fi
package/shell/start.sh CHANGED
@@ -74,7 +74,7 @@ if [[ $command != "reload" ]]; then
74
74
  ;;
75
75
  esac
76
76
 
77
- npm install -g pnpm@8.3.1 pm2 ts-node
77
+ npm install -g pnpm@8.3.1 pm2 ts-node typescript@5
78
78
  fi
79
79
 
80
80
  export PYTHON_SHORT_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
@@ -91,8 +91,11 @@ if [[ $command != "reload" ]]; then
91
91
  pip3 install --prefix ${PYTHON_HOME} requests
92
92
  fi
93
93
 
94
- cd ${QL_DIR}
95
- cp -f .env.example .env
94
+ cd "${QL_DIR}"
95
+ if [[ ! -e .env ]]; then
96
+ # Preserve user configuration, including a file created concurrently.
97
+ (umask 077; set -C; cat .env.example > .env)
98
+ fi
96
99
  chmod 777 ${QL_DIR}/shell/*.sh
97
100
 
98
101
  . ${QL_DIR}/shell/share.sh
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Fork from the current Bash state: an external `bash -c` would lose private
4
+ # before-hook variables, arrays and functions used by sourced Shell scripts.
5
+ run_task_command() {
6
+ local timeout_seconds
7
+ if [[ -z ${command_timeout_time:-} ]]; then
8
+ "$@"
9
+ return $?
10
+ fi
11
+ timeout_seconds=$(awk -v value="$command_timeout_time" 'BEGIN {
12
+ if (value !~ /^([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+-]?[0-9]+)?[smhd]?$/) exit 1
13
+ unit = substr(value, length(value), 1)
14
+ factor = unit == "d" ? 86400 : unit == "h" ? 3600 : unit == "m" ? 60 : 1
15
+ printf "%.9f", (value + 0) * factor
16
+ }') || { printf 'Invalid task timeout: %s\n' "$command_timeout_time" >&2; return 125; }
17
+ if [[ $timeout_seconds == '0.000000000' ]]; then
18
+ "$@"
19
+ return $?
20
+ fi
21
+ (
22
+ timeout_dir=$(mktemp -d "${TMPDIR:-/tmp}/ql-task-timeout.XXXXXXXX") || exit 125
23
+ # Both children get private process groups. The timer and the wrapper must
24
+ # survive terminating the task, and descendants must not outlive a timeout.
25
+ set -m
26
+ ( set +m; "$@" ) <&0 &
27
+ timeout_worker=$!
28
+ (
29
+ set +m
30
+ : > "$timeout_dir/ready"
31
+ sleep "$timeout_seconds" || exit 125
32
+ : > "$timeout_dir/expired"
33
+ kill -TERM -- "-$timeout_worker" 2>/dev/null || :
34
+ sleep 0.5
35
+ kill -KILL -- "-$timeout_worker" 2>/dev/null || :
36
+ ) &
37
+ timeout_watcher=$!
38
+ set +m
39
+ trap 'kill -KILL -- "-$timeout_watcher" 2>/dev/null || :
40
+ if kill -TERM -- "-$timeout_worker" 2>/dev/null; then sleep 0.1; fi
41
+ kill -KILL -- "-$timeout_worker" 2>/dev/null || :
42
+ wait "$timeout_worker" 2>/dev/null || :
43
+ wait "$timeout_watcher" 2>/dev/null || :
44
+ rm -rf -- "$timeout_dir"' EXIT
45
+ trap 'exit 130' INT
46
+ trap 'exit 143' TERM
47
+ trap 'exit 129' HUP
48
+ trap 'exit 131' QUIT
49
+ # Do not clean up a timer whose process group has not initialized yet.
50
+ while [[ ! -f "$timeout_dir/ready" ]]; do
51
+ kill -0 "$timeout_watcher" 2>/dev/null || exit 125
52
+ sleep 0.001
53
+ done
54
+ wait "$timeout_worker"
55
+ timeout_code=$?
56
+ if [[ -f "$timeout_dir/expired" ]]; then
57
+ # Let the timer finish escalation even if the task leader exited first.
58
+ wait "$timeout_watcher" 2>/dev/null || :
59
+ exit 124
60
+ fi
61
+ exit "$timeout_code"
62
+ )
63
+ }
package/shell/task.sh CHANGED
@@ -3,6 +3,7 @@
3
3
  dir_shell=$QL_DIR/shell
4
4
  . $dir_shell/share.sh
5
5
  . $dir_shell/api.sh
6
+ . $dir_shell/task-timeout.sh
6
7
 
7
8
  trap 'single_hanle SIGINT' INT
8
9
  trap 'single_hanle SIGTERM' TERM
@@ -18,6 +19,12 @@ single_hanle() {
18
19
  exit 1
19
20
  }
20
21
 
22
+ run_shell_script() {
23
+ # Preserve inherited variables/functions, but contain exit, exec and shell
24
+ # options so the task wrapper can run after hooks and report completion.
25
+ ( . "$@" )
26
+ }
27
+
21
28
  define_program() {
22
29
  local file_param=$1
23
30
  if [[ $file_param == *.js ]] || [[ $file_param == *.mjs ]]; then
@@ -25,7 +32,7 @@ define_program() {
25
32
  elif [[ $file_param == *.py ]] || [[ $file_param == *.pyc ]]; then
26
33
  which_program="python3"
27
34
  elif [[ $file_param == *.sh ]]; then
28
- which_program="."
35
+ which_program="run_shell_script"
29
36
  elif [[ $file_param == *.ts ]]; then
30
37
  which_program="ts-node-transpile-only"
31
38
  else
@@ -52,8 +59,14 @@ handle_log_path() {
52
59
  fi
53
60
  fi
54
61
 
55
- time=$(date "+$mtime_format")
56
- log_time=$(format_log_time "$mtime_format" "$time")
62
+ if [[ $is_macos -ne 1 && $mtime_format == '%Y-%m-%d %H:%M:%S.%3N' ]]; then
63
+ # Render both representations from one clock snapshot, without parsing it
64
+ # again in a second date process.
65
+ IFS='|' read -r time log_time < <(date "+$mtime_format|%Y-%m-%d-%H-%M-%S-%3N")
66
+ else
67
+ time=$(date "+$mtime_format")
68
+ log_time=$(format_log_time "$mtime_format" "$time")
69
+ fi
57
70
  if [[ -z $log_name ]]; then
58
71
  log_dir_tmp="${file_param##*/}"
59
72
  if [[ $file_param =~ "/" ]]; then
@@ -100,11 +113,6 @@ format_params() {
100
113
  mtime_format="%Y-%m-%d %H:%M:%S.%3N"
101
114
  fi
102
115
  timeoutCmd=""
103
- if [[ $command_timeout_time ]]; then
104
- if type timeout &>/dev/null; then
105
- timeoutCmd="timeout --foreground -s 2 -k 10s $command_timeout_time "
106
- fi
107
- fi
108
116
  # params=$(echo "$@" | sed -E 's/([^ ])&([^ ])/\1\\\&\2/g')
109
117
 
110
118
  # 分割 task 内置参数和脚本参数
@@ -124,7 +132,11 @@ format_params() {
124
132
  }
125
133
 
126
134
  init_begin_time() {
127
- begin_time=$(format_time "$time_format" "$time")
135
+ if [[ $is_macos -ne 1 && $mtime_format == '%Y-%m-%d %H:%M:%S.%3N' && $time_format == '%Y-%m-%d %H:%M:%S' ]]; then
136
+ begin_time=${time%.*}
137
+ else
138
+ begin_time=$(format_time "$time_format" "$time")
139
+ fi
128
140
  begin_timestamp=$(format_timestamp "$time_format" "$time")
129
141
  }
130
142
 
package/shell/update.sh CHANGED
@@ -211,6 +211,60 @@ run_extra_shell() {
211
211
  fi
212
212
  }
213
213
 
214
+ ## 查看青龙服务日志
215
+ show_service_logs() {
216
+ local lines="15"
217
+ local no_stream="false"
218
+ while [[ $# -gt 0 ]]; do
219
+ case "$1" in
220
+ --lines)
221
+ if [[ ! "${2:-}" =~ ^[0-9]+$ ]]; then
222
+ echo "ql log: --lines requires a non-negative integer" >&2
223
+ return 2
224
+ fi
225
+ lines="$2"
226
+ shift 2
227
+ ;;
228
+ --lines=*)
229
+ lines="${1#--lines=}"
230
+ if [[ ! "$lines" =~ ^[0-9]+$ ]]; then
231
+ echo "ql log: --lines requires a non-negative integer" >&2
232
+ return 2
233
+ fi
234
+ shift
235
+ ;;
236
+ --nostream)
237
+ no_stream="true"
238
+ shift
239
+ ;;
240
+ *)
241
+ echo "ql log: unknown option: $1" >&2
242
+ return 2
243
+ ;;
244
+ esac
245
+ done
246
+
247
+ local system_log_dir="$dir_data/syslog"
248
+ local latest_system_log
249
+ latest_system_log=$(ls -1t "$system_log_dir"/*.log* 2>/dev/null | head -n 1)
250
+ if [[ "$lines" != "0" ]] && [[ -f "$latest_system_log" ]]; then
251
+ tail -n "$lines" "$latest_system_log"
252
+ fi
253
+
254
+ if [[ "$no_stream" == "true" ]]; then
255
+ if [[ -z "$latest_system_log" ]]; then
256
+ echo "ql log: no system log found in $system_log_dir" >&2
257
+ return 1
258
+ fi
259
+ return 0
260
+ fi
261
+
262
+ # Winston writes the active runtime log by date. Follow the filename so
263
+ # size-based rotations are handled without involving the PM2 log files.
264
+ local current_system_log="$system_log_dir/$(date +%F).log"
265
+ tail -n 0 --retry -F "$current_system_log"
266
+ }
267
+
214
268
  ## 脚本用法
215
269
  usage() {
216
270
  t "$cmd_update 命令使用方法:"
@@ -221,105 +275,52 @@ usage() {
221
275
  echo -e "5. $cmd_update rmlog <days> # 删除旧日志"
222
276
  echo -e "6. $cmd_update bot # 启动tg-bot"
223
277
  echo -e "7. $cmd_update check # 检测青龙环境并修复"
224
- echo -e "8. $cmd_update resetlet # 重置登录错误次数"
225
- echo -e "9. $cmd_update resettfa # 禁用两步登录"
226
- echo -e "10. $cmd_update resetpwd # 修改登录密码"
227
- echo -e "11. $cmd_update resetname # 修改登录用户名"
278
+ echo -e "8. $cmd_update log [--lines <n>] [--nostream] # 查看青龙运行日志"
279
+ echo -e "9. $cmd_update resetlet # 重置登录错误次数"
280
+ echo -e "10. $cmd_update resettfa # 禁用两步登录"
281
+ echo -e "11. $cmd_update resetpwd # 修改登录密码"
282
+ echo -e "12. $cmd_update resetname # 修改登录用户名"
228
283
  }
229
284
 
230
285
  reload_qinglong() {
231
- echo -e "[reload_qinglong] deleting Triggered at $(date)" >>${dir_log}/reload.log
232
- sleep 3
233
- delete_pm2
234
- echo -e "[reload_qinglong] deleted Triggered at $(date)" >>${dir_log}/reload.log
235
-
236
286
  local reload_target="${1}"
237
- local primary_branch="master"
238
- if [[ "${QL_BRANCH}" == "develop" ]] || [[ "${QL_BRANCH}" == "debian" ]] || [[ "${QL_BRANCH}" == "debian-dev" ]]; then
239
- primary_branch="${QL_BRANCH}"
240
- fi
241
-
242
287
  if [[ "$reload_target" == 'system' ]]; then
243
- rm -rf ${dir_root}/back ${dir_root}/cli ${dir_root}/docker ${dir_root}/sample ${dir_root}/shell ${dir_root}/src
244
- mv -f ${dir_tmp}/qinglong-${primary_branch}/* ${dir_root}/
245
- rm -rf $dir_static/*
246
- mv -f ${dir_tmp}/qinglong-static-${primary_branch}/* ${dir_static}/
247
- cp -f $file_config_sample $dir_config/config.sample.sh
288
+ QlPort="${ql_port:-${QlPort:-5700}}" QlBaseUrl="${ql_base_url:-${QlBaseUrl:-/}}" node "$dir_shell/upgrade.cjs" reload
289
+ return $?
248
290
  fi
249
291
 
292
+ # Data import and a plain service restart retain their existing behavior.
293
+ echo -e "[reload_qinglong] deleting Triggered at $(date)" >>"${dir_log}/reload.log"
294
+ sleep 3
295
+ delete_pm2
250
296
  if [[ "$reload_target" == 'data' ]]; then
251
- rm -rf ${dir_data}/*
252
- mv -f ${dir_tmp}/data/* ${dir_data}/
297
+ rm -rf "${dir_data:?}"/*
298
+ mv -f "$dir_tmp"/data/* "$dir_data"/ || return $?
253
299
  fi
254
- echo -e "[reload_qinglong] starting Triggered at $(date)" >>${dir_log}/reload.log
255
300
  reload_pm2
256
- echo -e "[reload_qinglong] started Triggered at $(date)\n" >>${dir_log}/reload.log
257
301
  }
258
302
 
259
303
  ## 更新 qinglong
260
304
  update_qinglong() {
261
- rm -rf ${dir_tmp}/*
262
305
  local mirror="gitee"
263
- local downloadQLUrl="https://gitee.com/whyour/qinglong/repository/archive"
264
- local downloadStaticUrl="https://gitee.com/whyour/qinglong-static/repository/archive"
265
- local githubStatus=$(curl -s --noproxy "*" -m 2 -IL "https://google.com" | grep 200)
266
- if [[ ! -z $githubStatus ]]; then
306
+ if curl --fail --silent --noproxy "*" --max-time 2 --head "https://github.com" >/dev/null; then
267
307
  mirror="github"
268
- downloadQLUrl="https://github.com/whyour/qinglong/archive/refs/heads"
269
- downloadStaticUrl="https://github.com/whyour/qinglong-static/archive/refs/heads"
270
- fi
271
- t '使用 %s 源更新...\n' "${mirror}"
272
-
273
- local primary_branch="master"
274
- if [[ "${QL_BRANCH}" == "develop" ]] || [[ "${QL_BRANCH}" == "debian" ]] || [[ "${QL_BRANCH}" == "debian-dev" ]]; then
275
- primary_branch="${QL_BRANCH}"
276
- fi
277
-
278
- wget -cqO "${dir_tmp}/ql.zip" "${downloadQLUrl}/${primary_branch}.zip"
279
- exit_status=$?
280
-
281
- if [[ $exit_status -eq 0 ]]; then
282
- t '更新青龙源文件成功...\n'
283
-
284
- unzip -oq ${dir_tmp}/ql.zip -d ${dir_tmp}
285
-
286
- update_qinglong_static
287
- else
288
- t '更新青龙源文件失败,请检查网络...\n'
289
308
  fi
309
+ t '使用 %s 源更新...\n' "$mirror"
310
+ QlPort="${ql_port:-${QlPort:-5700}}" QlBaseUrl="${ql_base_url:-${QlBaseUrl:-/}}" node "$dir_shell/upgrade.cjs" update "$mirror" "$needRestart"
290
311
  }
291
312
 
292
- update_qinglong_static() {
293
- wget -cqO "${dir_tmp}/static.zip" "${downloadStaticUrl}/${primary_branch}.zip"
294
- exit_status=$?
295
-
296
- if [[ $exit_status -eq 0 ]]; then
297
- t '更新青龙静态资源成功...\n'
298
- unzip -oq ${dir_tmp}/static.zip -d ${dir_tmp}
299
-
300
- check_update_dep
313
+ # Preserve the updater's status through both tee and the final timing output.
314
+ run_update_logged() (
315
+ set -o pipefail
316
+ if [[ "$real_time" == 'true' ]]; then
317
+ "$@"
318
+ elif [[ "$no_tee" == 'true' ]]; then
319
+ "$@" >>"$file_path" 2>&1
301
320
  else
302
- t '更新青龙静态资源失败,请检查网络...\n'
321
+ "$@" 2>&1 | tee -a "$file_path"
303
322
  fi
304
- }
305
-
306
- check_update_dep() {
307
- t '\n开始检测依赖...\n'
308
- if [[ $(diff $dir_root/package.json ${dir_tmp}/qinglong-${primary_branch}/package.json) ]]; then
309
- npm_install_2 "${dir_tmp}/qinglong-${primary_branch}"
310
- fi
311
-
312
- if [[ $exit_status -eq 0 ]]; then
313
- t '\n依赖检测安装成功...\n'
314
- t '更新包下载成功...\n'
315
-
316
- if [[ "$needRestart" == 'true' ]]; then
317
- reload_qinglong "system"
318
- fi
319
- else
320
- t '\n依赖检测安装失败,请检查网络...\n'
321
- fi
322
- }
323
+ )
323
324
 
324
325
  ## 对比脚本
325
326
  diff_scripts() {
@@ -374,23 +375,19 @@ gen_list_repo() {
374
375
 
375
376
  cd ${repo_path}
376
377
 
377
- local cmd="find ."
378
- local index=0
379
- if [[ $6 ]]; then
380
- file_extensions="$6"
381
- if [[ $file_extensions =~ "|" ]]; then
382
- file_extensions=$(echo $file_extensions | sed 's/|/ /g')
378
+ local extension_string="${6:-$file_extensions}"
379
+ extension_string="${extension_string//|/ }"
380
+ extension_string="${extension_string//$'\n'/ }"
381
+ local -a extensions=() find_args=()
382
+ IFS=$' \t\n' read -r -a extensions <<< "$extension_string"
383
+ local extension
384
+ for extension in "${extensions[@]}"; do
385
+ if [[ ${#find_args[@]} -gt 0 ]]; then
386
+ find_args+=(-o)
383
387
  fi
384
- fi
385
- for extension in $file_extensions; do
386
- if [[ $index -eq 0 ]]; then
387
- cmd="${cmd} -name \"*.${extension}\""
388
- else
389
- cmd="${cmd} -o -name \"*.${extension}\""
390
- fi
391
- let index+=1
388
+ find_args+=(-name "*.${extension}")
392
389
  done
393
- files=$(eval $cmd | sed 's/^..//')
390
+ files=$(find . "${find_args[@]}" | sed 's/^..//')
394
391
  if [[ $path ]]; then
395
392
  files=$(echo "$files" | egrep "$path")
396
393
  fi
@@ -403,7 +400,7 @@ gen_list_repo() {
403
400
 
404
401
  if [[ $dependence ]]; then
405
402
  cd ${repo_path}
406
- results=$(eval $cmd | sed 's/^..//' | egrep "$dependence")
403
+ results=$(find . "${find_args[@]}" | sed 's/^..//' | egrep "$dependence")
407
404
  for _file in ${results}; do
408
405
  file_path=$(dirname $_file)
409
406
  make_dir "${dir_scripts}/${uniq_path}/${file_path}"
@@ -471,6 +468,12 @@ main() {
471
468
  local p8="${8}"
472
469
  local p9="${9}"
473
470
  local p10="${10}"
471
+
472
+ if [[ "$p1" == "log" ]]; then
473
+ show_service_logs "${@:2}"
474
+ return 0
475
+ fi
476
+
474
477
  local log_dir="${p1}"
475
478
  make_dir "$dir_log/$log_dir"
476
479
  local log_time=$(date "+%Y-%m-%d-%H-%M-%S")
@@ -497,14 +500,17 @@ main() {
497
500
 
498
501
  [[ $ID ]] && update_cron "\"$ID\"" "0" "$$" "$log_path" "$begin_timestamp"
499
502
 
503
+ local command_status=0
500
504
  case $p1 in
501
505
  update)
502
506
  fix_config
503
507
  local needRestart=${p2:-"true"}
504
- eval update_qinglong $cmd
508
+ run_update_logged update_qinglong
509
+ command_status=$?
505
510
  ;;
506
511
  reload)
507
- eval reload_qinglong "$p2" $cmd
512
+ run_update_logged reload_qinglong "$p2"
513
+ command_status=$?
508
514
  ;;
509
515
  extra)
510
516
  eval run_extra_shell $cmd
@@ -563,9 +569,9 @@ main() {
563
569
  if [[ "$p1" != "repo" ]] && [[ "$p1" != "raw" ]]; then
564
570
  eval echo -e "\\\n\#\# 执行结束... $end_time 耗时 $diff_time 秒     " $cmd
565
571
  fi
572
+ return "$command_status"
566
573
  }
567
574
 
568
575
  import_config "$@"
569
576
  main "$@"
570
-
571
- exit 0
577
+ exit $?
@@ -0,0 +1,8 @@
1
+ // The image updater and local CLI share one implementation and build contract.
2
+ const upgrade = require('../cli/src/internal/maintenance/upgradeArtifacts.cjs');
3
+ module.exports = upgrade;
4
+ if (require.main === module)
5
+ upgrade.main().catch((error) => {
6
+ console.error(`更新失败: ${error.message}`);
7
+ process.exitCode = 1;
8
+ });
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const express_1 = require("express");
4
+ const celebrate_1 = require("celebrate");
5
+ const trustProxy_1 = require("../shared/trustProxy");
6
+ const route = (0, express_1.Router)();
7
+ exports.default = (app) => {
8
+ app.use('/system/client-ip', route);
9
+ route.get('/config', async (req, res, next) => {
10
+ try {
11
+ res.send({ code: 200, data: await (0, trustProxy_1.getTrustProxyConfig)() });
12
+ }
13
+ catch (error) {
14
+ next(error);
15
+ }
16
+ });
17
+ route.put('/config', (0, celebrate_1.celebrate)({
18
+ body: celebrate_1.Joi.object({
19
+ trustProxy: celebrate_1.Joi.string().max(500).required(),
20
+ }),
21
+ }), async (req, res) => {
22
+ try {
23
+ const data = await (0, trustProxy_1.updateTrustProxy)(req.body.trustProxy);
24
+ res.send({ code: 200, data });
25
+ }
26
+ catch (error) {
27
+ res.send({
28
+ code: 400,
29
+ message: error instanceof Error ? error.message : '配置更新失败',
30
+ });
31
+ }
32
+ });
33
+ route.get('/diagnose', async (req, res, next) => {
34
+ try {
35
+ res.send({ code: 200, data: await (0, trustProxy_1.diagnoseClientIp)(req) });
36
+ }
37
+ catch (error) {
38
+ next(error);
39
+ }
40
+ });
41
+ };
42
+ //# sourceMappingURL=clientIp.js.map
@@ -31,11 +31,11 @@ const typedi_1 = require("typedi");
31
31
  const config_1 = __importDefault(require("../config"));
32
32
  const fs = __importStar(require("fs/promises"));
33
33
  const celebrate_1 = require("celebrate");
34
- const path_1 = require("path");
35
34
  const const_1 = require("../config/const");
36
35
  const i18n_1 = require("../shared/i18n");
37
36
  const config_2 = __importDefault(require("../services/config"));
38
37
  const utils_1 = require("../shared/utils");
38
+ const fileAccess_1 = require("../shared/fileAccess");
39
39
  const route = (0, express_1.Router)();
40
40
  exports.default = (app) => {
41
41
  app.use('/configs', route);
@@ -85,20 +85,11 @@ exports.default = (app) => {
85
85
  const logger = typedi_1.Container.get('logger');
86
86
  try {
87
87
  const { name, content } = req.body;
88
- // Resolve path first to prevent traversal attacks
89
- let basePath = config_1.default.configPath;
90
88
  if (name.startsWith('data/scripts/')) {
91
- basePath = (0, path_1.join)(config_1.default.rootPath, 'data/scripts');
92
- }
93
- const cleanName = name.replace(/^data\/scripts\//, '');
94
- const resolvedPath = (0, path_1.join)(basePath, cleanName);
95
- const normalized = (0, path_1.join)(resolvedPath);
96
- // Verify the resolved path stays within allowed directory
97
- if (!normalized.startsWith(basePath)) {
98
- return res.send({ code: 403, message: (0, i18n_1.t)('文件路径无效') });
89
+ return res.send({ code: 403, message: (0, i18n_1.t)('文件无法访问') });
99
90
  }
100
- // Check blacklist on actual filename (not user input)
101
- if (config_1.default.blackFileList.includes((0, path_1.basename)(normalized))) {
91
+ const normalized = (0, fileAccess_1.resolveFileAccess)(config_1.default.configPath, [name], config_1.default.blackFileList);
92
+ if (!normalized) {
102
93
  return res.send({ code: 403, message: (0, i18n_1.t)('文件无法访问') });
103
94
  }
104
95
  await (0, utils_1.writeFileWithLock)(normalized, content);
@@ -108,14 +99,11 @@ exports.default = (app) => {
108
99
  return next(e);
109
100
  }
110
101
  });
111
- route.get('/:file', async (req, res, next) => {
112
- try {
113
- const configService = typedi_1.Container.get(config_2.default);
114
- await configService.getFile(req.params.file, res);
115
- }
116
- catch (e) {
117
- return next(e);
118
- }
102
+ route.get('/:file', (req, res) => {
103
+ return res.send({
104
+ code: 410,
105
+ message: (0, i18n_1.t)('接口已下线,请使用 /configs/detail 接口'),
106
+ });
119
107
  });
120
108
  };
121
109
  //# sourceMappingURL=config.js.map