Skip to content

Commit a3b3836

Browse files
committed
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.
1 parent b9f61cc commit a3b3836

8 files changed

Lines changed: 46 additions & 50 deletions

File tree

packages/napcat-core/external/napcat.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
"o3HookMode": 1,
99
"bypass": {
1010
"hook": true,
11-
"module": true,
1211
"window": true,
13-
"js": true,
12+
"module": true,
13+
"process": true,
1414
"container": true,
15-
"maps": true
15+
"js": true
1616
}
1717
}

packages/napcat-core/helper/config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import { AnySchema } from 'ajv';
55

66
export const BypassOptionsSchema = Type.Object({
77
hook: Type.Boolean({ default: true }),
8-
module: Type.Boolean({ default: true }),
98
window: Type.Boolean({ default: true }),
10-
js: Type.Boolean({ default: true }),
9+
module: Type.Boolean({ default: true }),
10+
process: Type.Boolean({ default: true }),
1111
container: Type.Boolean({ default: true }),
12-
maps: Type.Boolean({ default: true }),
12+
js: Type.Boolean({ default: true }),
1313
});
1414

1515
export const NapcatConfigSchema = Type.Object({

packages/napcat-core/packet/handler/napi2nativeLoader.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { LogWrapper } from '../../helper/log';
66

77
export interface BypassOptions {
88
hook?: boolean;
9-
module?: boolean;
109
window?: boolean;
11-
js?: boolean;
10+
module?: boolean;
11+
process?: boolean;
1212
container?: boolean;
13-
maps?: boolean;
13+
js?: boolean;
1414
}
1515

1616
export interface Napi2NativeExportType {

packages/napcat-framework/napcat.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ export async function NCoreInitFramework (
5050
// 读取 napcat.json 配置
5151
let bypassOptions: BypassOptions = {
5252
hook: false,
53-
module: false,
5453
window: false,
55-
js: false,
54+
module: false,
55+
process: false,
5656
container: false,
57-
maps: false,
57+
js: false,
5858
};
5959
try {
6060
const configFile = path.join(pathWrapper.configPath, 'napcat.json');

packages/napcat-shell/base.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,14 @@ import { connectToNamedPipe } from './pipe';
5151
function loadBypassConfig (configPath: string, logger: LogWrapper): BypassOptions {
5252
const defaultOptions: BypassOptions = {
5353
hook: true,
54-
module: true,
5554
window: true,
56-
js: true,
55+
module: true,
56+
process: true,
5757
container: true,
58-
maps: true,
58+
js: true,
5959
};
6060

6161
let options = { ...defaultOptions };
62-
6362
try {
6463
const configFile = path.join(configPath, 'napcat.json');
6564
if (fs.existsSync(configFile)) {
@@ -72,13 +71,11 @@ function loadBypassConfig (configPath: string, logger: LogWrapper): BypassOption
7271
} catch (e) {
7372
logger.logWarn('[NapCat] 读取 bypass 配置失败,使用默认值:', e);
7473
}
75-
7674
// 根据分步禁用级别覆盖配置
7775
const disableLevel = parseInt(process.env['NAPCAT_BYPASS_DISABLE_LEVEL'] || '0', 10);
7876
if (disableLevel > 0) {
7977
const levelDescriptions = ['全部启用', '禁用 hook', '禁用 hook + module', '全部禁用 bypass'];
8078
logger.logWarn(`[NapCat] 崩溃恢复:当前 bypass 禁用级别 ${disableLevel} (${levelDescriptions[disableLevel] ?? '未知'})`);
81-
8279
if (disableLevel >= 1) {
8380
options.hook = false;
8481
}
@@ -87,14 +84,13 @@ function loadBypassConfig (configPath: string, logger: LogWrapper): BypassOption
8784
}
8885
if (disableLevel >= 3) {
8986
options.hook = false;
90-
options.module = false;
9187
options.window = false;
92-
options.js = false;
88+
options.module = false;
89+
options.process = false;
9390
options.container = false;
94-
options.maps = false;
91+
options.js = false;
9592
}
9693
}
97-
9894
return options;
9995
}
10096
// NapCat Shell App ES 入口文件

packages/napcat-webui-backend/src/api/NapCatConfig.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ const defaultNapcatConfig = {
1616
o3HookMode: 1,
1717
bypass: {
1818
hook: true,
19-
module: true,
2019
window: true,
21-
js: true,
20+
module: true,
21+
process: true,
2222
container: true,
23-
maps: true,
23+
js: true,
2424
},
2525
};
2626

@@ -81,7 +81,7 @@ export const NapCatSetConfigHandler: RequestHandler = (req, res) => {
8181
// 验证 bypass 字段
8282
if (mergedConfig.bypass && typeof mergedConfig.bypass === 'object') {
8383
const bypass = mergedConfig.bypass as Record<string, unknown>;
84-
const validKeys = ['hook', 'module', 'window', 'js', 'container', 'maps'];
84+
const validKeys = ['hook', 'window', 'module', 'process', 'container', 'js'];
8585
for (const key of validKeys) {
8686
if (key in bypass && typeof bypass[key] !== 'boolean') {
8787
return sendError(res, `bypass.${key} must be boolean`);

packages/napcat-webui-frontend/src/pages/dashboard/config/bypass.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ import QQManager from '@/controllers/qq_manager';
1010

1111
interface BypassFormData {
1212
hook: boolean;
13-
module: boolean;
1413
window: boolean;
15-
js: boolean;
14+
module: boolean;
15+
process: boolean;
1616
container: boolean;
17-
maps: boolean;
17+
js: boolean;
1818
}
1919

2020
const defaultBypass: BypassFormData = {
2121
hook: true,
22-
module: true,
2322
window: true,
24-
js: true,
23+
module: true,
24+
process: true,
2525
container: true,
26-
maps: true,
26+
js: true,
2727
};
2828

2929
const BypassConfigCard = () => {
@@ -43,11 +43,11 @@ const BypassConfigCard = () => {
4343
const config = await QQManager.getNapCatConfig();
4444
const bypass = config.bypass ?? defaultBypass;
4545
setValue('hook', bypass.hook ?? true);
46-
setValue('module', bypass.module ?? true);
4746
setValue('window', bypass.window ?? true);
48-
setValue('js', bypass.js ?? true);
47+
setValue('module', bypass.module ?? true);
48+
setValue('process', bypass.process ?? true);
4949
setValue('container', bypass.container ?? true);
50-
setValue('maps', bypass.maps ?? true);
50+
setValue('js', bypass.js ?? true);
5151
if (showTip) toast.success('刷新成功');
5252
} catch (error) {
5353
const msg = (error as Error).message;
@@ -103,34 +103,34 @@ const BypassConfigCard = () => {
103103
/>
104104
<Controller
105105
control={control}
106-
name='module'
106+
name='window'
107107
render={({ field }) => (
108108
<SwitchCard
109109
{...field}
110-
label='Module'
111-
description='加载模块隐藏'
110+
label='Window'
111+
description='窗口伪造'
112112
/>
113113
)}
114114
/>
115115
<Controller
116116
control={control}
117-
name='window'
117+
name='module'
118118
render={({ field }) => (
119119
<SwitchCard
120120
{...field}
121-
label='Window'
122-
description='窗口伪造'
121+
label='Module'
122+
description='加载模块隐藏'
123123
/>
124124
)}
125125
/>
126126
<Controller
127127
control={control}
128-
name='js'
128+
name='process'
129129
render={({ field }) => (
130130
<SwitchCard
131131
{...field}
132-
label='JS'
133-
description='JS Bypass(保留)'
132+
label='Process'
133+
description='进程反检测'
134134
/>
135135
)}
136136
/>
@@ -147,12 +147,12 @@ const BypassConfigCard = () => {
147147
/>
148148
<Controller
149149
control={control}
150-
name='maps'
150+
name='js'
151151
render={({ field }) => (
152152
<SwitchCard
153153
{...field}
154-
label='Maps'
155-
description='linux maps反检测'
154+
label='JS'
155+
description='JS反检测'
156156
/>
157157
)}
158158
/>

packages/napcat-webui-frontend/src/types/napcat_conf.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
interface BypassOptions {
22
hook: boolean;
3-
module: boolean;
43
window: boolean;
5-
js: boolean;
4+
module: boolean;
5+
process: boolean;
66
container: boolean;
7-
maps: boolean;
7+
js: boolean;
88
}
99

1010
interface NapCatConfig {

0 commit comments

Comments
 (0)