Shadowsocks — sing-box
sing-box 实现完整的 Shadowsocks 家族:传统 AEAD、带 EIH 多用户的 Shadowsocks-2022、v2ray-plugin 与 obfs 这类插件协议,以及 SS-2022 独有的服务端中继形态。
入站
type: "shadowsocks" 入站:
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
network | NetworkList | (tcp+udp) | tcp | udp | | 限定为仅 TCP 或仅 UDP。空值同时启用两者。 |
method | string | (required) | none | aes-128-gcm | aes-256-gcm | chacha20-ietf-poly1305 | xchacha20-ietf-poly1305 | 2022-blake3-aes-128-gcm | 2022-blake3-aes-256-gcm | 2022-blake3-chacha20-poly1305 | 入站使用的加密算法。SS-2022 加密会启用 `users[]` 与 `destinations[]`。 |
password | string | (required for single-user) | <string> | <base64 key> | 单用户密码或 SS-2022 服务端 EIH 密钥。 |
users | []ShadowsocksUser | [] | [ShadowsocksUser] | 单用户列表 —— 仅 SS-2022。每个用户拥有自己的 EIH 密钥。 |
destinations | []ShadowsocksDestination | [] | [ShadowsocksDestination] | 服务端中继目标。SS-2022 服务端可用它把单个入站按 EIH 扇出到多个上游地址。 |
multiplex | *InboundMultiplexOptions | (disabled) | InboundMultiplexOptions | 服务端多路复用。 |
managed | bool | false | true | false | 启用 managed-mode 协议,让与 ssmgmt 兼容的客户端在运行时重新配置用户。 |
源码: option/shadowsocks.go:3-12 · 锚定版本 v1.13.11 (553cfa1)
该结构体内嵌 ListenOptions(监听地址、端口、嗅探等)。
users[]
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
name | string | (unset) | <string> | 统计与日志中使用的显示名。 |
password | string | (required) | <base64 key> | 用户 EIH 密钥。长度需匹配加密算法(16 或 32 字节)。 |
源码: option/shadowsocks.go:14-17 · 锚定版本 v1.13.11 (553cfa1)
destinations[]
每个 destination 都内嵌 ServerOptions(server、server_port), 加上自己的 name / password。
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
name | string | (unset) | <string> | 该目标的显示名。 |
password | string | (required) | <base64 key> | 目标的 EIH 密钥。 |
源码: option/shadowsocks.go:19-23 · 锚定版本 v1.13.11 (553cfa1)
出站
type: "shadowsocks" 出站:
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
method | string | (required) | <cipher> | 服务端加密。 |
password | string | (required) | <string> | <base64 key> | 服务端密码 / SS-2022 密钥。 |
plugin | string | (unset) | obfs-local | v2ray-plugin | shadow-tls | kcptun | 外部 Shadowsocks 插件,用于包装流。`obfs-local` 与 `v2ray-plugin` 已编译进 sing-box;其他需要 PATH 中存在外部二进制。 |
plugin_opts | string | (unset) | <plugin-specific string> | 以分号分隔、转发给插件的参数(`mode=tls;host=example.com;...`)。 |
network | NetworkList | (tcp+udp) | tcp | udp | | 限定为仅 TCP 或仅 UDP。 |
udp_over_tcp | *UDPOverTCPOptions | (disabled) | UDPOverTCPOptions | 把 UDP 包包装进 TCP 流。对象形态:`{enabled, version}`。 |
multiplex | *OutboundMultiplexOptions | (disabled) | OutboundMultiplexOptions | 客户端多路复用(必须与服务端一致)。 |
源码: option/shadowsocks.go:25-35 · 锚定版本 v1.13.11 (553cfa1)
同时内嵌 DialerOptions 与 ServerOptions。
示例
传统 AEAD 入站:
json
{
"inbounds": [
{
"type": "shadowsocks",
"tag": "ss-in",
"listen": "::",
"listen_port": 8388,
"method": "aes-256-gcm",
"password": "<password>"
}
]
}SS-2022 入站,双用户:
json
{
"inbounds": [
{
"type": "shadowsocks",
"tag": "ss22-in",
"listen": "::",
"listen_port": 8388,
"method": "2022-blake3-aes-128-gcm",
"password": "<base64 16-byte server key>",
"users": [
{ "name": "alice", "password": "<base64 16-byte alice key>" },
{ "name": "bob", "password": "<base64 16-byte bob key>" }
]
}
]
}启用 v2ray-plugin 的出站:
json
{
"outbounds": [
{
"type": "shadowsocks",
"tag": "ss-out",
"server": "example.com",
"server_port": 8388,
"method": "chacha20-ietf-poly1305",
"password": "<password>",
"plugin": "v2ray-plugin",
"plugin_opts": "mode=websocket;tls;host=example.com;path=/ss"
}
]
}启用 UDP-over-TCP v2 的出站:
json
{
"outbounds": [
{
"type": "shadowsocks",
"server": "example.com",
"server_port": 8388,
"method": "2022-blake3-aes-256-gcm",
"password": "<base64 32-byte key>",
"udp_over_tcp": { "enabled": true, "version": 2 }
}
]
}说明
- sing-box 同时接受 IETF 加密名(
chacha20-ietf-poly1305)与历史 非 IETF 名,但在协议层内部会收敛到每个加密的单一拼写。 destinations[]是 sing-box 独有。带 destinations 的 SS-2022 服务 端表现为按 EIH 区分的中继:每个 destination 各持其 EIH 密钥,凡 鉴权命中某一项的入站连接,都会被转发到该 destination 的server/server_port,而不是本地处理。plugin: "v2ray-plugin"与plugin: "obfs-local"已编译进 sing-box(无需外部二进制)。其他插件名会调用同名外部可执行;插件 协议遵循 shadowsocks-libev 插件规范。udp_over_tcp是对象({enabled, version}),Xray 拆为两个字段 (uot、uotVersion),mihomo 又是两个不同名字段。
跨内核说明
- Xray 使用
clients[](而非users[]),并在出站以两个独立 字段(uot、uotVersion)表达 UoT。它没有destinations[]中继 形态。参见 Shadowsocks — Xray-core。 - mihomo 使用
cipher(而非method),并以按插件名键入的 类型化 YAML 映射plugin-opts接受插件参数。参见 Shadowsocks — mihomo。
源码: option/shadowsocks.go:3-35 · v1.13.11 (553cfa1)
