Skip to content

Commit 70592b0

Browse files
committed
Refactor finalmask
1 parent f37805e commit 70592b0

3 files changed

Lines changed: 465 additions & 285 deletions

File tree

docs/config/transports/finalmask.md

Lines changed: 155 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -73,51 +73,57 @@ FinalMask 在核心处理完包括 TLS/REALITY 在内的传输层加密后,对
7373
}
7474
```
7575

76-
> `type`: header-custom | fragment | sudoku
76+
> `type`: string
7777
7878
该层伪装的类型。
7979

80-
> `settings`: header-custom | fragment | sudoku
80+
> `settings`: string
8181
82-
该伪装类型的具体设置(每个类型的字段见下)
82+
该伪装类型的具体设置。
83+
84+
每个类型的字段见下
8385

8486
### header-custom
8587

8688
```json
8789
{
88-
"clients": [
89-
[
90-
{
91-
"delay": 0,
92-
"rand": 0,
93-
"randRange": "0-255",
94-
"type": "",
95-
"packet": []
96-
}
97-
]
98-
],
99-
"servers": [
100-
[
101-
{
102-
"delay": 0,
103-
"rand": 0,
104-
"randRange": "0-255",
105-
"type": "",
106-
"packet": []
107-
}
108-
]
109-
],
110-
"errors": [
111-
[
112-
{
113-
"delay": 0,
114-
"rand": 0,
115-
"randRange": "0-255",
116-
"type": "",
117-
"packet": []
118-
}
90+
"type": "header-custom",
91+
// [!code focus:35]
92+
"settings": {
93+
"clients": [
94+
[
95+
{
96+
"delay": 0,
97+
"rand": 0,
98+
"randRange": "0-255",
99+
"type": "",
100+
"packet": []
101+
}
102+
]
103+
],
104+
"servers": [
105+
[
106+
{
107+
"delay": 0,
108+
"rand": 0,
109+
"randRange": "0-255",
110+
"type": "",
111+
"packet": []
112+
}
113+
]
114+
],
115+
"errors": [
116+
[
117+
{
118+
"delay": 0,
119+
"rand": 0,
120+
"randRange": "0-255",
121+
"type": "",
122+
"packet": []
123+
}
124+
]
119125
]
120-
]
126+
}
121127
}
122128
```
123129

@@ -135,10 +141,14 @@ FinalMask 在核心处理完包括 TLS/REALITY 在内的传输层加密后,对
135141

136142
```json
137143
{
138-
"packets": "tlshello",
139-
"length": "100-200",
140-
"delay": "10-20",
141-
"maxSplit": "3-6"
144+
"type": "fragment",
145+
// [!code focus:6]
146+
"settings": {
147+
"packets": "tlshello",
148+
"length": "100-200",
149+
"delay": "10-20",
150+
"maxSplit": "3-6"
151+
}
142152
}
143153
```
144154

@@ -160,14 +170,18 @@ FinalMask 在核心处理完包括 TLS/REALITY 在内的传输层加密后,对
160170

161171
```json
162172
{
163-
"password": "",
164-
"ascii": "",
173+
"type": "sudoku",
174+
// [!code focus:10]
175+
"settings": {
176+
"password": "",
177+
"ascii": "",
165178

166-
"customTable": "", // 官方文档字段名为 custom_table
167-
"customTables": [""], // 官方文档字段名为 custom_tables
179+
"customTable": "", // 官方文档字段名为 custom_table
180+
"customTables": [""], // 官方文档字段名为 custom_tables
168181

169-
"paddingMin": 0, // 官方文档字段名为 padding_min
170-
"paddingMax": 0 // 官方文档字段名为 padding_max
182+
"paddingMin": 0, // 官方文档字段名为 padding_min
183+
"paddingMax": 0 // 官方文档字段名为 padding_max
184+
}
171185
}
172186
```
173187

@@ -191,36 +205,42 @@ FinalMask 在核心处理完包括 TLS/REALITY 在内的传输层加密后,对
191205
}
192206
```
193207

194-
> `type`: header-custom | header-dns | header-dtls | header-srtp | header-utp | header-wechat | header-wireguard | mkcp-original | mkcp-aes128gcm | noise | salamander | sudoku | xdns | xicmp
208+
> `type`: string
195209
196210
该层伪装的类型。
197211

198-
> `settings`: header-custom | header-dns | mkcp-aes128gcm | noise | salamander | sudoku | xdns | xicmp
212+
> `settings`: string
213+
214+
该伪装类型的具体设置。
199215

200-
该伪装类型的具体设置(每个类型的字段见下
216+
每个类型的字段见下
201217

202218
### header-custom
203219

204220
总是合包到数据包头。
205221

206222
```json
207223
{
208-
"client": [
209-
{
210-
"rand": 0,
211-
"randRange": "0-255",
212-
"type": "",
213-
"packet": []
214-
}
215-
],
216-
"server": [
217-
{
218-
"rand": 0,
219-
"randRange": "0-255",
220-
"type": "",
221-
"packet": []
222-
}
223-
]
224+
"type": "header-custom",
225+
// [!code focus:18]
226+
"settings": {
227+
"client": [
228+
{
229+
"rand": 0,
230+
"randRange": "0-255",
231+
"type": "",
232+
"packet": []
233+
}
234+
],
235+
"server": [
236+
{
237+
"rand": 0,
238+
"randRange": "0-255",
239+
"type": "",
240+
"packet": []
241+
}
242+
]
243+
}
224244
}
225245
```
226246

@@ -236,31 +256,51 @@ FinalMask 在核心处理完包括 TLS/REALITY 在内的传输层加密后,对
236256

237257
```json
238258
{
239-
"header": "", // dns dtls srtp utp wechat wireguard
240-
"value": "" // password domain
259+
"type": "mkcp-legacy",
260+
// [!code focus:4]
261+
"settings": {
262+
"header": "", // dns dtls srtp utp wechat wireguard
263+
"value": "" // password domain
264+
}
241265
}
242266
```
243267

244-
`header`: empty for original & aes128gcm
268+
旧 mKCP 的包头伪装/混淆,`value` 的含义随 `header` 变化。注意伪造只是简单的包头伪造,不代表实现了完整协议。
269+
270+
> 为空时: 进行 AES-128-GCM 加密,`value` 为其密码,若 `value` 为空则改为使用默认的简单 xor 混淆。
271+
272+
> `dns`: 伪造为 DNS 查询,`value` 为指定的域名,为空时默认 `www.baidu.com`
273+
274+
> `dtls`: 伪造为 DTLS 1.2 应用数据,`value` 无作用。
245275
246-
`value`: empty for original
276+
> `srtp`: 伪造为 SRTP。`value` 无作用。
277+
278+
> `utp`: 伪造为 uTP(BitTorrent)。`value` 无作用。
279+
280+
> `wechat`: 伪造为微信视频通话头,序号递增。`value` 无作用。
281+
282+
> `wireguard`: 伪造为 WireGuard。`value` 无作用。
247283
248284
### noise
249285

250286
在发送数据前发送的噪声。
251287

252288
```json
253289
{
254-
"reset": "30-60",
255-
"noise": [
256-
{
257-
"rand": "1-8192",
258-
"randRange": "0-255",
259-
"type": "",
260-
"packet": [],
261-
"delay": "10-20"
262-
}
263-
]
290+
"type": "noise",
291+
// [!code focus:12]
292+
"settings": {
293+
"reset": "30-60",
294+
"noise": [
295+
{
296+
"rand": "1-8192",
297+
"randRange": "0-255",
298+
"type": "",
299+
"packet": [],
300+
"delay": "10-20"
301+
}
302+
]
303+
}
264304
}
265305
```
266306

@@ -282,22 +322,30 @@ Salamander 混淆。(来自 Hysteria2)
282322

283323
```json
284324
{
285-
"password": "your-password"
325+
"type": "salamander",
326+
// [!code focus:3]
327+
"settings": {
328+
"password": "your-password"
329+
}
286330
}
287331
```
288332

289333
### sudoku
290334

291335
```json
292336
{
293-
"password": "",
294-
"ascii": "",
337+
"type": "sudoku",
338+
// [!code focus:10]
339+
"settings": {
340+
"password": "",
341+
"ascii": "",
295342

296-
"customTable": "",
297-
"customTables": [""],
343+
"customTable": "",
344+
"customTables": [""],
298345

299-
"paddingMin": 0,
300-
"paddingMax": 0
346+
"paddingMin": 0,
347+
"paddingMax": 0
348+
}
301349
}
302350
```
303351

@@ -317,8 +365,12 @@ Salamander 混淆。(来自 Hysteria2)
317365

318366
```json
319367
{
320-
"domains": ["t.example.com"],
321-
"resolvers": ["t.example.com+udp://8.8.8.8:53"]
368+
"type": "xdns",
369+
// [!code focus:4]
370+
"settings": {
371+
"domains": ["t.example.com"],
372+
"resolvers": ["t.example.com+udp://8.8.8.8:53"]
373+
}
322374
}
323375
```
324376

@@ -332,8 +384,12 @@ Salamander 混淆。(来自 Hysteria2)
332384

333385
```json
334386
{
335-
"dgram": false, // optional
336-
"ips": [] // optional
387+
"type": "xicmp",
388+
// [!code focus:4]
389+
"settings": {
390+
"dgram": false, // optional
391+
"ips": [] // optional
392+
}
337393
}
338394
```
339395

@@ -347,12 +403,16 @@ Salamander 混淆。(来自 Hysteria2)
347403

348404
```json
349405
{
350-
"url": "realm://public@xxx/your-realm-name",
351-
"stunServers": [
352-
"stun.nextcloud.com:3478",
353-
"global.stun.twilio.com:3478"
354-
],
355-
"tlsConfig": {} // optional
406+
"type": "realm",
407+
// [!code focus:8]
408+
"settings": {
409+
"url": "realm://public@xxx/your-realm-name",
410+
"stunServers": [
411+
"stun.nextcloud.com:3478",
412+
"global.stun.twilio.com:3478"
413+
],
414+
"tlsConfig": {} // optional
415+
}
356416
}
357417
```
358418

0 commit comments

Comments
 (0)