Skip to content

Commit fad0551

Browse files
committed
Add udp mask
EN Add udp mask RU Add udp mask Prettified Code!
1 parent 303cbf1 commit fad0551

File tree

6 files changed

+353
-129
lines changed

6 files changed

+353
-129
lines changed

docs/config/transport.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
"grpcSettings": {},
2121
"wsSettings": {},
2222
"httpupgradeSettings": {},
23+
"finalmask": {
24+
"udp": []
25+
},
2326
"sockopt": {
2427
"mark": 0,
2528
"tcpMaxSeg": 1440,
@@ -102,6 +105,10 @@ Reality 是目前最安全的传输加密方案, 且外部看来流量类型和
102105
103106
透明代理相关的具体配置。
104107

108+
> `finalmask`: [FinalMaskObject](#finalmaskobject)
109+
110+
FinalMask 配置,用于对流量进行通用伪装。
111+
105112
### TLSObject
106113

107114
```json
@@ -901,3 +908,110 @@ RFC-8305 中的 "First Address Family count", 默认值为 1. 它定义了对不
901908
> `maxConcurrentTry`: number
902909
903910
最大并发数量,用于防止解析出的IP过多且均未成功时候核心也对这些IP产生大量连接。默认为4, 设置为0代表禁用 happyEyeballs.
911+
912+
### FinalMaskObject
913+
914+
FinalMask 在核心处理完包括 TLS/REALITY 在内的传输层加密后,对流量进行最后一层伪装。
915+
916+
目前仅有 UDP 支持。
917+
918+
```json
919+
{
920+
"udp": [
921+
{
922+
"type": "header-dns",
923+
"settings": {
924+
"domain": "www.baidu.com"
925+
}
926+
}
927+
]
928+
}
929+
```
930+
931+
> `udp`: \[ list \]
932+
933+
一个数组,表示应用于 UDP 流量的伪装列表。多个伪装会按顺序一层层应用。
934+
935+
settings 根据伪装类型不同,见下。
936+
937+
> `mkcp-original`
938+
939+
mKCP 曾经默认应用的简单混淆,你可能需要配置它来连接以前的 mKCP 服务器。无额外配置。
940+
941+
> `mkcp-aes128gcm`
942+
943+
对应原 mKCP 的 `seed` 功能。使用 AES-128-GCM 进行混淆。
944+
945+
- `settings`:
946+
```json
947+
{
948+
"password": "your-password"
949+
}
950+
```
951+
952+
`password` 为加密密码,服务端客户端需一致。
953+
954+
> `header-dns`
955+
956+
对应原 mKCP 的 DNS 伪装。
957+
958+
- `settings`:
959+
```json
960+
{
961+
"domain": "www.example.com"
962+
}
963+
```
964+
965+
`domain` 为用于伪装的域名。
966+
967+
> `header-dtls`
968+
969+
对应原 mKCP 的 DTLS 伪装。无额外配置。
970+
971+
> `header-srtp`
972+
973+
对应原 mKCP 的 SRTP 伪装。无额外配置。
974+
975+
> `header-utp`
976+
977+
对应原 mKCP 的 uTP 伪装。无额外配置。
978+
979+
> `header-wechat`
980+
981+
对应原 mKCP 的 WeChat Video 伪装。无额外配置。
982+
983+
> `header-wireguard`
984+
985+
对应原 mKCP 的 WireGuard 伪装。无额外配置。
986+
987+
> `xdns`
988+
989+
实验性功能,利用 DNS 查询来传输数据(类似 DNSTT)。它将执行标准的 DNS TXT 查询来传输载荷。
990+
991+
由于技术限制,它给出的 MTU 非常小,无法使用 QUIC,建议搭配 mKCP 使用。推荐的 MTU 值:客户端 130,服务端 900。
992+
993+
- `settings`:
994+
```json
995+
{
996+
"domain": "www.example.com"
997+
}
998+
```
999+
1000+
`domain` 为用于查询的域名。
1001+
1002+
因为执行的查询是标准的,它可以透过任何 UDP DNS 服务器进行转发,尽管效率可能十分不理想。
1003+
1004+
要使用这个功能,需要服务端监听 53 端口,然后代理协议将目标指向一个 DNS 服务器(如 8.8.8.8:53),并且你拥有 `domain` 的域名,然后将其 NS 记录指向服务端。
1005+
1006+
> `salamander`
1007+
1008+
Salamander 混淆。(来自 Hysteria2)
1009+
1010+
- `settings`:
1011+
```json
1012+
{
1013+
"password": "your-password"
1014+
}
1015+
```
1016+
1017+
`password` 为混淆密码,服务端客户端需一致。

docs/config/transports/mkcp.md

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ mKCP 牺牲带宽来降低延迟。传输同样的内容,mKCP 一般比 TCP
2020
"downlinkCapacity": 20,
2121
"congestion": false,
2222
"readBufferSize": 1,
23-
"writeBufferSize": 1,
24-
"header": {
25-
"type": "none",
26-
"domain": "example.com"
27-
},
28-
"seed": "Password"
23+
"writeBufferSize": 1
2924
}
3025
```
3126

27+
::: TIP
28+
`header``seed` 字段已被移除,请使用 [FinalMask](../transport.md#finalmaskobject) 进行配置。
29+
30+
并且曾经默认的 mKCP 混淆也被移除,要连接旧版服务端,需要在 FinalMask 中配置 `mkcp-original`
31+
:::
32+
3233
> `mtu`: number
3334
3435
最大传输单元(maximum transmission unit)
@@ -91,43 +92,6 @@ mKCP 牺牲带宽来降低延迟。传输同样的内容,mKCP 一般比 TCP
9192
在网速不超过 20MB/s 时,默认值 1MB 可以满足需求;超过之后,可以适当增加 `readBufferSize``writeBufferSize` 的值,然后手动平衡速度和内存的关系。
9293
:::
9394

94-
> `header`: [HeaderObject](#headerobject)
95-
96-
数据包头部伪装设置
97-
98-
> `seed`: string
99-
100-
可选的混淆密码,使用 AES-128-GCM 算法混淆流量数据,客户端和服务端需要保持一致。
101-
102-
本混淆机制不能用于保证通信内容的安全,但可能可以对抗部分封锁。
103-
104-
> 目前测试环境下开启此设置后没有出现原版未混淆版本的封端口现象
105-
106-
### HeaderObject
107-
108-
```json
109-
{
110-
"type": "none",
111-
"domain": "example.com"
112-
}
113-
```
114-
115-
> `type`: string
116-
117-
伪装类型,可选的值有:
118-
119-
- `"none"`:默认值,不进行伪装,发送的数据是没有特征的数据包。
120-
- `"srtp"`:伪装成 SRTP 数据包,会被识别为视频通话数据(如 FaceTime)。
121-
- `"utp"`:伪装成 uTP 数据包,会被识别为 BT 下载数据。
122-
- `"wechat-video"`:伪装成微信视频通话的数据包。
123-
- `"dtls"`:伪装成 DTLS 1.2 数据包。
124-
- `"wireguard"`:伪装成 WireGuard 数据包。(并不是真正的 WireGuard 协议)
125-
- `"dns"`:某些校园网在未登录的情况下允许DNS查询,给KCP添加DNS头,把流量伪装成dns请求,可以绕过某些校园网登录。
126-
127-
> `domain`: string
128-
129-
配合伪装类型 `"dns"` 使用,可随便填一个域名。
130-
13195
## 鸣谢
13296

13397
- [@skywind3000](https://github.com/skywind3000) 发明并实现了 KCP 协议。

docs/en/config/transport.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Transport specifies a stable method for data transmission. Generally, both ends
2020
"grpcSettings": {},
2121
"wsSettings": {},
2222
"httpupgradeSettings": {},
23+
"finalmask": {
24+
"udp": []
25+
},
2326
"sockopt": {
2427
"mark": 0,
2528
"tcpMaxSeg": 1440,
@@ -101,6 +104,10 @@ Hysteria configuration for the current connection. Only valid when this connecti
101104
102105
Specific configurations related to transparent proxying.
103106

107+
> `finalmask`: [FinalMaskObject](#finalmaskobject)
108+
109+
FinalMask configuration, used for general traffic obfuscation.
110+
104111
### TLSObject
105112

106113
```json
@@ -888,3 +895,100 @@ E.g., waiting IP queue sorted as 46464646 (set to 1), 44664466 (set to 2).
888895
> `maxConcurrentTry`: number
889896
890897
Max concurrent attempts. Prevents core from making massive connections if many IPs resolve but fail. Default 4. Set to 0 to disable happyEyeballs.
898+
899+
### FinalMaskObject
900+
901+
FinalMask applies a final layer of obfuscation to the traffic after the core has processed transport layer encryption, including TLS/REALITY. Currently, only UDP is supported.
902+
903+
```json
904+
{
905+
"udp": [
906+
{
907+
"type": "header-dns",
908+
"settings": {
909+
"domain": "[www.baidu.com](https://www.baidu.com)"
910+
}
911+
}
912+
]
913+
}
914+
```
915+
916+
> `udp`: \[ list \]
917+
918+
An array representing the list of obfuscations applied to UDP traffic. Multiple obfuscations will be applied sequentially, layer by layer. The `settings` vary depending on the obfuscation type; see below.
919+
920+
> `mkcp-original`
921+
922+
The simple obfuscation that was previously applied by default in mKCP. You may need to configure this to connect to legacy mKCP servers. No additional configuration required.
923+
924+
> `mkcp-aes128gcm`
925+
926+
Corresponds to the original mKCP `seed` feature. Uses AES-128-GCM for obfuscation.
927+
928+
- `settings`:
929+
```json
930+
{
931+
"password": "your-password"
932+
}
933+
```
934+
935+
`password` is the encryption password; it must be consistent between the server and the client.
936+
937+
> `header-dns`
938+
939+
Corresponds to the original mKCP DNS obfuscation.
940+
941+
- `settings`:
942+
```json
943+
{
944+
"domain": "[www.example.com](https://www.example.com)"
945+
}
946+
```
947+
948+
`domain` is the domain name used for obfuscation.
949+
950+
> `header-dtls`
951+
952+
Corresponds to the original mKCP DTLS obfuscation. No additional configuration required.
953+
954+
> `header-srtp`
955+
956+
Corresponds to the original mKCP SRTP obfuscation. No additional configuration required.
957+
958+
> `header-utp`
959+
960+
Corresponds to the original mKCP uTP obfuscation. No additional configuration required.
961+
962+
> `header-wechat`
963+
964+
Corresponds to the original mKCP WeChat Video obfuscation. No additional configuration required.
965+
966+
> `header-wireguard`
967+
968+
Corresponds to the original mKCP WireGuard obfuscation. No additional configuration required.
969+
970+
> `xdns`
971+
972+
Experimental feature. Utilizes DNS queries to transport data (similar to DNSTT). It performs standard DNS TXT queries to transport the payload. Due to technical limitations, the resulting MTU is very small, making it incompatible with QUIC; it is recommended to use it with mKCP. Recommended MTU values: Client 130, Server 900.
973+
974+
- `settings`:
975+
```json
976+
{
977+
"domain": "[www.example.com](https://www.example.com)"
978+
}
979+
```
980+
981+
`domain` is the domain name used for queries. Since the queries performed are standard, they can be forwarded through any UDP DNS server, although efficiency may be very suboptimal. To use this feature, the server needs to listen on port 53, and the proxy protocol should direct the target to a DNS server (e.g., 8.8.8.8:53). Additionally, you must own the domain specified in `domain` and point its NS record to your server.
982+
983+
> `salamander`
984+
985+
Salamander obfuscation (from Hysteria2).
986+
987+
- `settings`:
988+
```json
989+
{
990+
"password": "your-password"
991+
}
992+
```
993+
994+
`password` is the obfuscation password; it must be consistent between the server and the client.

docs/en/config/transports/mkcp.md

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ Please ensure that the firewall configuration on the host is correct.
2020
"downlinkCapacity": 20,
2121
"congestion": false,
2222
"readBufferSize": 1,
23-
"writeBufferSize": 1,
24-
"header": {
25-
"type": "none",
26-
"domain": "example.com"
27-
},
28-
"seed": "Password"
23+
"writeBufferSize": 1
2924
}
3025
```
3126

27+
::: TIP
28+
The `header` and `seed` fields have been removed. Please use [FinalMask](../transport.md#finalmaskobject) for configuration.
29+
30+
Additionally, the previously default mKCP obfuscation has also been removed. To connect to a legacy server, you need to configure `mkcp-original` in FinalMask.
31+
:::
32+
3233
> `mtu`: number
3334
3435
Maximum Transmission Unit.
@@ -91,43 +92,6 @@ When high-speed transmission is required, specifying larger `readBufferSize` and
9192
When the network speed does not exceed 20MB/s, the default value of 1MB can meet the demand; beyond that, you can appropriately increase the values of `readBufferSize` and `writeBufferSize`, and then manually balance the relationship between speed and memory.
9293
:::
9394

94-
> `header`: [HeaderObject](#headerobject)
95-
96-
Packet header camouflage settings.
97-
98-
> `seed`: string
99-
100-
Optional obfuscation password. Uses the AES-128-GCM algorithm to obfuscate traffic data. Must be consistent between the client and the server.
101-
102-
This obfuscation mechanism cannot be used to guarantee the security of communication content, but it may help mitigate some forms of blocking.
103-
104-
> Currently, in test environments, no port blocking phenomena have been observed after enabling this setting compared to the original unobfuscated version.
105-
106-
### HeaderObject
107-
108-
```json
109-
{
110-
"type": "none",
111-
"domain": "example.com"
112-
}
113-
```
114-
115-
> `type`: string
116-
117-
Camouflage type. Optional values are:
118-
119-
- `"none"`: Default value. No camouflage is performed; sent data is a packet without characteristics.
120-
- `"srtp"`: Disguised as SRTP packets, recognized as video call data (e.g., FaceTime).
121-
- `"utp"`: Disguised as uTP packets, recognized as BT download data.
122-
- `"wechat-video"`: Disguised as WeChat video call packets.
123-
- `"dtls"`: Disguised as DTLS 1.2 packets.
124-
- `"wireguard"`: Disguised as WireGuard packets. (Not the real WireGuard protocol).
125-
- `"dns"`: Some campus networks allow DNS queries without logging in. Adding a DNS header to KCP allows traffic to be disguised as DNS requests, potentially bypassing login requirements on some campus networks.
126-
127-
> `domain`: string
128-
129-
Used with the camouflage type `"dns"`. You can fill in any domain name.
130-
13195
## Credits
13296

13397
- [@skywind3000](https://github.com/skywind3000) Invented and implemented the KCP protocol.

0 commit comments

Comments
 (0)