Skip to content

Commit 4e24b85

Browse files
committed
Add snell protocol
1 parent 19bdede commit 4e24b85

16 files changed

Lines changed: 927 additions & 3 deletions

File tree

constant/proxy.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const (
1111
TypeHTTP = "http"
1212
TypeMixed = "mixed"
1313
TypeShadowsocks = "shadowsocks"
14+
TypeSnell = "snell"
1415
TypeVMess = "vmess"
1516
TypeTrojan = "trojan"
1617
TypeNaive = "naive"
@@ -67,6 +68,8 @@ func ProxyDisplayName(proxyType string) string {
6768
return "Mixed"
6869
case TypeShadowsocks:
6970
return "Shadowsocks"
71+
case TypeSnell:
72+
return "Snell"
7073
case TypeVMess:
7174
return "VMess"
7275
case TypeTrojan:

docs/configuration/inbound/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
| `hysteria2` | [Hysteria2](./hysteria2/) | :material-close: |
3232
| `vless` | [VLESS](./vless/) | TCP |
3333
| `anytls` | [AnyTLS](./anytls/) | TCP |
34+
| `snell` | [Snell](./snell/) | TCP |
3435
| `tun` | [Tun](./tun/) | :material-close: |
3536
| `redirect` | [Redirect](./redirect/) | :material-close: |
3637
| `tproxy` | [TProxy](./tproxy/) | :material-close: |

docs/configuration/inbound/index.zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
| `hysteria2` | [Hysteria2](./hysteria2/) | :material-close: |
3232
| `vless` | [VLESS](./vless/) | TCP |
3333
| `anytls` | [AnyTLS](./anytls/) | TCP |
34+
| `snell` | [Snell](./snell/) | TCP |
3435
| `tun` | [Tun](./tun/) | :material-close: |
3536
| `redirect` | [Redirect](./redirect/) | :material-close: |
3637
| `tproxy` | [TProxy](./tproxy/) | :material-close: |
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
icon: material/new-box
3+
---
4+
5+
!!! question "Since sing-box 1.14.0"
6+
7+
### Structure
8+
9+
```json
10+
{
11+
"type": "snell",
12+
"tag": "snell-in",
13+
14+
... // Listen Fields
15+
16+
"version": 5,
17+
"psk": "password",
18+
"users": [
19+
{
20+
"name": "sekai",
21+
"userkey": "user-password"
22+
}
23+
],
24+
"obfs_mode": ""
25+
}
26+
```
27+
28+
### Version 6 Structure
29+
30+
```json
31+
{
32+
"type": "snell",
33+
"tag": "snell-in",
34+
35+
... // Listen Fields
36+
37+
"version": 6,
38+
"psk": "password",
39+
"users": [
40+
{
41+
"name": "sekai",
42+
"userkey": "user-password"
43+
}
44+
],
45+
"mode": ""
46+
}
47+
```
48+
49+
### Listen Fields
50+
51+
See [Listen Fields](/configuration/shared/listen/) for details.
52+
53+
### Fields
54+
55+
#### version
56+
57+
==Required==
58+
59+
The Snell protocol version, one of `5` `6`.
60+
61+
Version `5` supports HTTP obfuscation (`obfs_mode`); version `6` replaces it
62+
with traffic shaping (`mode`) and requires a `psk` of 12 to 255 bytes.
63+
64+
!!! note
65+
66+
Since we intentionally do not support the QUIC proxy mode of Snell v5, the v5 wire protocol
67+
is effectively identical to v4, so no separate v4 server or v5 client is provided.
68+
69+
#### psk
70+
71+
==Required==
72+
73+
The pre-shared key.
74+
75+
#### users
76+
77+
Snell users.
78+
79+
When set, the server runs in multi-user mode: each entry has a `name` (optional, used in
80+
logs) and a `userkey` (the user's key). The top-level `psk` remains the server key.
81+
82+
#### obfs_mode
83+
84+
==Version 5 only==
85+
86+
HTTP obfuscation mode, one of `none` `http`.
87+
88+
`none` is used by default.
89+
90+
#### mode
91+
92+
==Version 6 only==
93+
94+
Traffic shaping mode, one of `default` `unshaped` `unsafe-raw`.
95+
96+
`default` is used by default.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
icon: material/new-box
3+
---
4+
5+
!!! question "自 sing-box 1.14.0 起"
6+
7+
### 结构
8+
9+
```json
10+
{
11+
"type": "snell",
12+
"tag": "snell-in",
13+
14+
... // 监听字段
15+
16+
"version": 5,
17+
"psk": "password",
18+
"users": [
19+
{
20+
"name": "sekai",
21+
"userkey": "user-password"
22+
}
23+
],
24+
"obfs_mode": ""
25+
}
26+
```
27+
28+
### 版本 6 结构
29+
30+
```json
31+
{
32+
"type": "snell",
33+
"tag": "snell-in",
34+
35+
... // 监听字段
36+
37+
"version": 6,
38+
"psk": "password",
39+
"users": [
40+
{
41+
"name": "sekai",
42+
"userkey": "user-password"
43+
}
44+
],
45+
"mode": ""
46+
}
47+
```
48+
49+
### 监听字段
50+
51+
参阅 [监听字段](/zh/configuration/shared/listen/)
52+
53+
### 字段
54+
55+
#### version
56+
57+
==必填==
58+
59+
Snell 协议版本,`5` `6` 之一。
60+
61+
版本 `5` 支持 HTTP 混淆(`obfs_mode`);版本 `6` 以流量整形(`mode`)取而代之,并要求
62+
`psk` 长度为 12 到 255 字节。
63+
64+
!!! note
65+
66+
由于我们有意不支持 Snell v5 的 QUIC 代理模式,v5 的线路协议实际上与 v4 没有区别,
67+
因此不提供独立的 v4 服务器和 v5 客户端。
68+
69+
#### psk
70+
71+
==必填==
72+
73+
预共享密钥。
74+
75+
#### users
76+
77+
Snell 用户。
78+
79+
设置后,服务器运行于多用户模式:每一项包含 `name`(可选,用于日志)和 `userkey`
80+
(用户密钥)。顶层的 `psk` 仍作为服务器密钥。
81+
82+
#### obfs_mode
83+
84+
==仅版本 5==
85+
86+
HTTP 混淆模式,`none` `http` 之一。
87+
88+
默认为 `none`
89+
90+
#### mode
91+
92+
==仅版本 6==
93+
94+
流量整形模式,`default` `unshaped` `unsafe-raw` 之一。
95+
96+
默认为 `default`

docs/configuration/outbound/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
| `tuic` | [TUIC](./tuic/) |
3232
| `hysteria2` | [Hysteria2](./hysteria2/) |
3333
| `anytls` | [AnyTLS](./anytls/) |
34+
| `snell` | [Snell](./snell/) |
3435
| `tor` | [Tor](./tor/) |
3536
| `ssh` | [SSH](./ssh/) |
3637
| `dns` | [DNS](./dns/) |

docs/configuration/outbound/index.zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
| `tuic` | [TUIC](./tuic/) |
3232
| `hysteria2` | [Hysteria2](./hysteria2/) |
3333
| `anytls` | [AnyTLS](./anytls/) |
34+
| `snell` | [Snell](./snell/) |
3435
| `tor` | [Tor](./tor/) |
3536
| `ssh` | [SSH](./ssh/) |
3637
| `dns` | [DNS](./dns/) |
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
icon: material/new-box
3+
---
4+
5+
!!! question "Since sing-box 1.14.0"
6+
7+
### Structure
8+
9+
```json
10+
{
11+
"type": "snell",
12+
"tag": "snell-out",
13+
14+
"server": "127.0.0.1",
15+
"server_port": 1080,
16+
"version": 4,
17+
"psk": "password",
18+
"userkey": "",
19+
"reuse": false,
20+
"network": "tcp",
21+
"obfs_mode": "",
22+
"obfs_host": "",
23+
24+
... // Dial Fields
25+
}
26+
```
27+
28+
### Version 6 Structure
29+
30+
```json
31+
{
32+
"type": "snell",
33+
"tag": "snell-out",
34+
35+
"server": "127.0.0.1",
36+
"server_port": 1080,
37+
"version": 6,
38+
"psk": "password",
39+
"userkey": "",
40+
"reuse": false,
41+
"network": "tcp",
42+
"mode": "",
43+
44+
... // Dial Fields
45+
}
46+
```
47+
48+
### Fields
49+
50+
#### server
51+
52+
==Required==
53+
54+
The server address.
55+
56+
#### server_port
57+
58+
==Required==
59+
60+
The server port.
61+
62+
#### version
63+
64+
==Required==
65+
66+
The Snell protocol version, one of `4` `6`.
67+
68+
Version `4` supports HTTP obfuscation (`obfs_mode` / `obfs_host`); version `6`
69+
replaces it with traffic shaping (`mode`) and requires a `psk` of 12 to 255
70+
bytes.
71+
72+
!!! note
73+
74+
Since we intentionally do not support the QUIC proxy mode of Snell v5, the v5 wire protocol
75+
is effectively identical to v4, so no separate v4 server or v5 client is provided.
76+
77+
#### psk
78+
79+
==Required==
80+
81+
The pre-shared key.
82+
83+
#### userkey
84+
85+
The user key, used to authenticate against a multi-user server.
86+
87+
#### reuse
88+
89+
Enable connection reuse (the Snell v2 `CONNECT` command).
90+
91+
#### network
92+
93+
Enabled network
94+
95+
One of `tcp` `udp`.
96+
97+
Both is enabled by default.
98+
99+
#### obfs_mode
100+
101+
==Version 4 only==
102+
103+
HTTP obfuscation mode, one of `none` `http`.
104+
105+
`none` is used by default.
106+
107+
#### obfs_host
108+
109+
==Version 4 only==
110+
111+
The HTTP `Host` header sent when `obfs_mode` is `http`.
112+
113+
`bing.com` is used by default.
114+
115+
#### mode
116+
117+
==Version 6 only==
118+
119+
Traffic shaping mode, one of `default` `unshaped` `unsafe-raw`.
120+
121+
`default` is used by default.
122+
123+
### Dial Fields
124+
125+
See [Dial Fields](/configuration/shared/dial/) for details.

0 commit comments

Comments
 (0)