Shadowsocks — Xray-core
Xray-core 同时支持传统 AEAD-Shadowsocks(AES-GCM、(X)ChaCha20-Poly1305)与 Shadowsocks-2022(2022-blake3-... 加密家族);两者都支持单端口多用户,SS-2022 还提供基于 EIH 的中继。加载时会打印弃用横幅 —— Xray 开发者推荐使用 VLESS 加密作为现代替代。
入站
"protocol": "shadowsocks" 入站的 settings:
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
method | string | (required) | aes-128-gcm | aes-256-gcm | chacha20-poly1305 | xchacha20-poly1305 | 2022-blake3-aes-128-gcm | 2022-blake3-aes-256-gcm | 2022-blake3-chacha20-poly1305 | 加密算法(不区分大小写)。取 2022-blake3-… 时启用 Shadowsocks-2022。传统加密还接受 aead_… 别名(如 aead_aes_128_gcm)以及 chacha20-ietf-poly1305 / xchacha20-ietf-poly1305;不存在不加密的 none / plain 方法。未知值会导致启动失败。使用传统按用户 clients 时,每个用户各自设置 method。 |
password | string | (required; ignored with classic clients) | <string> | <base64 key> | 单用户密码(传统 AEAD),或 服务端密钥(SS-2022 —— 与 clients 搭配的多用户及中继模式下同样必填)。SS-2022 下取值为 base64 编码的密钥,解码后长度需匹配加密算法(16 / 32 字节)。 |
level | byte | 0 | <byte> | 单用户账户的策略等级;clients 中的用户各自携带 level。 |
email | string | (unset) | <string> | 统计 / 日志中显示的标签。 |
users | []*ShadowsocksUserConfig | — | [ShadowsocksUserConfig] | … | 入站账户列表;对象形状与 clients 相同。两个键均可使用。 |
clients | []*ShadowsocksUserConfig | [] | [ShadowsocksUserConfig] | 按用户的列表 —— 两个家族都支持单端口多用户。传统 AEAD:每个条目自带 method 与 password,顶层 password 被忽略。SS-2022:条目在顶层服务端 method / password 之下携带用户密钥(仅 AES 加密);若第一个条目带有 address,入站改为中继模式(见下方提示)。 |
network | *NetworkList | tcp | tcp | udp | tcp,udp | 支持的传输(逗号分隔列表或单值)。 |
源码: infra/conf/shadowsocks.go:39-47 · 锚定版本 v26.11.9 (676eaf6)
clients[]
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
method | string | (see description) | <classic AEAD cipher> | (empty for SS-2022) | 传统 AEAD:必填 —— 该用户的加密(aes-128-gcm、aes-256-gcm、chacha20-poly1305 或 xchacha20-poly1305)。SS-2022:必须留空 —— 沿用服务端 method;非空值会导致启动失败。 |
password | string | (required) | <string> | <base64 key> | 传统 AEAD:该用户的密码。SS-2022:该用户的密钥(base64,解码后长度与服务端加密匹配 —— 16 或 32 字节);中继模式下为经 address / port 到达的目标服务器的密钥。 |
level | byte | 0 | <byte> | 该用户的策略等级。 |
email | string | (unset) | <string> | 用户标识。 |
address | *Address | (unset) | <host> | 仅 SS-2022 中继 —— 该条目对应的目标服务器。第一个条目带 address 时入站即成为中继,此后每个条目都必须设置。 |
port | uint16 | (unset) | <port> | 中继目标端口(与 address 成对出现)。 |
源码: infra/conf/shadowsocks.go:30-37 · 锚定版本 v26.11.9 (676eaf6)
多用户与中继
- 传统 AEAD:每个
clients[]条目都需要自己的method与password;此时顶层password被忽略。 - SS-2022:
clients[]条目携带用户密钥且method留空,归属于顶层服务端method/password;仅2022-blake3-aes-*-gcm加密支持。若第一个条目带有address,入站即成为中继:此后每个条目都需要address/port,其password是对应目标服务器的密钥。 - 多用户 SS-2022 服务端的客户端把
password设为<server key>:<user key>。
出站
"protocol": "shadowsocks" 出站的 settings:
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
address | *Address | (unset) | <host> | 简化形式 —— 服务器主机名或 IP。 |
port | uint16 | (required with address) | <port> | 服务器端口。 |
level | byte | 0 | <byte> | 用户等级。 |
email | string | (unset) | <string> | 用户标识。 |
method | string | (required) | <see inbound methods> | 与服务端协商使用的加密。 |
password | string | (required) | <string> | <base64 key> | <key>:<key> | 服务端密码 / SS-2022 密钥。连接多用户 SS-2022 服务端时,按跳转顺序用 : 连接各密钥(如 <server key>:<user key>)。2022-blake3-chacha20-poly1305 只接受单个密钥。 |
servers | []*ShadowsocksServerTarget | (use simplified shape) | [ShadowsocksServerTarget] | 完整形式,恰好一个条目。 |
源码: infra/conf/shadowsocks.go:189-197 · 锚定版本 v26.11.9 (676eaf6)
servers[]
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
address | *Address | (required) | <host> | 服务器主机名或 IP。 |
port | uint16 | (required) | <port> | 服务器端口。 |
level | byte | 0 | <byte> | 用户等级。 |
email | string | (unset) | <string> | 用户标识。 |
method | string | (required) | <cipher> | 加密算法。 |
password | string | (required) | <string> | <base64 key> | 密码 / SS-2022 密钥 —— 格式与顶层 password 相同。 |
源码: infra/conf/shadowsocks.go:180-187 · 锚定版本 v26.11.9 (676eaf6)
出站接受 要么 简化形式(顶层 address、port、method、password),要么 完整的 servers 形式且恰好一个条目。
示例
传统 AEAD 入站:
json
{
"inbounds": [
{
"tag": "ss-in",
"listen": "0.0.0.0",
"port": 8388,
"protocol": "shadowsocks",
"settings": {
"method": "aes-256-gcm",
"password": "<password>",
"network": "tcp,udp"
}
}
]
}SS-2022 入站,双用户:
json
{
"inbounds": [
{
"tag": "ss22-in",
"listen": "0.0.0.0",
"port": 8388,
"protocol": "shadowsocks",
"settings": {
"method": "2022-blake3-aes-128-gcm",
"password": "<base64 16-byte server key>",
"clients": [
{ "password": "<base64 16-byte alice key>", "email": "alice" },
{ "password": "<base64 16-byte bob key>", "email": "bob" }
],
"network": "tcp,udp"
}
}
]
}SS-2022 出站:
json
{
"outbounds": [
{
"tag": "ss-out",
"protocol": "shadowsocks",
"settings": {
"address": "example.com",
"port": 8388,
"method": "2022-blake3-aes-256-gcm",
"password": "<base64 32-byte key>"
}
}
]
}说明
- 加密算法集合:传统 AEAD 家族取自
cipherFromString(infra/conf/shadowsocks.go:15-28),2022-blake3-...家族取自 Xray 自带的 SS-2022 实现;两者都不区分大小写。未知加密会构建失败。 - 不存在不加密的方法 ——
none与plain会被当作未知加密拒绝。 - SS-2022 密码是 原始密钥材料,以 base64 编码(不是合法 base64 的值会按原始字节使用)。
2022-blake3-aes-128-gcm使用 16 字节密钥;2022-blake3-aes-256-gcm与2022-blake3-chacha20-poly1305使用 32 字节密钥。长度不符的密钥会在入站或出站启动时失败(bad key)。 - 加载时打印的弃用横幅 "Shadowsocks (with no Forward Secrecy, etc.)" 位于
infra/conf/shadowsocks.go:50, 200。
跨内核说明
- sing-box SS-2022 多用户使用
users[],并新增destinations[]数组表示服务端中继形式(一台 SS-2022 服务器分流到多个上游地址)。另外支持外部插件(plugin、plugin_opts),并在出站提供 UDP-over-TCP(udp_over_tcp),而 Xray 的 Shadowsocks 没有这一选项。参见 Shadowsocks — sing-box。 - mihomo 使用
cipher(而非method)作为字段名;插件参数以通用plugin-opts映射形式按插件名键入;并支持丰富的混淆插件(obfs、v2ray-plugin、shadow-tls、restls、jls、kcptun)。参见 Shadowsocks — mihomo。
源码: infra/conf/shadowsocks.go:30-197 · v26.11.9 (676eaf6)
