mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-03-01 08:10:25 +00:00
Add configurable bypass options and UI
Introduce granular "bypass" configuration to control Napi2Native bypass features and expose it in the WebUI. Key changes: - Add bypass defaults to packages/napcat-core/external/napcat.json and BypassOptionsSchema in napcat-core helper config. - Extend Napi2NativeLoader types: enableAllBypasses now accepts BypassOptions. - Framework & Shell: load napcat.json (via json5), pass parsed bypass options to native loader, and log the applied config. Add json5 dependency. - Shell: implement loadBypassConfig with a crash-recovery override (NAPCAT_BYPASS_DISABLE_LEVEL) and add master<->worker IPC (login-success) plus progressive bypass-disable strategy to mitigate repeated crashes before login. - WebUI backend: add GET/Set endpoints for NapCat config (NapCatConfigRouter) with validation and JSON5-aware defaults. - WebUI frontend: add BypassConfig page, types, and controller methods to get/set bypass config. - Update package.json to include json5 and update pnpm lockfile; native binaries (.node / ffmpeg.dll) also updated. This enables operators to tune bypass behavior per-installation and to have an in-UI control for toggling anti-detection features; it also adds progressive fallback behavior to help recover from crashes caused by bypasses.
This commit is contained in:
10
packages/napcat-core/external/napcat.json
vendored
10
packages/napcat-core/external/napcat.json
vendored
@@ -5,5 +5,13 @@
|
||||
"consoleLogLevel": "info",
|
||||
"packetBackend": "auto",
|
||||
"packetServer": "",
|
||||
"o3HookMode": 1
|
||||
"o3HookMode": 1,
|
||||
"bypass": {
|
||||
"hook": true,
|
||||
"module": true,
|
||||
"window": true,
|
||||
"js": true,
|
||||
"container": true,
|
||||
"maps": true
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,15 @@ import { NapCatCore } from '@/napcat-core/index';
|
||||
import { Type, Static } from '@sinclair/typebox';
|
||||
import { AnySchema } from 'ajv';
|
||||
|
||||
export const BypassOptionsSchema = Type.Object({
|
||||
hook: Type.Boolean({ default: true }),
|
||||
module: Type.Boolean({ default: true }),
|
||||
window: Type.Boolean({ default: true }),
|
||||
js: Type.Boolean({ default: true }),
|
||||
container: Type.Boolean({ default: true }),
|
||||
maps: Type.Boolean({ default: true }),
|
||||
});
|
||||
|
||||
export const NapcatConfigSchema = Type.Object({
|
||||
fileLog: Type.Boolean({ default: false }),
|
||||
consoleLog: Type.Boolean({ default: true }),
|
||||
@@ -11,6 +20,7 @@ export const NapcatConfigSchema = Type.Object({
|
||||
packetBackend: Type.String({ default: 'auto' }),
|
||||
packetServer: Type.String({ default: '' }),
|
||||
o3HookMode: Type.Number({ default: 0 }),
|
||||
bypass: Type.Optional(BypassOptionsSchema),
|
||||
});
|
||||
|
||||
export type NapcatConfig = Static<typeof NapcatConfigSchema>;
|
||||
|
||||
@@ -4,10 +4,19 @@ import fs from 'fs';
|
||||
import { constants } from 'node:os';
|
||||
import { LogWrapper } from '../../helper/log';
|
||||
|
||||
export interface BypassOptions {
|
||||
hook?: boolean;
|
||||
module?: boolean;
|
||||
window?: boolean;
|
||||
js?: boolean;
|
||||
container?: boolean;
|
||||
maps?: boolean;
|
||||
}
|
||||
|
||||
export interface Napi2NativeExportType {
|
||||
initHook?: (send: string, recv: string) => boolean;
|
||||
setVerbose?: (verbose: boolean) => void; // 默认关闭日志
|
||||
enableAllBypasses?: () => void;
|
||||
enableAllBypasses?: (options?: BypassOptions) => boolean;
|
||||
}
|
||||
|
||||
export class Napi2NativeLoader {
|
||||
|
||||
Reference in New Issue
Block a user