Add process bypass option and update bypass fields

Introduce a new 'process' bypass option and remove the old 'maps' key, updating all related schemas, types, defaults and validation. Adjusted napcat.json ordering and NapcatConfig defaults, updated BypassOptions schema and TypeScript interfaces, backend validation keys, loader/default parsing logic, and the web UI form mappings/labels to reflect the new field set and ordering.
This commit is contained in:
手瓜一十雪
2026-02-18 22:14:31 +08:00
parent b9f61cc0ee
commit a3b3836b8a
8 changed files with 51 additions and 55 deletions

View File

@@ -51,15 +51,14 @@ import { connectToNamedPipe } from './pipe';
function loadBypassConfig (configPath: string, logger: LogWrapper): BypassOptions {
const defaultOptions: BypassOptions = {
hook: true,
module: true,
window: true,
js: true,
module: true,
process: true,
container: true,
maps: true,
js: true,
};
let options = { ...defaultOptions };
try {
const configFile = path.join(configPath, 'napcat.json');
if (fs.existsSync(configFile)) {
@@ -72,13 +71,11 @@ function loadBypassConfig (configPath: string, logger: LogWrapper): BypassOption
} catch (e) {
logger.logWarn('[NapCat] 读取 bypass 配置失败,使用默认值:', e);
}
// 根据分步禁用级别覆盖配置
const disableLevel = parseInt(process.env['NAPCAT_BYPASS_DISABLE_LEVEL'] || '0', 10);
if (disableLevel > 0) {
const levelDescriptions = ['全部启用', '禁用 hook', '禁用 hook + module', '全部禁用 bypass'];
logger.logWarn(`[NapCat] 崩溃恢复:当前 bypass 禁用级别 ${disableLevel} (${levelDescriptions[disableLevel] ?? '未知'})`);
if (disableLevel >= 1) {
options.hook = false;
}
@@ -87,14 +84,13 @@ function loadBypassConfig (configPath: string, logger: LogWrapper): BypassOption
}
if (disableLevel >= 3) {
options.hook = false;
options.module = false;
options.window = false;
options.js = false;
options.module = false;
options.process = false;
options.container = false;
options.maps = false;
options.js = false;
}
}
return options;
}
// NapCat Shell App ES 入口文件