mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-11 19:05:20 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc92ba47f6 | ||
|
|
dfb70abbe3 | ||
|
|
d53437d169 | ||
|
|
d526602d19 | ||
|
|
91b44914f6 | ||
|
|
4f6c93cc1c | ||
|
|
e326d89571 | ||
|
|
5f0dafa010 | ||
|
|
dc0b3f2eb2 | ||
|
|
3db716763d | ||
|
|
fae226745e | ||
|
|
9330650163 | ||
|
|
073de76a4a | ||
|
|
c61d1aa828 | ||
|
|
33fa3aca99 | ||
|
|
c772fc9527 | ||
|
|
c5d2aa3aba | ||
|
|
02a05f06bd | ||
|
|
3b0f55caf4 | ||
|
|
6a3dd4f83c | ||
|
|
177cd3de81 | ||
|
|
d473c3ae88 | ||
|
|
ee2fbe5335 | ||
|
|
48abf44ceb | ||
|
|
03c7031a3c |
@@ -9,15 +9,13 @@ on:
|
|||||||
- "develop"
|
- "develop"
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
schedule:
|
|
||||||
- cron: "00 20 * * *"
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
code_gitlab:
|
code_gitlab:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: Yikun/hub-mirror-action@master
|
- uses: Yikun/hub-mirror-action@master
|
||||||
@@ -32,7 +30,7 @@ jobs:
|
|||||||
code_gitee:
|
code_gitee:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: Yikun/hub-mirror-action@master
|
- uses: Yikun/hub-mirror-action@master
|
||||||
@@ -47,12 +45,12 @@ jobs:
|
|||||||
build-static:
|
build-static:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: pnpm/action-setup@v3
|
- uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: "8.3.1"
|
version: "8.3.1"
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
|
|
||||||
@@ -83,7 +81,7 @@ jobs:
|
|||||||
needs: build-static
|
needs: build-static
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: Yikun/hub-mirror-action@master
|
- uses: Yikun/hub-mirror-action@master
|
||||||
@@ -99,7 +97,7 @@ jobs:
|
|||||||
needs: build-static
|
needs: build-static
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: Yikun/hub-mirror-action@master
|
- uses: Yikun/hub-mirror-action@master
|
||||||
@@ -112,6 +110,7 @@ jobs:
|
|||||||
force_update: true
|
force_update: true
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||||
needs: build-static
|
needs: build-static
|
||||||
|
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
@@ -121,14 +120,21 @@ jobs:
|
|||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: pnpm/action-setup@v3
|
- uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: "8.3.1"
|
version: "8.3.1"
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
|
|
||||||
|
- name: Read version from version.yaml
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
VERSION=$(grep '^version:' version.yaml | awk '{print $2}')
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "Version: $VERSION"
|
||||||
|
|
||||||
- name: Setup timezone
|
- name: Setup timezone
|
||||||
uses: szenius/set-timezone@v2.0
|
uses: szenius/set-timezone@v2.0
|
||||||
with:
|
with:
|
||||||
@@ -154,19 +160,13 @@ jobs:
|
|||||||
images: |
|
images: |
|
||||||
${{ github.repository }}
|
${{ github.repository }}
|
||||||
ghcr.io/${{ github.repository }}
|
ghcr.io/${{ github.repository }}
|
||||||
# generate Docker tags based on the following events/attributes
|
|
||||||
# nightly, master, pr-2, 1.2.3, 1.2, 1
|
|
||||||
flavor: |
|
flavor: |
|
||||||
latest=false
|
latest=false
|
||||||
tags: |
|
tags: |
|
||||||
type=schedule,pattern=nightly
|
type=ref,event=branch,enable=${{ github.ref == format('refs/heads/{0}', 'develop') }}
|
||||||
type=edge
|
|
||||||
type=ref,event=pr
|
|
||||||
type=ref,event=branch,enable=${{ github.ref != format('refs/heads/{0}', 'master') }}
|
|
||||||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
||||||
|
type=raw,value=${{ steps.version.outputs.version }},enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
type=semver,pattern={{major}}
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
@@ -208,14 +208,21 @@ jobs:
|
|||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: pnpm/action-setup@v3
|
- uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: "8.3.1"
|
version: "8.3.1"
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
|
|
||||||
|
- name: Read version from version.yaml
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
VERSION=$(grep '^version:' version.yaml | awk '{print $2}')
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "Version: $VERSION"
|
||||||
|
|
||||||
- name: Setup timezone
|
- name: Setup timezone
|
||||||
uses: szenius/set-timezone@v2.0
|
uses: szenius/set-timezone@v2.0
|
||||||
with:
|
with:
|
||||||
@@ -254,7 +261,9 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
file: ./docker/310.Dockerfile
|
file: ./docker/310.Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: whyour/qinglong:python3.10
|
tags: |
|
||||||
|
whyour/qinglong:python3.10
|
||||||
|
whyour/qinglong:${{ steps.version.outputs.version }}-python3.10
|
||||||
cache-from: type=registry,ref=whyour/qinglong:cache-python3.10
|
cache-from: type=registry,ref=whyour/qinglong:cache-python3.10
|
||||||
cache-to: type=registry,ref=whyour/qinglong:cache-python3.10,mode=max
|
cache-to: type=registry,ref=whyour/qinglong:cache-python3.10,mode=max
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default (app: Router) => {
|
|||||||
searchValue: Joi.string().optional().allow(''),
|
searchValue: Joi.string().optional().allow(''),
|
||||||
type: Joi.string().optional().allow(''),
|
type: Joi.string().optional().allow(''),
|
||||||
status: Joi.string().optional().allow(''),
|
status: Joi.string().optional().allow(''),
|
||||||
}),
|
}).unknown(true),
|
||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
const logger: Logger = Container.get('logger');
|
const logger: Logger = Container.get('logger');
|
||||||
|
|||||||
+6
-4
@@ -29,7 +29,7 @@ export default (app: Router) => {
|
|||||||
celebrate({
|
celebrate({
|
||||||
query: Joi.object({
|
query: Joi.object({
|
||||||
path: Joi.string().optional().allow(''),
|
path: Joi.string().optional().allow(''),
|
||||||
}),
|
}).unknown(true),
|
||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
const logger: Logger = Container.get('logger');
|
const logger: Logger = Container.get('logger');
|
||||||
@@ -79,7 +79,7 @@ export default (app: Router) => {
|
|||||||
query: Joi.object({
|
query: Joi.object({
|
||||||
path: Joi.string().optional().allow(''),
|
path: Joi.string().optional().allow(''),
|
||||||
file: Joi.string().required(),
|
file: Joi.string().required(),
|
||||||
}),
|
}).unknown(true),
|
||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
@@ -103,7 +103,7 @@ export default (app: Router) => {
|
|||||||
}),
|
}),
|
||||||
query: Joi.object({
|
query: Joi.object({
|
||||||
path: Joi.string().optional().allow(''),
|
path: Joi.string().optional().allow(''),
|
||||||
}),
|
}).unknown(true),
|
||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
@@ -129,7 +129,8 @@ export default (app: Router) => {
|
|||||||
content: Joi.string().optional().allow(''),
|
content: Joi.string().optional().allow(''),
|
||||||
originFilename: Joi.string().optional().allow(''),
|
originFilename: Joi.string().optional().allow(''),
|
||||||
directory: Joi.string().optional().allow(''),
|
directory: Joi.string().optional().allow(''),
|
||||||
}),
|
file: Joi.string().optional().allow(''),
|
||||||
|
}).unknown(true),
|
||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
@@ -175,6 +176,7 @@ export default (app: Router) => {
|
|||||||
path,
|
path,
|
||||||
`${originFilename.replace(/\//g, '')}`,
|
`${originFilename.replace(/\//g, '')}`,
|
||||||
);
|
);
|
||||||
|
await fs.mkdir(path, { recursive: true });
|
||||||
const filePath = join(path, `${filename.replace(/\//g, '')}`);
|
const filePath = join(path, `${filename.replace(/\//g, '')}`);
|
||||||
const fileExists = await fileExist(filePath);
|
const fileExists = await fileExist(filePath);
|
||||||
if (fileExists) {
|
if (fileExists) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Container } from 'typedi';
|
|||||||
import { Logger } from 'winston';
|
import { Logger } from 'winston';
|
||||||
import SubscriptionService from '../services/subscription';
|
import SubscriptionService from '../services/subscription';
|
||||||
import { celebrate, Joi } from 'celebrate';
|
import { celebrate, Joi } from 'celebrate';
|
||||||
import { CronExpressionParser } from 'cron-parser';
|
import CronExpressionParser from 'cron-parser';
|
||||||
const route = Router();
|
const route = Router();
|
||||||
|
|
||||||
export default (app: Router) => {
|
export default (app: Router) => {
|
||||||
|
|||||||
@@ -426,6 +426,24 @@ export default (app: Router) => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
route.put(
|
||||||
|
'/config/global-ssh-key',
|
||||||
|
celebrate({
|
||||||
|
body: Joi.object({
|
||||||
|
globalSshKey: Joi.string().allow('').allow(null),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
|
try {
|
||||||
|
const systemService = Container.get(SystemService);
|
||||||
|
const result = await systemService.updateGlobalSshKey(req.body);
|
||||||
|
res.send(result);
|
||||||
|
} catch (e) {
|
||||||
|
return next(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
route.put(
|
route.put(
|
||||||
'/config/dependence-clean',
|
'/config/dependence-clean',
|
||||||
celebrate({
|
celebrate({
|
||||||
|
|||||||
+3
-2
@@ -8,7 +8,7 @@ import path from 'path';
|
|||||||
import { v4 as uuidV4 } from 'uuid';
|
import { v4 as uuidV4 } from 'uuid';
|
||||||
import rateLimit from 'express-rate-limit';
|
import rateLimit from 'express-rate-limit';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
import { isDemoEnv } from '../config/util';
|
import { isDemoEnv, getToken } from '../config/util';
|
||||||
const route = Router();
|
const route = Router();
|
||||||
|
|
||||||
const storage = multer.diskStorage({
|
const storage = multer.diskStorage({
|
||||||
@@ -56,7 +56,8 @@ export default (app: Router) => {
|
|||||||
const logger: Logger = Container.get('logger');
|
const logger: Logger = Container.get('logger');
|
||||||
try {
|
try {
|
||||||
const userService = Container.get(UserService);
|
const userService = Container.get(UserService);
|
||||||
await userService.logout(req.platform);
|
const token = getToken(req);
|
||||||
|
await userService.logout(req.platform, token);
|
||||||
res.send({ code: 200 });
|
res.send({ code: 200 });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return next(e);
|
return next(e);
|
||||||
|
|||||||
@@ -64,6 +64,19 @@ if (!process.env.QL_DIR) {
|
|||||||
|
|
||||||
const lastVersionFile = `https://qn.whyour.cn/version.yaml`;
|
const lastVersionFile = `https://qn.whyour.cn/version.yaml`;
|
||||||
|
|
||||||
|
// Get and normalize QlBaseUrl
|
||||||
|
let baseUrl = process.env.QlBaseUrl || '';
|
||||||
|
if (baseUrl) {
|
||||||
|
// Ensure it starts with /
|
||||||
|
if (!baseUrl.startsWith('/')) {
|
||||||
|
baseUrl = `/${baseUrl}`;
|
||||||
|
}
|
||||||
|
// Remove trailing slash for consistency in route definitions
|
||||||
|
if (baseUrl.endsWith('/')) {
|
||||||
|
baseUrl = baseUrl.slice(0, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const rootPath = process.env.QL_DIR as string;
|
const rootPath = process.env.QL_DIR as string;
|
||||||
const envFound = dotenv.config({ path: path.join(rootPath, '.env') });
|
const envFound = dotenv.config({ path: path.join(rootPath, '.env') });
|
||||||
|
|
||||||
@@ -116,6 +129,7 @@ if (envFound.error) {
|
|||||||
export default {
|
export default {
|
||||||
...config,
|
...config,
|
||||||
jwt: config.jwt,
|
jwt: config.jwt,
|
||||||
|
baseUrl,
|
||||||
rootPath,
|
rootPath,
|
||||||
tmpPath,
|
tmpPath,
|
||||||
dataPath,
|
dataPath,
|
||||||
@@ -176,4 +190,5 @@ export default {
|
|||||||
sshdPath,
|
sshdPath,
|
||||||
systemLogPath,
|
systemLogPath,
|
||||||
dependenceCachePath,
|
dependenceCachePath,
|
||||||
|
maxTokensPerPlatform: 10, // Maximum number of concurrent sessions per platform
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -417,6 +417,27 @@ export async function getPid(cmd: string) {
|
|||||||
return pid ? Number(pid) : undefined;
|
return pid ? Number(pid) : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getAllPids(cmd: string): Promise<number[]> {
|
||||||
|
const taskCommand = `ps -eo pid,command | grep "${cmd}" | grep -v grep | awk '{print $1}'`;
|
||||||
|
const pidsStr = await promiseExec(taskCommand);
|
||||||
|
if (!pidsStr) return [];
|
||||||
|
return pidsStr
|
||||||
|
.split('\n')
|
||||||
|
.map((p) => Number(p.trim()))
|
||||||
|
.filter((p) => !isNaN(p) && p > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function killAllTasks(cmd: string): Promise<void> {
|
||||||
|
const pids = await getAllPids(cmd);
|
||||||
|
for (const pid of pids) {
|
||||||
|
try {
|
||||||
|
await killTask(pid);
|
||||||
|
} catch (error) {
|
||||||
|
// Ignore errors if process already terminated
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface IVersion {
|
interface IVersion {
|
||||||
version: string;
|
version: string;
|
||||||
changeLogLink: string;
|
changeLogLink: string;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export class Crontab {
|
|||||||
task_before?: string;
|
task_before?: string;
|
||||||
task_after?: string;
|
task_after?: string;
|
||||||
log_name?: string;
|
log_name?: string;
|
||||||
|
allow_multiple_instances?: 1 | 0;
|
||||||
|
|
||||||
constructor(options: Crontab) {
|
constructor(options: Crontab) {
|
||||||
this.name = options.name;
|
this.name = options.name;
|
||||||
@@ -47,6 +48,7 @@ export class Crontab {
|
|||||||
this.task_before = options.task_before;
|
this.task_before = options.task_before;
|
||||||
this.task_after = options.task_after;
|
this.task_after = options.task_after;
|
||||||
this.log_name = options.log_name;
|
this.log_name = options.log_name;
|
||||||
|
this.allow_multiple_instances = options.allow_multiple_instances || 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,4 +89,5 @@ export const CrontabModel = sequelize.define<CronInstance>('Crontab', {
|
|||||||
task_before: DataTypes.STRING,
|
task_before: DataTypes.STRING,
|
||||||
task_after: DataTypes.STRING,
|
task_after: DataTypes.STRING,
|
||||||
log_name: DataTypes.STRING,
|
log_name: DataTypes.STRING,
|
||||||
|
allow_multiple_instances: DataTypes.NUMBER,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ export class WebhookNotification extends NotificationBaseInfo {
|
|||||||
|
|
||||||
export class LarkNotification extends NotificationBaseInfo {
|
export class LarkNotification extends NotificationBaseInfo {
|
||||||
public larkKey = '';
|
public larkKey = '';
|
||||||
|
public larkSecret = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NtfyNotification extends NotificationBaseInfo {
|
export class NtfyNotification extends NotificationBaseInfo {
|
||||||
|
|||||||
+15
-1
@@ -38,6 +38,7 @@ export interface SystemConfigInfo {
|
|||||||
pythonMirror?: string;
|
pythonMirror?: string;
|
||||||
linuxMirror?: string;
|
linuxMirror?: string;
|
||||||
timezone?: string;
|
timezone?: string;
|
||||||
|
globalSshKey?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LoginLogInfo {
|
export interface LoginLogInfo {
|
||||||
@@ -48,6 +49,19 @@ export interface LoginLogInfo {
|
|||||||
status?: LoginStatus;
|
status?: LoginStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TokenInfo {
|
||||||
|
value: string;
|
||||||
|
timestamp: number;
|
||||||
|
ip: string;
|
||||||
|
address: string;
|
||||||
|
platform: string;
|
||||||
|
/**
|
||||||
|
* Token expiration time in seconds since Unix epoch.
|
||||||
|
* If undefined, the token uses JWT's built-in expiration.
|
||||||
|
*/
|
||||||
|
expiration?: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface AuthInfo {
|
export interface AuthInfo {
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
@@ -58,7 +72,7 @@ export interface AuthInfo {
|
|||||||
platform: string;
|
platform: string;
|
||||||
isTwoFactorChecking: boolean;
|
isTwoFactorChecking: boolean;
|
||||||
token: string;
|
token: string;
|
||||||
tokens: Record<string, string>;
|
tokens: Record<string, string | TokenInfo[]>;
|
||||||
twoFactorActivated: boolean;
|
twoFactorActivated: boolean;
|
||||||
twoFactorSecret: string;
|
twoFactorSecret: string;
|
||||||
avatar: string;
|
avatar: string;
|
||||||
|
|||||||
+32
-45
@@ -19,51 +19,38 @@ export default async () => {
|
|||||||
await CrontabViewModel.sync();
|
await CrontabViewModel.sync();
|
||||||
|
|
||||||
// 初始化新增字段
|
// 初始化新增字段
|
||||||
try {
|
const migrations = [
|
||||||
await sequelize.query(
|
{
|
||||||
'alter table CrontabViews add column filterRelation VARCHAR(255)',
|
table: 'CrontabViews',
|
||||||
);
|
column: 'filterRelation',
|
||||||
} catch (error) {}
|
type: 'VARCHAR(255)',
|
||||||
try {
|
},
|
||||||
await sequelize.query(
|
{ table: 'Subscriptions', column: 'proxy', type: 'VARCHAR(255)' },
|
||||||
'alter table Subscriptions add column proxy VARCHAR(255)',
|
{ table: 'CrontabViews', column: 'type', type: 'NUMBER' },
|
||||||
);
|
{ table: 'Subscriptions', column: 'autoAddCron', type: 'NUMBER' },
|
||||||
} catch (error) {}
|
{ table: 'Subscriptions', column: 'autoDelCron', type: 'NUMBER' },
|
||||||
try {
|
{ table: 'Crontabs', column: 'sub_id', type: 'NUMBER' },
|
||||||
await sequelize.query('alter table CrontabViews add column type NUMBER');
|
{ table: 'Crontabs', column: 'extra_schedules', type: 'JSON' },
|
||||||
} catch (error) {}
|
{ table: 'Crontabs', column: 'task_before', type: 'TEXT' },
|
||||||
try {
|
{ table: 'Crontabs', column: 'task_after', type: 'TEXT' },
|
||||||
await sequelize.query(
|
{ table: 'Crontabs', column: 'log_name', type: 'VARCHAR(255)' },
|
||||||
'alter table Subscriptions add column autoAddCron NUMBER',
|
{
|
||||||
);
|
table: 'Crontabs',
|
||||||
} catch (error) {}
|
column: 'allow_multiple_instances',
|
||||||
try {
|
type: 'NUMBER',
|
||||||
await sequelize.query(
|
},
|
||||||
'alter table Subscriptions add column autoDelCron NUMBER',
|
{ table: 'Envs', column: 'isPinned', type: 'NUMBER' },
|
||||||
);
|
];
|
||||||
} catch (error) {}
|
|
||||||
try {
|
for (const migration of migrations) {
|
||||||
await sequelize.query('alter table Crontabs add column sub_id NUMBER');
|
try {
|
||||||
} catch (error) {}
|
await sequelize.query(
|
||||||
try {
|
`alter table ${migration.table} add column ${migration.column} ${migration.type}`,
|
||||||
await sequelize.query(
|
);
|
||||||
'alter table Crontabs add column extra_schedules JSON',
|
} catch (error) {
|
||||||
);
|
// Column already exists or other error, continue
|
||||||
} catch (error) {}
|
}
|
||||||
try {
|
}
|
||||||
await sequelize.query('alter table Crontabs add column task_before TEXT');
|
|
||||||
} catch (error) {}
|
|
||||||
try {
|
|
||||||
await sequelize.query('alter table Crontabs add column task_after TEXT');
|
|
||||||
} catch (error) {}
|
|
||||||
try {
|
|
||||||
await sequelize.query(
|
|
||||||
'alter table Crontabs add column log_name VARCHAR(255)',
|
|
||||||
);
|
|
||||||
} catch (error) { }
|
|
||||||
try {
|
|
||||||
await sequelize.query('alter table Envs add column isPinned NUMBER');
|
|
||||||
} catch (error) {}
|
|
||||||
|
|
||||||
Logger.info('✌️ DB loaded');
|
Logger.info('✌️ DB loaded');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
+10
-5
@@ -9,11 +9,19 @@ import rewrite from 'express-urlrewrite';
|
|||||||
import { errors } from 'celebrate';
|
import { errors } from 'celebrate';
|
||||||
import { serveEnv } from '../config/serverEnv';
|
import { serveEnv } from '../config/serverEnv';
|
||||||
import { IKeyvStore, shareStore } from '../shared/store';
|
import { IKeyvStore, shareStore } from '../shared/store';
|
||||||
|
import { isValidToken } from '../shared/auth';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
export default ({ app }: { app: Application }) => {
|
export default ({ app }: { app: Application }) => {
|
||||||
app.set('trust proxy', 'loopback');
|
app.set('trust proxy', 'loopback');
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
|
|
||||||
|
// Rewrite URLs to strip baseUrl prefix if configured
|
||||||
|
// This allows the rest of the app to work without baseUrl awareness
|
||||||
|
if (config.baseUrl) {
|
||||||
|
app.use(rewrite(`${config.baseUrl}/*`, '/$1'));
|
||||||
|
}
|
||||||
|
|
||||||
app.get(`${config.api.prefix}/env.js`, serveEnv);
|
app.get(`${config.api.prefix}/env.js`, serveEnv);
|
||||||
app.use(`${config.api.prefix}/static`, express.static(config.uploadPath));
|
app.use(`${config.api.prefix}/static`, express.static(config.uploadPath));
|
||||||
|
|
||||||
@@ -77,11 +85,8 @@ export default ({ app }: { app: Application }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const authInfo = await shareStore.getAuthInfo();
|
const authInfo = await shareStore.getAuthInfo();
|
||||||
if (authInfo && headerToken) {
|
if (isValidToken(authInfo, headerToken, req.platform)) {
|
||||||
const { token = '', tokens = {} } = authInfo;
|
return next();
|
||||||
if (headerToken === token || tokens[req.platform] === headerToken) {
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const errorCode = headerToken ? 'invalid_token' : 'credentials_required';
|
const errorCode = headerToken ? 'invalid_token' : 'credentials_required';
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Container } from 'typedi';
|
|||||||
import SystemService from '../services/system';
|
import SystemService from '../services/system';
|
||||||
import ScheduleService, { ScheduleTaskType } from '../services/schedule';
|
import ScheduleService, { ScheduleTaskType } from '../services/schedule';
|
||||||
import SubscriptionService from '../services/subscription';
|
import SubscriptionService from '../services/subscription';
|
||||||
|
import SshKeyService from '../services/sshKey';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
import { fileExist } from '../config/util';
|
import { fileExist } from '../config/util';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
@@ -10,6 +11,7 @@ export default async () => {
|
|||||||
const systemService = Container.get(SystemService);
|
const systemService = Container.get(SystemService);
|
||||||
const scheduleService = Container.get(ScheduleService);
|
const scheduleService = Container.get(ScheduleService);
|
||||||
const subscriptionService = Container.get(SubscriptionService);
|
const subscriptionService = Container.get(SubscriptionService);
|
||||||
|
const sshKeyService = Container.get(SshKeyService);
|
||||||
|
|
||||||
// 生成内置token
|
// 生成内置token
|
||||||
let tokenCommand = `ts-node-transpile-only ${join(
|
let tokenCommand = `ts-node-transpile-only ${join(
|
||||||
@@ -57,6 +59,11 @@ export default async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
systemService.updateTimezone(data.info);
|
systemService.updateTimezone(data.info);
|
||||||
|
|
||||||
|
// Apply global SSH key if configured
|
||||||
|
if (data.info.globalSshKey) {
|
||||||
|
await sshKeyService.addGlobalSSHKey(data.info.globalSshKey, 'global');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await subscriptionService.setSshConfig();
|
await subscriptionService.setSshConfig();
|
||||||
|
|||||||
+13
-13
@@ -4,9 +4,11 @@ import { Container } from 'typedi';
|
|||||||
import SockService from '../services/sock';
|
import SockService from '../services/sock';
|
||||||
import { getPlatform } from '../config/util';
|
import { getPlatform } from '../config/util';
|
||||||
import { shareStore } from '../shared/store';
|
import { shareStore } from '../shared/store';
|
||||||
|
import { isValidToken } from '../shared/auth';
|
||||||
|
import config from '../config';
|
||||||
|
|
||||||
export default async ({ server }: { server: Server }) => {
|
export default async ({ server }: { server: Server }) => {
|
||||||
const echo = sockJs.createServer({ prefix: '/api/ws', log: () => {} });
|
const echo = sockJs.createServer({ prefix: `${config.baseUrl}/api/ws`, log: () => { } });
|
||||||
const sockService = Container.get(SockService);
|
const sockService = Container.get(SockService);
|
||||||
|
|
||||||
echo.on('connection', async (conn) => {
|
echo.on('connection', async (conn) => {
|
||||||
@@ -17,21 +19,19 @@ export default async ({ server }: { server: Server }) => {
|
|||||||
const authInfo = await shareStore.getAuthInfo();
|
const authInfo = await shareStore.getAuthInfo();
|
||||||
const platform = getPlatform(conn.headers['user-agent'] || '') || 'desktop';
|
const platform = getPlatform(conn.headers['user-agent'] || '') || 'desktop';
|
||||||
const headerToken = conn.url.replace(`${conn.pathname}?token=`, '');
|
const headerToken = conn.url.replace(`${conn.pathname}?token=`, '');
|
||||||
if (authInfo) {
|
|
||||||
const { token = '', tokens = {} } = authInfo;
|
|
||||||
if (headerToken === token || tokens[platform] === headerToken) {
|
|
||||||
sockService.addClient(conn);
|
|
||||||
|
|
||||||
conn.on('data', (message) => {
|
if (isValidToken(authInfo, headerToken, platform)) {
|
||||||
conn.write(message);
|
sockService.addClient(conn);
|
||||||
});
|
|
||||||
|
|
||||||
conn.on('close', function () {
|
conn.on('data', (message) => {
|
||||||
sockService.removeClient(conn);
|
conn.write(message);
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
conn.on('close', function () {
|
||||||
}
|
sockService.removeClient(conn);
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.close('404');
|
conn.close('404');
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ message NotificationInfo {
|
|||||||
optional string webhookContentType = 57;
|
optional string webhookContentType = 57;
|
||||||
|
|
||||||
optional string larkKey = 58;
|
optional string larkKey = 58;
|
||||||
|
optional string larkSecret = 69;
|
||||||
|
|
||||||
optional string ntfyUrl = 59;
|
optional string ntfyUrl = 59;
|
||||||
optional string ntfyTopic = 60;
|
optional string ntfyTopic = 60;
|
||||||
|
|||||||
+19
-1
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-ts_proto v2.6.1
|
// protoc-gen-ts_proto v2.6.1
|
||||||
// protoc v3.17.3
|
// protoc v3.21.12
|
||||||
// source: back/protos/api.proto
|
// source: back/protos/api.proto
|
||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
@@ -382,6 +382,7 @@ export interface NotificationInfo {
|
|||||||
webhookMethod?: string | undefined;
|
webhookMethod?: string | undefined;
|
||||||
webhookContentType?: string | undefined;
|
webhookContentType?: string | undefined;
|
||||||
larkKey?: string | undefined;
|
larkKey?: string | undefined;
|
||||||
|
larkSecret?: string | undefined;
|
||||||
ntfyUrl?: string | undefined;
|
ntfyUrl?: string | undefined;
|
||||||
ntfyTopic?: string | undefined;
|
ntfyTopic?: string | undefined;
|
||||||
ntfyPriority?: string | undefined;
|
ntfyPriority?: string | undefined;
|
||||||
@@ -2947,6 +2948,7 @@ function createBaseNotificationInfo(): NotificationInfo {
|
|||||||
webhookMethod: undefined,
|
webhookMethod: undefined,
|
||||||
webhookContentType: undefined,
|
webhookContentType: undefined,
|
||||||
larkKey: undefined,
|
larkKey: undefined,
|
||||||
|
larkSecret: undefined,
|
||||||
ntfyUrl: undefined,
|
ntfyUrl: undefined,
|
||||||
ntfyTopic: undefined,
|
ntfyTopic: undefined,
|
||||||
ntfyPriority: undefined,
|
ntfyPriority: undefined,
|
||||||
@@ -3136,6 +3138,9 @@ export const NotificationInfo: MessageFns<NotificationInfo> = {
|
|||||||
if (message.larkKey !== undefined) {
|
if (message.larkKey !== undefined) {
|
||||||
writer.uint32(466).string(message.larkKey);
|
writer.uint32(466).string(message.larkKey);
|
||||||
}
|
}
|
||||||
|
if (message.larkSecret !== undefined) {
|
||||||
|
writer.uint32(554).string(message.larkSecret);
|
||||||
|
}
|
||||||
if (message.ntfyUrl !== undefined) {
|
if (message.ntfyUrl !== undefined) {
|
||||||
writer.uint32(474).string(message.ntfyUrl);
|
writer.uint32(474).string(message.ntfyUrl);
|
||||||
}
|
}
|
||||||
@@ -3640,6 +3645,14 @@ export const NotificationInfo: MessageFns<NotificationInfo> = {
|
|||||||
message.larkKey = reader.string();
|
message.larkKey = reader.string();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
case 69: {
|
||||||
|
if (tag !== 554) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
message.larkSecret = reader.string();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
case 59: {
|
case 59: {
|
||||||
if (tag !== 474) {
|
if (tag !== 474) {
|
||||||
break;
|
break;
|
||||||
@@ -3797,6 +3810,7 @@ export const NotificationInfo: MessageFns<NotificationInfo> = {
|
|||||||
webhookMethod: isSet(object.webhookMethod) ? globalThis.String(object.webhookMethod) : undefined,
|
webhookMethod: isSet(object.webhookMethod) ? globalThis.String(object.webhookMethod) : undefined,
|
||||||
webhookContentType: isSet(object.webhookContentType) ? globalThis.String(object.webhookContentType) : undefined,
|
webhookContentType: isSet(object.webhookContentType) ? globalThis.String(object.webhookContentType) : undefined,
|
||||||
larkKey: isSet(object.larkKey) ? globalThis.String(object.larkKey) : undefined,
|
larkKey: isSet(object.larkKey) ? globalThis.String(object.larkKey) : undefined,
|
||||||
|
larkSecret: isSet(object.larkSecret) ? globalThis.String(object.larkSecret) : undefined,
|
||||||
ntfyUrl: isSet(object.ntfyUrl) ? globalThis.String(object.ntfyUrl) : undefined,
|
ntfyUrl: isSet(object.ntfyUrl) ? globalThis.String(object.ntfyUrl) : undefined,
|
||||||
ntfyTopic: isSet(object.ntfyTopic) ? globalThis.String(object.ntfyTopic) : undefined,
|
ntfyTopic: isSet(object.ntfyTopic) ? globalThis.String(object.ntfyTopic) : undefined,
|
||||||
ntfyPriority: isSet(object.ntfyPriority) ? globalThis.String(object.ntfyPriority) : undefined,
|
ntfyPriority: isSet(object.ntfyPriority) ? globalThis.String(object.ntfyPriority) : undefined,
|
||||||
@@ -3990,6 +4004,9 @@ export const NotificationInfo: MessageFns<NotificationInfo> = {
|
|||||||
if (message.larkKey !== undefined) {
|
if (message.larkKey !== undefined) {
|
||||||
obj.larkKey = message.larkKey;
|
obj.larkKey = message.larkKey;
|
||||||
}
|
}
|
||||||
|
if (message.larkSecret !== undefined) {
|
||||||
|
obj.larkSecret = message.larkSecret;
|
||||||
|
}
|
||||||
if (message.ntfyUrl !== undefined) {
|
if (message.ntfyUrl !== undefined) {
|
||||||
obj.ntfyUrl = message.ntfyUrl;
|
obj.ntfyUrl = message.ntfyUrl;
|
||||||
}
|
}
|
||||||
@@ -4086,6 +4103,7 @@ export const NotificationInfo: MessageFns<NotificationInfo> = {
|
|||||||
message.webhookMethod = object.webhookMethod ?? undefined;
|
message.webhookMethod = object.webhookMethod ?? undefined;
|
||||||
message.webhookContentType = object.webhookContentType ?? undefined;
|
message.webhookContentType = object.webhookContentType ?? undefined;
|
||||||
message.larkKey = object.larkKey ?? undefined;
|
message.larkKey = object.larkKey ?? undefined;
|
||||||
|
message.larkSecret = object.larkSecret ?? undefined;
|
||||||
message.ntfyUrl = object.ntfyUrl ?? undefined;
|
message.ntfyUrl = object.ntfyUrl ?? undefined;
|
||||||
message.ntfyTopic = object.ntfyTopic ?? undefined;
|
message.ntfyTopic = object.ntfyTopic ?? undefined;
|
||||||
message.ntfyPriority = object.ntfyPriority ?? undefined;
|
message.ntfyPriority = object.ntfyPriority ?? undefined;
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-ts_proto v2.6.1
|
// protoc-gen-ts_proto v2.6.1
|
||||||
// protoc v3.17.3
|
// protoc v3.21.12
|
||||||
// source: back/protos/cron.proto
|
// source: back/protos/cron.proto
|
||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-ts_proto v2.6.1
|
// protoc-gen-ts_proto v2.6.1
|
||||||
// protoc v3.17.3
|
// protoc v3.21.12
|
||||||
// source: back/protos/health.proto
|
// source: back/protos/health.proto
|
||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|||||||
+26
-8
@@ -4,11 +4,12 @@ import config from '../config';
|
|||||||
import { Crontab, CrontabModel, CrontabStatus } from '../data/cron';
|
import { Crontab, CrontabModel, CrontabStatus } from '../data/cron';
|
||||||
import { exec, execSync } from 'child_process';
|
import { exec, execSync } from 'child_process';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import { CronExpressionParser } from 'cron-parser';
|
import CronExpressionParser from 'cron-parser';
|
||||||
import {
|
import {
|
||||||
getFileContentByName,
|
getFileContentByName,
|
||||||
fileExist,
|
fileExist,
|
||||||
killTask,
|
killTask,
|
||||||
|
killAllTasks,
|
||||||
getUniqPath,
|
getUniqPath,
|
||||||
safeJSONParse,
|
safeJSONParse,
|
||||||
isDemoEnv,
|
isDemoEnv,
|
||||||
@@ -57,7 +58,9 @@ export default class CronService {
|
|||||||
}
|
}
|
||||||
let uniqPath = await getUniqPath(command, `${id}`);
|
let uniqPath = await getUniqPath(command, `${id}`);
|
||||||
if (log_name) {
|
if (log_name) {
|
||||||
const normalizedLogName = log_name.startsWith('/') ? log_name : path.join(config.logPath, log_name);
|
const normalizedLogName = log_name.startsWith('/')
|
||||||
|
? log_name
|
||||||
|
: path.join(config.logPath, log_name);
|
||||||
if (normalizedLogName.startsWith(config.logPath)) {
|
if (normalizedLogName.startsWith(config.logPath)) {
|
||||||
uniqPath = log_name;
|
uniqPath = log_name;
|
||||||
}
|
}
|
||||||
@@ -462,12 +465,20 @@ export default class CronService {
|
|||||||
public async stop(ids: number[]) {
|
public async stop(ids: number[]) {
|
||||||
const docs = await CrontabModel.findAll({ where: { id: ids } });
|
const docs = await CrontabModel.findAll({ where: { id: ids } });
|
||||||
for (const doc of docs) {
|
for (const doc of docs) {
|
||||||
if (doc.pid) {
|
// Kill all running instances of this task
|
||||||
try {
|
try {
|
||||||
|
if (doc.pid) {
|
||||||
await killTask(doc.pid);
|
await killTask(doc.pid);
|
||||||
} catch (error) {
|
|
||||||
this.logger.error(error);
|
|
||||||
}
|
}
|
||||||
|
const command = doc.command.replace(/\s+/g, ' ').trim();
|
||||||
|
await killAllTasks(command);
|
||||||
|
this.logger.info(
|
||||||
|
`[panel][停止所有运行中的任务实例] 任务ID: ${doc.id}, 命令: ${command}`,
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(
|
||||||
|
`[panel][停止任务失败] 任务ID: ${doc.id}, 错误: ${error}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,7 +509,10 @@ export default class CronService {
|
|||||||
|
|
||||||
let { id, command, log_name } = cron;
|
let { id, command, log_name } = cron;
|
||||||
|
|
||||||
const uniqPath = log_name === '/dev/null' ? (await getUniqPath(command, `${id}`)) : log_name;
|
const uniqPath =
|
||||||
|
log_name === '/dev/null' || !log_name
|
||||||
|
? await getUniqPath(command, `${id}`)
|
||||||
|
: log_name;
|
||||||
const logTime = dayjs().format('YYYY-MM-DD-HH-mm-ss-SSS');
|
const logTime = dayjs().format('YYYY-MM-DD-HH-mm-ss-SSS');
|
||||||
const logDirPath = path.resolve(config.logPath, `${uniqPath}`);
|
const logDirPath = path.resolve(config.logPath, `${uniqPath}`);
|
||||||
await fs.mkdir(logDirPath, { recursive: true });
|
await fs.mkdir(logDirPath, { recursive: true });
|
||||||
@@ -630,7 +644,11 @@ export default class CronService {
|
|||||||
if (!command.startsWith(TASK_PREFIX) && !command.startsWith(QL_PREFIX)) {
|
if (!command.startsWith(TASK_PREFIX) && !command.startsWith(QL_PREFIX)) {
|
||||||
command = `${TASK_PREFIX}${tab.command}`;
|
command = `${TASK_PREFIX}${tab.command}`;
|
||||||
}
|
}
|
||||||
let commandVariable = `real_time=${Boolean(realTime)} log_name=${tab.log_name} no_tee=true ID=${tab.id} `;
|
let commandVariable = `real_time=${Boolean(realTime)} no_tee=true ID=${tab.id} `;
|
||||||
|
// Only include log_name if it has a truthy value to avoid passing null/undefined to shell
|
||||||
|
if (tab.log_name) {
|
||||||
|
commandVariable += `log_name=${tab.log_name} `;
|
||||||
|
}
|
||||||
if (tab.task_before) {
|
if (tab.task_before) {
|
||||||
commandVariable += `task_before='${tab.task_before
|
commandVariable += `task_before='${tab.task_before
|
||||||
.replace(/'/g, "'\\''")
|
.replace(/'/g, "'\\''")
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export default class DependenceService {
|
|||||||
query: any = {},
|
query: any = {},
|
||||||
): Promise<Dependence[]> {
|
): Promise<Dependence[]> {
|
||||||
let condition = query;
|
let condition = query;
|
||||||
if (DependenceTypes[type]) {
|
if (type && DependenceTypes[type] !== undefined) {
|
||||||
condition.type = DependenceTypes[type];
|
condition.type = DependenceTypes[type];
|
||||||
}
|
}
|
||||||
if (status) {
|
if (status) {
|
||||||
|
|||||||
@@ -13,10 +13,11 @@ import {
|
|||||||
stepPosition,
|
stepPosition,
|
||||||
} from '../data/env';
|
} from '../data/env';
|
||||||
import { writeFileWithLock } from '../shared/utils';
|
import { writeFileWithLock } from '../shared/utils';
|
||||||
|
import { sequelize } from '../data';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export default class EnvService {
|
export default class EnvService {
|
||||||
constructor(@Inject('logger') private logger: winston.Logger) {}
|
constructor(@Inject('logger') private logger: winston.Logger) { }
|
||||||
|
|
||||||
public async create(payloads: Env[]): Promise<Env[]> {
|
public async create(payloads: Env[]): Promise<Env[]> {
|
||||||
const envs = await this.envs();
|
const envs = await this.envs();
|
||||||
@@ -146,7 +147,7 @@ export default class EnvService {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const result = await this.find(condition, [
|
const result = await this.find(condition, [
|
||||||
['isPinned', 'DESC'],
|
[sequelize.literal('COALESCE(`isPinned`, 0)'), 'DESC'],
|
||||||
['position', 'DESC'],
|
['position', 'DESC'],
|
||||||
['createdAt', 'ASC'],
|
['createdAt', 'ASC'],
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export class GrpcServerService {
|
|||||||
const grpcPort = config.grpcPort;
|
const grpcPort = config.grpcPort;
|
||||||
const bindAsync = promisify(this.server.bindAsync).bind(this.server);
|
const bindAsync = promisify(this.server.bindAsync).bind(this.server);
|
||||||
await bindAsync(
|
await bindAsync(
|
||||||
`0.0.0.0:${grpcPort}`,
|
`[::]:${grpcPort}`,
|
||||||
ServerCredentials.createInsecure(),
|
ServerCredentials.createInsecure(),
|
||||||
);
|
);
|
||||||
Logger.debug(`✌️ gRPC service started successfully`);
|
Logger.debug(`✌️ gRPC service started successfully`);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export class HttpServerService {
|
|||||||
async initialize(expressApp: express.Application, port: number) {
|
async initialize(expressApp: express.Application, port: number) {
|
||||||
try {
|
try {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.server = expressApp.listen(port, '0.0.0.0', () => {
|
this.server = expressApp.listen(port, '::', () => {
|
||||||
Logger.debug(`✌️ HTTP service started successfully`);
|
Logger.debug(`✌️ HTTP service started successfully`);
|
||||||
metricsService.record('http_service_start', 1, {
|
metricsService.record('http_service_start', 1, {
|
||||||
port: port.toString(),
|
port: port.toString(),
|
||||||
|
|||||||
+19
-5
@@ -550,19 +550,33 @@ export default class NotificationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async lark() {
|
private async lark() {
|
||||||
let { larkKey } = this.params;
|
let { larkKey, larkSecret } = this.params;
|
||||||
|
|
||||||
if (!larkKey.startsWith('http')) {
|
if (!larkKey.startsWith('http')) {
|
||||||
larkKey = `https://open.feishu.cn/open-apis/bot/v2/hook/${larkKey}`;
|
larkKey = `https://open.feishu.cn/open-apis/bot/v2/hook/${larkKey}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const body: Record<string, any> = {
|
||||||
|
msg_type: 'text',
|
||||||
|
content: { text: `${this.title}\n\n${this.content}` },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add signature if secret is provided
|
||||||
|
// Note: Feishu's signature algorithm uses timestamp+"\n"+secret as the HMAC key
|
||||||
|
// and signs an empty message, which differs from typical HMAC usage
|
||||||
|
if (larkSecret) {
|
||||||
|
const timestamp = Math.floor(Date.now() / 1000).toString();
|
||||||
|
const stringToSign = `${timestamp}\n${larkSecret}`;
|
||||||
|
const hmac = crypto.createHmac('sha256', stringToSign);
|
||||||
|
const sign = hmac.digest('base64');
|
||||||
|
body.timestamp = timestamp;
|
||||||
|
body.sign = sign;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await httpClient.post(larkKey, {
|
const res = await httpClient.post(larkKey, {
|
||||||
...this.gotOption,
|
...this.gotOption,
|
||||||
json: {
|
json: body,
|
||||||
msg_type: 'text',
|
|
||||||
content: { text: `${this.title}\n\n${this.content}` },
|
|
||||||
},
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
});
|
});
|
||||||
if (res.StatusCode === 0 || res.code === 0) {
|
if (res.StatusCode === 0 || res.code === 0) {
|
||||||
|
|||||||
@@ -131,4 +131,32 @@ export default class SshKeyService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async addGlobalSSHKey(key: string, alias: string): Promise<void> {
|
||||||
|
await this.generatePrivateKeyFile(`~global_${alias}`, key);
|
||||||
|
// Create a global SSH config entry that matches all hosts
|
||||||
|
// This allows the key to be used for any Git repository
|
||||||
|
await this.generateGlobalSshConfig(`~global_${alias}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async removeGlobalSSHKey(alias: string): Promise<void> {
|
||||||
|
await this.removePrivateKeyFile(`~global_${alias}`);
|
||||||
|
await this.removeSshConfig(`~global_${alias}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async generateGlobalSshConfig(alias: string) {
|
||||||
|
// Create a config that matches all hosts, making this key globally available
|
||||||
|
const config = `Host *\n IdentityFile ${path.join(
|
||||||
|
this.sshPath,
|
||||||
|
alias,
|
||||||
|
)}\n StrictHostKeyChecking no\n`;
|
||||||
|
await writeFileWithLock(
|
||||||
|
`${path.join(this.sshPath, `${alias}.config`)}`,
|
||||||
|
config,
|
||||||
|
{
|
||||||
|
encoding: 'utf8',
|
||||||
|
mode: '600',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -530,6 +530,27 @@ export default class SystemService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async updateGlobalSshKey(info: SystemModelInfo) {
|
||||||
|
const oDoc = await this.getSystemConfig();
|
||||||
|
const result = await this.updateAuthDb({
|
||||||
|
...oDoc,
|
||||||
|
info: { ...oDoc.info, ...info },
|
||||||
|
});
|
||||||
|
|
||||||
|
// Apply the global SSH key
|
||||||
|
const SshKeyService = require('./sshKey').default;
|
||||||
|
const Container = require('typedi').Container;
|
||||||
|
const sshKeyService = Container.get(SshKeyService);
|
||||||
|
|
||||||
|
if (info.globalSshKey) {
|
||||||
|
await sshKeyService.addGlobalSSHKey(info.globalSshKey, 'global');
|
||||||
|
} else {
|
||||||
|
await sshKeyService.removeGlobalSSHKey('global');
|
||||||
|
}
|
||||||
|
|
||||||
|
return { code: 200, data: result };
|
||||||
|
}
|
||||||
|
|
||||||
public async cleanDependence(type: 'node' | 'python3') {
|
public async cleanDependence(type: 'node' | 'python3') {
|
||||||
if (!type || !['node', 'python3'].includes(type)) {
|
if (!type || !['node', 'python3'].includes(type)) {
|
||||||
return { code: 400, message: '参数错误' };
|
return { code: 400, message: '参数错误' };
|
||||||
|
|||||||
+139
-7
@@ -11,6 +11,7 @@ import {
|
|||||||
SystemModelInfo,
|
SystemModelInfo,
|
||||||
LoginStatus,
|
LoginStatus,
|
||||||
AuthInfo,
|
AuthInfo,
|
||||||
|
TokenInfo,
|
||||||
} from '../data/system';
|
} from '../data/system';
|
||||||
import { NotificationInfo } from '../data/notify';
|
import { NotificationInfo } from '../data/notify';
|
||||||
import NotificationService from './notify';
|
import NotificationService from './notify';
|
||||||
@@ -101,12 +102,23 @@ export default class UserService {
|
|||||||
algorithm: 'HS384',
|
algorithm: 'HS384',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const tokenInfo: TokenInfo = {
|
||||||
|
value: token,
|
||||||
|
timestamp,
|
||||||
|
ip,
|
||||||
|
address,
|
||||||
|
platform: req.platform,
|
||||||
|
};
|
||||||
|
|
||||||
|
const updatedTokens = this.addTokenToList(
|
||||||
|
tokens,
|
||||||
|
req.platform,
|
||||||
|
tokenInfo,
|
||||||
|
);
|
||||||
|
|
||||||
await this.updateAuthInfo(content, {
|
await this.updateAuthInfo(content, {
|
||||||
token,
|
token,
|
||||||
tokens: {
|
tokens: updatedTokens,
|
||||||
...tokens,
|
|
||||||
[req.platform]: token,
|
|
||||||
},
|
|
||||||
lastlogon: timestamp,
|
lastlogon: timestamp,
|
||||||
retries: 0,
|
retries: 0,
|
||||||
lastip: ip,
|
lastip: ip,
|
||||||
@@ -180,11 +192,37 @@ export default class UserService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async logout(platform: string): Promise<any> {
|
public async logout(platform: string, tokenValue: string): Promise<any> {
|
||||||
|
if (!platform || !tokenValue) {
|
||||||
|
this.logger.warn('Invalid logout parameters - empty platform or token');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const authInfo = await this.getAuthInfo();
|
const authInfo = await this.getAuthInfo();
|
||||||
|
|
||||||
|
// Verify the token exists before attempting to remove it
|
||||||
|
const tokenExists = this.findTokenInList(
|
||||||
|
authInfo.tokens,
|
||||||
|
platform,
|
||||||
|
tokenValue,
|
||||||
|
);
|
||||||
|
if (!tokenExists && authInfo.token !== tokenValue) {
|
||||||
|
// Token not found, but don't throw error - user may have already logged out
|
||||||
|
this.logger.info(
|
||||||
|
`Logout attempted for non-existent token on platform: ${platform}`,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const updatedTokens = this.removeTokenFromList(
|
||||||
|
authInfo.tokens,
|
||||||
|
platform,
|
||||||
|
tokenValue,
|
||||||
|
);
|
||||||
|
|
||||||
await this.updateAuthInfo(authInfo, {
|
await this.updateAuthInfo(authInfo, {
|
||||||
token: '',
|
token: authInfo.token === tokenValue ? '' : authInfo.token,
|
||||||
tokens: { ...authInfo.tokens, [platform]: '' },
|
tokens: updatedTokens,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,6 +402,100 @@ export default class UserService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private normalizeTokens(
|
||||||
|
tokens: Record<string, string | TokenInfo[]>,
|
||||||
|
): Record<string, TokenInfo[]> {
|
||||||
|
const normalized: Record<string, TokenInfo[]> = {};
|
||||||
|
|
||||||
|
for (const [platform, value] of Object.entries(tokens)) {
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
// Legacy format: convert string token to TokenInfo array
|
||||||
|
if (value) {
|
||||||
|
normalized[platform] = [
|
||||||
|
{
|
||||||
|
value,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
ip: '',
|
||||||
|
address: '',
|
||||||
|
platform,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
normalized[platform] = [];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Already in new format
|
||||||
|
normalized[platform] = value || [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
private addTokenToList(
|
||||||
|
tokens: Record<string, string | TokenInfo[]>,
|
||||||
|
platform: string,
|
||||||
|
tokenInfo: TokenInfo,
|
||||||
|
maxTokensPerPlatform: number = config.maxTokensPerPlatform,
|
||||||
|
): Record<string, TokenInfo[]> {
|
||||||
|
// Validate maxTokensPerPlatform parameter
|
||||||
|
if (!Number.isInteger(maxTokensPerPlatform) || maxTokensPerPlatform < 1) {
|
||||||
|
this.logger.warn(
|
||||||
|
`Invalid maxTokensPerPlatform value: ${maxTokensPerPlatform}, using default`,
|
||||||
|
);
|
||||||
|
maxTokensPerPlatform = config.maxTokensPerPlatform;
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalized = this.normalizeTokens(tokens);
|
||||||
|
|
||||||
|
if (!normalized[platform]) {
|
||||||
|
normalized[platform] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add new token
|
||||||
|
normalized[platform].unshift(tokenInfo);
|
||||||
|
|
||||||
|
// Limit the number of active tokens per platform
|
||||||
|
if (normalized[platform].length > maxTokensPerPlatform) {
|
||||||
|
normalized[platform] = normalized[platform].slice(
|
||||||
|
0,
|
||||||
|
maxTokensPerPlatform,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
private removeTokenFromList(
|
||||||
|
tokens: Record<string, string | TokenInfo[]>,
|
||||||
|
platform: string,
|
||||||
|
tokenValue: string,
|
||||||
|
): Record<string, TokenInfo[]> {
|
||||||
|
const normalized = this.normalizeTokens(tokens);
|
||||||
|
|
||||||
|
if (normalized[platform]) {
|
||||||
|
normalized[platform] = normalized[platform].filter(
|
||||||
|
(t) => t.value !== tokenValue,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
private findTokenInList(
|
||||||
|
tokens: Record<string, string | TokenInfo[]>,
|
||||||
|
platform: string,
|
||||||
|
tokenValue: string,
|
||||||
|
): TokenInfo | undefined {
|
||||||
|
const normalized = this.normalizeTokens(tokens);
|
||||||
|
|
||||||
|
if (normalized[platform]) {
|
||||||
|
return normalized[platform].find((t) => t.value === tokenValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
public async resetAuthInfo(info: Partial<AuthInfo>) {
|
public async resetAuthInfo(info: Partial<AuthInfo>) {
|
||||||
const { retries, twoFactorActivated, password, username } = info;
|
const { retries, twoFactorActivated, password, username } = info;
|
||||||
const authInfo = await this.getAuthInfo();
|
const authInfo = await this.getAuthInfo();
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { AuthInfo, TokenInfo } from '../data/system';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates if a token exists in the authentication info.
|
||||||
|
* Supports both legacy string tokens and new TokenInfo array format.
|
||||||
|
*
|
||||||
|
* @param authInfo - The authentication information
|
||||||
|
* @param headerToken - The token to validate
|
||||||
|
* @param platform - The platform (desktop, mobile)
|
||||||
|
* @returns true if the token is valid, false otherwise
|
||||||
|
*/
|
||||||
|
export function isValidToken(
|
||||||
|
authInfo: AuthInfo | null | undefined,
|
||||||
|
headerToken: string,
|
||||||
|
platform: string,
|
||||||
|
): boolean {
|
||||||
|
if (!authInfo || !headerToken) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { token = '', tokens = {} } = authInfo;
|
||||||
|
|
||||||
|
// Check legacy token field
|
||||||
|
if (headerToken === token) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check platform-specific tokens (support both legacy string and new TokenInfo[] format)
|
||||||
|
const platformTokens = tokens[platform];
|
||||||
|
|
||||||
|
// Handle null/undefined platformTokens
|
||||||
|
if (platformTokens === null || platformTokens === undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof platformTokens === 'string') {
|
||||||
|
// Legacy format: single string token
|
||||||
|
return headerToken === platformTokens;
|
||||||
|
} else if (Array.isArray(platformTokens)) {
|
||||||
|
// New format: array of TokenInfo objects
|
||||||
|
return platformTokens.some((t: TokenInfo) => t && t.value === headerToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unexpected type - log warning and reject
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@@ -2,10 +2,45 @@ import { spawn } from 'cross-spawn';
|
|||||||
import taskLimit from './pLimit';
|
import taskLimit from './pLimit';
|
||||||
import Logger from '../loaders/logger';
|
import Logger from '../loaders/logger';
|
||||||
import { ICron } from '../protos/cron';
|
import { ICron } from '../protos/cron';
|
||||||
|
import { CrontabModel, CrontabStatus } from '../data/cron';
|
||||||
|
import { killTask } from '../config/util';
|
||||||
|
|
||||||
export function runCron(cmd: string, cron: ICron): Promise<number | void> {
|
export function runCron(cmd: string, cron: ICron): Promise<number | void> {
|
||||||
return taskLimit.runWithCronLimit(cron, () => {
|
return taskLimit.runWithCronLimit(cron, () => {
|
||||||
return new Promise(async (resolve: any) => {
|
return new Promise(async (resolve: any) => {
|
||||||
|
// Check if the cron is already running and stop it (only if multiple instances are not allowed)
|
||||||
|
try {
|
||||||
|
const existingCron = await CrontabModel.findOne({
|
||||||
|
where: { id: Number(cron.id) },
|
||||||
|
});
|
||||||
|
|
||||||
|
// Default to single instance mode (0) for backward compatibility
|
||||||
|
const allowSingleInstances =
|
||||||
|
existingCron?.allow_multiple_instances === 0;
|
||||||
|
|
||||||
|
if (
|
||||||
|
allowSingleInstances &&
|
||||||
|
existingCron &&
|
||||||
|
existingCron.pid &&
|
||||||
|
(existingCron.status === CrontabStatus.running ||
|
||||||
|
existingCron.status === CrontabStatus.queued)
|
||||||
|
) {
|
||||||
|
Logger.info(
|
||||||
|
`[schedule][停止已运行任务] 任务ID: ${cron.id}, PID: ${existingCron.pid}`,
|
||||||
|
);
|
||||||
|
await killTask(existingCron.pid);
|
||||||
|
// Update the status to idle after killing
|
||||||
|
await CrontabModel.update(
|
||||||
|
{ status: CrontabStatus.idle, pid: undefined },
|
||||||
|
{ where: { id: Number(cron.id) } },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
Logger.error(
|
||||||
|
`[schedule][检查已运行任务失败] 任务ID: ${cron.id}, 错误: ${error}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Logger.info(
|
Logger.info(
|
||||||
`[schedule][开始执行任务] 参数 ${JSON.stringify({
|
`[schedule][开始执行任务] 参数 ${JSON.stringify({
|
||||||
...cron,
|
...cron,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Joi } from 'celebrate';
|
import { Joi } from 'celebrate';
|
||||||
import { CronExpressionParser } from 'cron-parser';
|
import CronExpressionParser from 'cron-parser';
|
||||||
import { ScheduleType } from '../interface/schedule';
|
import { ScheduleType } from '../interface/schedule';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
@@ -64,7 +64,11 @@ export const commonCronSchema = {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!/^(?!.*(?:^|\/)\.{1,2}(?:\/|$))(?:\/)?(?:[\w.-]+\/)*[\w.-]+\/?$/.test(value)) {
|
if (
|
||||||
|
!/^(?!.*(?:^|\/)\.{1,2}(?:\/|$))(?:\/)?(?:[\w.-]+\/)*[\w.-]+\/?$/.test(
|
||||||
|
value,
|
||||||
|
)
|
||||||
|
) {
|
||||||
return helpers.error('string.pattern.base');
|
return helpers.error('string.pattern.base');
|
||||||
}
|
}
|
||||||
if (value.length > 100) {
|
if (value.length > 100) {
|
||||||
@@ -77,4 +81,5 @@ export const commonCronSchema = {
|
|||||||
'string.max': '日志名称不能超过100个字符',
|
'string.max': '日志名称不能超过100个字符',
|
||||||
'string.unsafePath': '绝对路径必须在日志目录内或使用 /dev/null',
|
'string.unsafePath': '绝对路径必须在日志目录内或使用 /dev/null',
|
||||||
}),
|
}),
|
||||||
|
allow_multiple_instances: Joi.number().optional().valid(0, 1).allow(null),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ log_with_style() {
|
|||||||
if [ -f /etc/alpine-release ]; then
|
if [ -f /etc/alpine-release ]; then
|
||||||
if ! grep -q "^options ndots:0" /etc/resolv.conf 2>/dev/null; then
|
if ! grep -q "^options ndots:0" /etc/resolv.conf 2>/dev/null; then
|
||||||
echo "options ndots:0" >> /etc/resolv.conf
|
echo "options ndots:0" >> /etc/resolv.conf
|
||||||
log_with_style "INFO" "🔧 已配置 DNS 解析优化 (ndots:0)"
|
log_with_style "INFO" "🔧 0. 已配置 DNS 解析优化 (ndots:0)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_with_style "INFO" "🚀 1. 检测配置文件..."
|
log_with_style "INFO" "🚀 1. 检测配置文件..."
|
||||||
load_ql_envs
|
load_ql_envs
|
||||||
export_ql_envs
|
export_ql_envs
|
||||||
. $dir_shell/env.sh
|
. $dir_shell/env.sh
|
||||||
@@ -41,16 +41,16 @@ log_with_style "INFO" "⚙️ 2. 启动 pm2 服务..."
|
|||||||
reload_pm2
|
reload_pm2
|
||||||
|
|
||||||
if [[ $AutoStartBot == true ]]; then
|
if [[ $AutoStartBot == true ]]; then
|
||||||
log_with_style "INFO" "🤖 3. 启动 bot..."
|
log_with_style "INFO" "🤖 3. 启动 bot..."
|
||||||
nohup ql bot >$dir_log/bot.log 2>&1 &
|
nohup ql bot >$dir_log/bot.log 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $EnableExtraShell == true ]]; then
|
if [[ $EnableExtraShell == true ]]; then
|
||||||
log_with_style "INFO" "🛠️ 4. 执行自定义脚本..."
|
log_with_style "INFO" "🛠️ 4. 执行自定义脚本..."
|
||||||
nohup ql extra >$dir_log/extra.log 2>&1 &
|
nohup ql extra >$dir_log/extra.log 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_with_style "SUCCESS" "🎉 容器启动成功!"
|
log_with_style "SUCCESS" "🎉 容器启动成功!"
|
||||||
|
|
||||||
crond -f >/dev/null
|
crond -f >/dev/null
|
||||||
|
|
||||||
|
|||||||
+37
-5
@@ -52,6 +52,7 @@ const push_config = {
|
|||||||
DD_BOT_TOKEN: '', // 钉钉机器人的 DD_BOT_TOKEN
|
DD_BOT_TOKEN: '', // 钉钉机器人的 DD_BOT_TOKEN
|
||||||
|
|
||||||
FSKEY: '', // 飞书机器人的 FSKEY
|
FSKEY: '', // 飞书机器人的 FSKEY
|
||||||
|
FSSECRET: '', // 飞书机器人的 FSSECRET,对应安全设置里的签名校验密钥
|
||||||
|
|
||||||
// 推送到个人QQ:http://127.0.0.1/send_private_msg
|
// 推送到个人QQ:http://127.0.0.1/send_private_msg
|
||||||
// 群:http://127.0.0.1/send_group_msg
|
// 群:http://127.0.0.1/send_group_msg
|
||||||
@@ -481,9 +482,13 @@ function tgBotNotify(text, desp) {
|
|||||||
timeout,
|
timeout,
|
||||||
};
|
};
|
||||||
if (TG_PROXY_HOST && TG_PROXY_PORT) {
|
if (TG_PROXY_HOST && TG_PROXY_PORT) {
|
||||||
|
let proxyHost = TG_PROXY_HOST;
|
||||||
|
if (TG_PROXY_AUTH && !TG_PROXY_HOST.includes('@')) {
|
||||||
|
proxyHost = `${TG_PROXY_AUTH}@${TG_PROXY_HOST}`;
|
||||||
|
}
|
||||||
let agent;
|
let agent;
|
||||||
agent = new ProxyAgent({
|
agent = new ProxyAgent({
|
||||||
uri: `http://${TG_PROXY_AUTH}${TG_PROXY_HOST}:${TG_PROXY_PORT}`,
|
uri: `http://${proxyHost}:${TG_PROXY_PORT}`,
|
||||||
});
|
});
|
||||||
options.dispatcher = agent;
|
options.dispatcher = agent;
|
||||||
}
|
}
|
||||||
@@ -989,11 +994,29 @@ function aibotkNotify(text, desp) {
|
|||||||
|
|
||||||
function fsBotNotify(text, desp) {
|
function fsBotNotify(text, desp) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const { FSKEY } = push_config;
|
const { FSKEY, FSSECRET } = push_config;
|
||||||
if (FSKEY) {
|
if (FSKEY) {
|
||||||
|
const body = {
|
||||||
|
msg_type: 'text',
|
||||||
|
content: { text: `${text}\n\n${desp}` },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add signature if secret is provided
|
||||||
|
// Note: Feishu's signature algorithm uses timestamp+"\n"+secret as the HMAC key
|
||||||
|
// and signs an empty message, which differs from typical HMAC usage
|
||||||
|
if (FSSECRET) {
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const timestamp = Math.floor(Date.now() / 1000).toString();
|
||||||
|
const stringToSign = `${timestamp}\n${FSSECRET}`;
|
||||||
|
const hmac = crypto.createHmac('sha256', stringToSign);
|
||||||
|
const sign = hmac.digest('base64');
|
||||||
|
body.timestamp = timestamp;
|
||||||
|
body.sign = sign;
|
||||||
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
url: `https://open.feishu.cn/open-apis/bot/v2/hook/${FSKEY}`,
|
url: `https://open.feishu.cn/open-apis/bot/v2/hook/${FSKEY}`,
|
||||||
json: { msg_type: 'text', content: { text: `${text}\n\n${desp}` } },
|
json: body,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
@@ -1262,7 +1285,15 @@ function ntfyNotify(text, desp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const { NTFY_URL, NTFY_TOPIC, NTFY_PRIORITY, NTFY_TOKEN, NTFY_USERNAME, NTFY_PASSWORD, NTFY_ACTIONS } = push_config;
|
const {
|
||||||
|
NTFY_URL,
|
||||||
|
NTFY_TOPIC,
|
||||||
|
NTFY_PRIORITY,
|
||||||
|
NTFY_TOKEN,
|
||||||
|
NTFY_USERNAME,
|
||||||
|
NTFY_PASSWORD,
|
||||||
|
NTFY_ACTIONS,
|
||||||
|
} = push_config;
|
||||||
if (NTFY_TOPIC) {
|
if (NTFY_TOPIC) {
|
||||||
const options = {
|
const options = {
|
||||||
url: `${NTFY_URL || 'https://ntfy.sh'}/${NTFY_TOPIC}`,
|
url: `${NTFY_URL || 'https://ntfy.sh'}/${NTFY_TOPIC}`,
|
||||||
@@ -1277,7 +1308,8 @@ function ntfyNotify(text, desp) {
|
|||||||
if (NTFY_TOKEN) {
|
if (NTFY_TOKEN) {
|
||||||
options.headers['Authorization'] = `Bearer ${NTFY_TOKEN}`;
|
options.headers['Authorization'] = `Bearer ${NTFY_TOKEN}`;
|
||||||
} else if (NTFY_USERNAME && NTFY_PASSWORD) {
|
} else if (NTFY_USERNAME && NTFY_PASSWORD) {
|
||||||
options.headers['Authorization'] = `Basic ${Buffer.from(`${NTFY_USERNAME}:${NTFY_PASSWORD}`).toString('base64')}`;
|
options.headers['Authorization'] =
|
||||||
|
`Basic ${Buffer.from(`${NTFY_USERNAME}:${NTFY_PASSWORD}`).toString('base64')}`;
|
||||||
}
|
}
|
||||||
if (NTFY_ACTIONS) {
|
if (NTFY_ACTIONS) {
|
||||||
options.headers['Actions'] = encodeRFC2047(NTFY_ACTIONS);
|
options.headers['Actions'] = encodeRFC2047(NTFY_ACTIONS);
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ push_config = {
|
|||||||
'DD_BOT_TOKEN': '', # 钉钉机器人的 DD_BOT_TOKEN
|
'DD_BOT_TOKEN': '', # 钉钉机器人的 DD_BOT_TOKEN
|
||||||
|
|
||||||
'FSKEY': '', # 飞书机器人的 FSKEY
|
'FSKEY': '', # 飞书机器人的 FSKEY
|
||||||
|
'FSSECRET': '', # 飞书机器人的 FSSECRET,对应安全设置里的签名校验密钥
|
||||||
|
|
||||||
'GOBOT_URL': '', # go-cqhttp
|
'GOBOT_URL': '', # go-cqhttp
|
||||||
# 推送到个人QQ:http://127.0.0.1/send_private_msg
|
# 推送到个人QQ:http://127.0.0.1/send_private_msg
|
||||||
@@ -233,6 +234,20 @@ def feishu_bot(title: str, content: str) -> None:
|
|||||||
|
|
||||||
url = f'https://open.feishu.cn/open-apis/bot/v2/hook/{push_config.get("FSKEY")}'
|
url = f'https://open.feishu.cn/open-apis/bot/v2/hook/{push_config.get("FSKEY")}'
|
||||||
data = {"msg_type": "text", "content": {"text": f"{title}\n\n{content}"}}
|
data = {"msg_type": "text", "content": {"text": f"{title}\n\n{content}"}}
|
||||||
|
|
||||||
|
# Add signature if secret is provided
|
||||||
|
# Note: Feishu's signature algorithm uses timestamp+"\n"+secret as the HMAC key
|
||||||
|
# and signs an empty message, which differs from typical HMAC usage
|
||||||
|
if push_config.get("FSSECRET"):
|
||||||
|
timestamp = str(int(time.time()))
|
||||||
|
string_to_sign = f'{timestamp}\n{push_config.get("FSSECRET")}'
|
||||||
|
hmac_code = hmac.new(
|
||||||
|
string_to_sign.encode("utf-8"), digestmod=hashlib.sha256
|
||||||
|
).digest()
|
||||||
|
sign = base64.b64encode(hmac_code).decode("utf-8")
|
||||||
|
data["timestamp"] = timestamp
|
||||||
|
data["sign"] = sign
|
||||||
|
|
||||||
response = requests.post(url, data=json.dumps(data)).json()
|
response = requests.post(url, data=json.dumps(data)).json()
|
||||||
|
|
||||||
if response.get("StatusCode") == 0 or response.get("code") == 0:
|
if response.get("StatusCode") == 0 or response.get("code") == 0:
|
||||||
|
|||||||
+23
-3
@@ -104,7 +104,7 @@
|
|||||||
"序号": "Number",
|
"序号": "Number",
|
||||||
"备注": "Remarks",
|
"备注": "Remarks",
|
||||||
"更新时间": "Update Time",
|
"更新时间": "Update Time",
|
||||||
"创建时间": "Creation Time",
|
"创建时间": "Created Time",
|
||||||
"确认删除依赖": "Confirm to delete the dependency",
|
"确认删除依赖": "Confirm to delete the dependency",
|
||||||
"确认重新安装": "Confirm to reinstall",
|
"确认重新安装": "Confirm to reinstall",
|
||||||
"确认取消安装": "Confirm to cancel install",
|
"确认取消安装": "Confirm to cancel install",
|
||||||
@@ -252,7 +252,7 @@
|
|||||||
"登录日志": "Login Logs",
|
"登录日志": "Login Logs",
|
||||||
"其他设置": "Other Settings",
|
"其他设置": "Other Settings",
|
||||||
"关于": "About",
|
"关于": "About",
|
||||||
"成功": "Success",
|
"成功": "Successfully",
|
||||||
"失败": "Failure",
|
"失败": "Failure",
|
||||||
"登录时间": "Login Time",
|
"登录时间": "Login Time",
|
||||||
"登录地址": "Login Address",
|
"登录地址": "Login Address",
|
||||||
@@ -389,6 +389,7 @@
|
|||||||
"消息接收人": "message recipient",
|
"消息接收人": "message recipient",
|
||||||
"调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版": "Version, you can specify 'pro' for the Professional version and 'personal' for the Personal version. If left blank, it will default to the Professional version.",
|
"调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版": "Version, you can specify 'pro' for the Professional version and 'personal' for the Personal version. If left blank, it will default to the Professional version.",
|
||||||
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "Feishu group bot: https://www.feishu.cn/hc/zh-CN/articles/360024984973",
|
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "Feishu group bot: https://www.feishu.cn/hc/zh-CN/articles/360024984973",
|
||||||
|
"飞书群组机器人加签密钥,安全设置中开启签名校验后获得": "Feishu group bot signature secret, obtained after enabling signature verification in security settings",
|
||||||
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "Email service name, e.g., 126, 163, Gmail, QQ, etc. Supported list: https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
|
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "Email service name, e.g., 126, 163, Gmail, QQ, etc. Supported list: https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
|
||||||
"邮箱地址": "Email Address",
|
"邮箱地址": "Email Address",
|
||||||
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "The SMTP login password may also be a special passphrase, depending on the specific email service provider's instructions",
|
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "The SMTP login password may also be a special passphrase, depending on the specific email service provider's instructions",
|
||||||
@@ -533,5 +534,24 @@
|
|||||||
"日志名称不能超过100个字符": "Log name cannot exceed 100 characters",
|
"日志名称不能超过100个字符": "Log name cannot exceed 100 characters",
|
||||||
"未启用": "Not enabled",
|
"未启用": "Not enabled",
|
||||||
"默认为 CPU 个数": "Default is the number of CPUs",
|
"默认为 CPU 个数": "Default is the number of CPUs",
|
||||||
"Minimum is 4": "Minimum is 4"
|
"Minimum is 4": "Minimum is 4",
|
||||||
|
"实例模式": "Instance Mode",
|
||||||
|
"单实例模式:定时启动新任务前会自动停止旧任务;多实例模式:允许同时运行多个任务实例": "Single instance mode: automatically stop old task before starting new scheduled task; Multi-instance mode: allow multiple task instances to run simultaneously",
|
||||||
|
"请选择实例模式": "Please select instance mode",
|
||||||
|
"单实例": "Single Instance",
|
||||||
|
"多实例": "Multi-Instance",
|
||||||
|
"SSH密钥": "SSH Keys",
|
||||||
|
"别名": "Alias",
|
||||||
|
"编辑SSH密钥": "Edit SSH Key",
|
||||||
|
"创建SSH密钥": "Create SSH Key",
|
||||||
|
"更新SSH密钥成功": "SSH key updated successfully",
|
||||||
|
"创建SSH密钥成功": "SSH key created successfully",
|
||||||
|
"请输入SSH密钥别名": "Please enter SSH key alias",
|
||||||
|
"请输入SSH私钥": "Please enter SSH private key",
|
||||||
|
"请输入SSH私钥内容(以 -----BEGIN 开头)": "Please enter SSH private key content (starts with -----BEGIN)",
|
||||||
|
"确认删除SSH密钥": "Confirm to delete SSH key",
|
||||||
|
"批量": "Batch",
|
||||||
|
"全局SSH私钥": "Global SSH Private Key",
|
||||||
|
"用于访问所有私有仓库的全局SSH私钥": "Global SSH private key for accessing all private repositories",
|
||||||
|
"请输入完整的SSH私钥内容": "Please enter the complete SSH private key content"
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-1
@@ -389,6 +389,7 @@
|
|||||||
"消息接收人": "消息接收人",
|
"消息接收人": "消息接收人",
|
||||||
"调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版": "调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版",
|
"调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版": "调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版",
|
||||||
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973",
|
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973",
|
||||||
|
"飞书群组机器人加签密钥,安全设置中开启签名校验后获得": "飞书群组机器人加签密钥,安全设置中开启签名校验后获得",
|
||||||
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
|
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
|
||||||
"邮箱地址": "邮箱地址",
|
"邮箱地址": "邮箱地址",
|
||||||
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定",
|
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定",
|
||||||
@@ -533,5 +534,24 @@
|
|||||||
"日志名称不能超过100个字符": "日志名称不能超过100个字符",
|
"日志名称不能超过100个字符": "日志名称不能超过100个字符",
|
||||||
"未启用": "未启用",
|
"未启用": "未启用",
|
||||||
"默认为 CPU 个数": "默认为 CPU 个数",
|
"默认为 CPU 个数": "默认为 CPU 个数",
|
||||||
"最小是 4": "最小是 4"
|
"最小是 4": "最小是 4",
|
||||||
|
"实例模式": "实例模式",
|
||||||
|
"单实例模式:定时启动新任务前会自动停止旧任务;多实例模式:允许同时运行多个任务实例": "单实例模式:定时启动新任务前会自动停止旧任务;多实例模式:允许同时运行多个任务实例",
|
||||||
|
"请选择实例模式": "请选择实例模式",
|
||||||
|
"单实例": "单实例",
|
||||||
|
"多实例": "多实例",
|
||||||
|
"SSH密钥": "SSH密钥",
|
||||||
|
"别名": "别名",
|
||||||
|
"编辑SSH密钥": "编辑SSH密钥",
|
||||||
|
"创建SSH密钥": "创建SSH密钥",
|
||||||
|
"更新SSH密钥成功": "更新SSH密钥成功",
|
||||||
|
"创建SSH密钥成功": "创建SSH密钥成功",
|
||||||
|
"请输入SSH密钥别名": "请输入SSH密钥别名",
|
||||||
|
"请输入SSH私钥": "请输入SSH私钥",
|
||||||
|
"请输入SSH私钥内容(以 -----BEGIN 开头)": "请输入SSH私钥内容(以 -----BEGIN 开头)",
|
||||||
|
"确认删除SSH密钥": "确认删除SSH密钥",
|
||||||
|
"批量": "批量",
|
||||||
|
"全局SSH私钥": "全局SSH私钥",
|
||||||
|
"用于访问所有私有仓库的全局SSH私钥": "用于访问所有私有仓库的全局SSH私钥",
|
||||||
|
"请输入完整的SSH私钥内容": "请输入完整的SSH私钥内容"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import config from '@/utils/config';
|
|||||||
import { request } from '@/utils/http';
|
import { request } from '@/utils/http';
|
||||||
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
||||||
import { Button, Form, Input, Modal, Select, Space, message } from 'antd';
|
import { Button, Form, Input, Modal, Select, Space, message } from 'antd';
|
||||||
import { CronExpressionParser } from 'cron-parser';
|
import CronExpressionParser from 'cron-parser';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { getScheduleType, scheduleTypeMap } from './const';
|
import { getScheduleType, scheduleTypeMap } from './const';
|
||||||
@@ -91,10 +91,14 @@ const CronModal = ({
|
|||||||
{ required: true },
|
{ required: true },
|
||||||
{
|
{
|
||||||
validator: (_, value) => {
|
validator: (_, value) => {
|
||||||
if (!value || CronExpressionParser.parse(value).hasNext()) {
|
try {
|
||||||
return Promise.resolve();
|
if (!value || CronExpressionParser.parse(value).hasNext()) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
return Promise.reject(intl.get('Cron表达式格式有误'));
|
||||||
|
} catch (e) {
|
||||||
|
return Promise.reject(intl.get('Cron表达式格式有误'));
|
||||||
}
|
}
|
||||||
return Promise.reject(intl.get('Cron表达式格式有误'));
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
@@ -180,6 +184,18 @@ const CronModal = ({
|
|||||||
<Form.Item name="labels" label={intl.get('标签')}>
|
<Form.Item name="labels" label={intl.get('标签')}>
|
||||||
<EditableTagGroup />
|
<EditableTagGroup />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="allow_multiple_instances"
|
||||||
|
label={intl.get('实例模式')}
|
||||||
|
tooltip={intl.get(
|
||||||
|
'单实例模式:定时启动新任务前会自动停止旧任务;多实例模式:允许同时运行多个任务实例',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Select placeholder={intl.get('请选择实例模式')}>
|
||||||
|
<Select.Option value={0}>{intl.get('单实例')}</Select.Option>
|
||||||
|
<Select.Option value={1}>{intl.get('多实例')}</Select.Option>
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="log_name"
|
name="log_name"
|
||||||
label={intl.get('日志名称')}
|
label={intl.get('日志名称')}
|
||||||
@@ -194,7 +210,11 @@ const CronModal = ({
|
|||||||
if (value.length > 100) {
|
if (value.length > 100) {
|
||||||
return Promise.reject(intl.get('日志名称不能超过100个字符'));
|
return Promise.reject(intl.get('日志名称不能超过100个字符'));
|
||||||
}
|
}
|
||||||
if (!/^(?!.*(?:^|\/)\.{1,2}(?:\/|$))(?:\/)?(?:[\w.-]+\/)*[\w.-]+\/?$/.test(value)) {
|
if (
|
||||||
|
!/^(?!.*(?:^|\/)\.{1,2}(?:\/|$))(?:\/)?(?:[\w.-]+\/)*[\w.-]+\/?$/.test(
|
||||||
|
value,
|
||||||
|
)
|
||||||
|
) {
|
||||||
return Promise.reject(
|
return Promise.reject(
|
||||||
intl.get('日志名称只能包含字母、数字、下划线和连字符'),
|
intl.get('日志名称只能包含字母、数字、下划线和连字符'),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export interface ICrontab {
|
|||||||
nextRunTime: Date;
|
nextRunTime: Date;
|
||||||
sub_id: number;
|
sub_id: number;
|
||||||
extra_schedules?: Array<{ schedule: string }>;
|
extra_schedules?: Array<{ schedule: string }>;
|
||||||
|
allow_multiple_instances?: 1 | 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ScheduleType {
|
export enum ScheduleType {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const SaveModal = ({
|
|||||||
|
|
||||||
const handleOk = async (values: any) => {
|
const handleOk = async (values: any) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const payload = { ...file, ...values, originFilename: file.title };
|
const payload = { ...values, originFilename: file.title, content: file.content };
|
||||||
request
|
request
|
||||||
.post(`${config.apiPrefix}scripts`, payload)
|
.post(`${config.apiPrefix}scripts`, payload)
|
||||||
.then(({ code, data }) => {
|
.then(({ code, data }) => {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ const dataMap = {
|
|||||||
'log-remove-frequency': 'logRemoveFrequency',
|
'log-remove-frequency': 'logRemoveFrequency',
|
||||||
'cron-concurrency': 'cronConcurrency',
|
'cron-concurrency': 'cronConcurrency',
|
||||||
timezone: 'timezone',
|
timezone: 'timezone',
|
||||||
|
'global-ssh-key': 'globalSshKey',
|
||||||
};
|
};
|
||||||
|
|
||||||
const exportModules = [
|
const exportModules = [
|
||||||
@@ -54,6 +55,7 @@ const Other = ({
|
|||||||
logRemoveFrequency?: number | null;
|
logRemoveFrequency?: number | null;
|
||||||
cronConcurrency?: number | null;
|
cronConcurrency?: number | null;
|
||||||
timezone?: string | null;
|
timezone?: string | null;
|
||||||
|
globalSshKey?: string | null;
|
||||||
}>();
|
}>();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [exportLoading, setExportLoading] = useState(false);
|
const [exportLoading, setExportLoading] = useState(false);
|
||||||
@@ -308,6 +310,32 @@ const Other = ({
|
|||||||
</Button>
|
</Button>
|
||||||
</Input.Group>
|
</Input.Group>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
label={intl.get('全局SSH私钥')}
|
||||||
|
name="globalSshKey"
|
||||||
|
tooltip={intl.get('用于访问所有私有仓库的全局SSH私钥')}
|
||||||
|
>
|
||||||
|
<Input.Group compact>
|
||||||
|
<Input.TextArea
|
||||||
|
value={systemConfig?.globalSshKey || ''}
|
||||||
|
style={{ width: 264 }}
|
||||||
|
autoSize={{ minRows: 3, maxRows: 8 }}
|
||||||
|
placeholder={intl.get('请输入完整的SSH私钥内容')}
|
||||||
|
onChange={(e) => {
|
||||||
|
setSystemConfig({ ...systemConfig, globalSshKey: e.target.value });
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Input.Group>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={() => {
|
||||||
|
updateSystemConfig('global-ssh-key');
|
||||||
|
}}
|
||||||
|
style={{ width: 264, marginTop: 8 }}
|
||||||
|
>
|
||||||
|
{intl.get('确认')}
|
||||||
|
</Button>
|
||||||
|
</Form.Item>
|
||||||
<Form.Item label={intl.get('语言')} name="lang">
|
<Form.Item label={intl.get('语言')} name="lang">
|
||||||
<Select
|
<Select
|
||||||
defaultValue={localStorage.getItem('lang') || ''}
|
defaultValue={localStorage.getItem('lang') || ''}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
} from 'antd';
|
} from 'antd';
|
||||||
import { request } from '@/utils/http';
|
import { request } from '@/utils/http';
|
||||||
import config from '@/utils/config';
|
import config from '@/utils/config';
|
||||||
import { CronExpressionParser } from 'cron-parser';
|
import CronExpressionParser from 'cron-parser';
|
||||||
import isNil from 'lodash/isNil';
|
import isNil from 'lodash/isNil';
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
@@ -378,13 +378,17 @@ const SubscriptionModal = ({
|
|||||||
{ required: true },
|
{ required: true },
|
||||||
{
|
{
|
||||||
validator: (rule, value) => {
|
validator: (rule, value) => {
|
||||||
if (
|
try {
|
||||||
scheduleType === 'interval' ||
|
if (
|
||||||
!value ||
|
scheduleType === 'interval' ||
|
||||||
CronExpressionParser.parse(value).hasNext()
|
!value ||
|
||||||
) {
|
CronExpressionParser.parse(value).hasNext()
|
||||||
return Promise.resolve();
|
) {
|
||||||
} else {
|
return Promise.resolve();
|
||||||
|
} else {
|
||||||
|
return Promise.reject(intl.get('Subscription表达式格式有误'));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
return Promise.reject(intl.get('Subscription表达式格式有误'));
|
return Promise.reject(intl.get('Subscription表达式格式有误'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -395,6 +395,12 @@ export default {
|
|||||||
),
|
),
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'larkSecret',
|
||||||
|
tip: intl.get(
|
||||||
|
'飞书群组机器人加签密钥,安全设置中开启签名校验后获得',
|
||||||
|
),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
email: [
|
email: [
|
||||||
{
|
{
|
||||||
|
|||||||
+6
-6
@@ -84,12 +84,12 @@ let _request = axios.create({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const apiWhiteList = [
|
const apiWhiteList = [
|
||||||
'/api/user/login',
|
`${config.baseUrl}api/user/login`,
|
||||||
'/open/auth/token',
|
`${config.baseUrl}open/auth/token`,
|
||||||
'/api/user/two-factor/login',
|
`${config.baseUrl}api/user/two-factor/login`,
|
||||||
'/api/system',
|
`${config.baseUrl}api/system`,
|
||||||
'/api/user/init',
|
`${config.baseUrl}api/user/init`,
|
||||||
'/api/user/notification/init',
|
`${config.baseUrl}api/user/notification/init`,
|
||||||
];
|
];
|
||||||
|
|
||||||
_request.interceptors.request.use((_config) => {
|
_request.interceptors.request.use((_config) => {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { LANG_MAP, LOG_END_SYMBOL } from './const';
|
import { LANG_MAP, LOG_END_SYMBOL } from './const';
|
||||||
import { CronExpressionParser } from 'cron-parser';
|
import CronExpressionParser from 'cron-parser';
|
||||||
import { ICrontab } from '@/pages/crontab/type';
|
import { ICrontab } from '@/pages/crontab/type';
|
||||||
|
|
||||||
export default function browserType() {
|
export default function browserType() {
|
||||||
|
|||||||
+10
-9
@@ -1,10 +1,11 @@
|
|||||||
version: 2.19.2
|
version: 2.20.1
|
||||||
changeLogLink: https://t.me/jiao_long/431
|
changeLogLink: https://t.me/jiao_long/433
|
||||||
publishTime: 2025-06-27 23:59
|
publishTime: 2025-12-26 22:00
|
||||||
changeLog: |
|
changeLog: |
|
||||||
1. 备份数据支持选择模块,支持清除依赖缓存
|
1. 修复获取依赖管理列表
|
||||||
2. QLAPI 和 openapi 的 systemNotify 支持自定义通知类型和参数
|
2. notify.js 修复 TG_PROXY_AUTH 参数拼接
|
||||||
3. ntfy 增加可选的认证与用户动作,感谢 https://github.com/liheji
|
3. QLAPI.notify larkSecret 参数
|
||||||
4. 修复取消安装依赖
|
4. 修复 cron parser 定时规则校验
|
||||||
5. 修复环境变量过大解析报错
|
5. 修复设置 baseUrl 后无法访问
|
||||||
6. 修改服务启动方式
|
6. 修复环境变量排序
|
||||||
|
7. 修复定时任务无法停止
|
||||||
Reference in New Issue
Block a user