Shadowsocks — mihomo
mihomo 双端支持 Shadowsocks,并自带丰富的插件生态:可把线路格式包进 obfs、WebSocket(v2ray-plugin / gost-plugin)、Shadow-TLS、 REALTLS 或 KCP。插件配置以 plugin-opts 这一类型化 YAML 映射形式 提供。
出站
proxies: 下 type: ss 条目。内嵌 BasicOption。
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
name | string | (required) | <string> | 唯一的代理名。 |
server | string | (required) | <host> | 上游服务器主机名或 IP。 |
port | int | (required) | <port> | 上游服务器端口。 |
password | string | (required) | <string> | <base64 key> | 服务端密码(AEAD)或 EIH 密钥(SS-2022)。 |
cipher | string | (required) | 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 | none | mihomo 中 Shadowsocks 加密 / 密钥派生算法的字段名。 |
udp | bool | false | true | false | 允许 UDP 包经此出站转发。 |
plugin | string | (unset) | obfs | v2ray-plugin | gost-plugin | shadow-tls | restls | kcptun | 用于包装流的混淆 / 传输插件。每种插件有自己的 `plugin-opts` schema(下方分节说明)。 |
plugin-opts | map[string]any | {} | <plugin-specific YAML map> | 插件专属配置。schema 取决于 `plugin` —— 见下方子节。 |
udp-over-tcp | bool | false | true | false | 把 UDP 包包装在 TCP 流中。 |
udp-over-tcp-version | int | 2 | 1 | 2 | UoT 帧版本。 |
client-fingerprint | string | (global) | chrome | firefox | safari | ios | edge | random | randomized | 当插件启用 TLS 时使用的 uTLS ClientHello 指纹。 |
源码: adapter/outbound/shadowsocks.go:41-54 · 锚定版本 v1.19.27 (5184081)
plugin-opts —— plugin: obfs 时
把流包进 simple-obfs(TLS 形态或 HTTP 形态)。
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
mode | string | tls | tls | http | obfs 模式。`tls` 模拟 TLS ClientHello;`http` 模拟普通 HTTP 请求。 |
host | string | (unset) | <host> | obfs 载荷中使用的伪装主机名。 |
源码: adapter/outbound/shadowsocks.go:56-59 · 锚定版本 v1.19.27 (5184081)
plugin-opts —— plugin: v2ray-plugin 时
把流包进 WebSocket 握手。可选 TLS。
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
mode | string | (required) | websocket | 目前仅支持 `websocket`。 |
host | string | (unset) | <host> | WS 握手发送的 Host 头。 |
path | string | / | /<path> | WebSocket 路径。 |
tls | bool | false | true | false | 用 TLS 包裹 WS 握手。 |
ech-opts | ECHOptions | — | — | |
fingerprint | string | (unset) | <SHA256 hex> | 锚定服务端 TLS 证书指纹。 |
certificate | string | (unset) | <PEM file path> | 客户端证书(mTLS)。 |
private-key | string | (unset) | <key file path> | 与 `certificate` 配对的私钥。 |
headers | map[string]string | {} | {<header>: <value>} | upgrade 请求附加的 HTTP 头。 |
skip-cert-verify | bool | false | true | false | 禁用 TLS 校验。 |
mux | bool | false | true | false | 在 WS 流上启用 smux。 |
v2ray-http-upgrade | bool | false | true | false | 用 V2Ray HTTP-upgrade 替代标准 WebSocket。 |
v2ray-http-upgrade-fast-open | bool | false | true | false | 在 HTTP-upgrade 请求中捎带载荷。 |
源码: adapter/outbound/shadowsocks.go:61-75 · 锚定版本 v1.19.27 (5184081)
plugin-opts —— plugin: shadow-tls 时
在 Shadowsocks 流之前加一层 Shadow-TLS 握手。
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
password | string | (unset) | <string> | Shadow-TLS v2/v3 密码。 |
host | string | (required) | <host> | TLS 握手的伪装主机名。 |
fingerprint | string | (unset) | <SHA256 hex> | 锚定伪装服务器的 TLS 证书。 |
certificate | string | (unset) | <PEM file path> | 客户端证书。 |
private-key | string | (unset) | <key file path> | 私钥。 |
skip-cert-verify | bool | false | true | false | 禁用证书校验(仅供测试)。 |
version | int | 3 | 1 | 2 | 3 | Shadow-TLS 协议版本。v3 为当前生产版本。 |
alpn | []string | [] | h2 | http/1.1 | 伪装 TLS 握手时宣告的 ALPN 列表。 |
源码: adapter/outbound/shadowsocks.go:91-100 · 锚定版本 v1.19.27 (5184081)
其他插件变体(gost-plugin、restls、kcptun)在 plugin-opts 下 各有自己的 schema。它们的结构体(gostObfsOption、restlsOption、 kcpTunOption)位于同一源文件;完整字段列表见提取出的数据。
入站
listeners: 下 type: ss 条目。内嵌 BaseOption。
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
password | string | (required) | <string> | <base64 key> | 服务端密码或 SS-2022 密钥。 |
cipher | string | (required) | <cipher> | 加密算法集合同出站。 |
udp | bool | false | true | false | 接受 UDP 包。 |
mux-option | MuxOption | (disabled) | MuxOption | sing 风格的多路复用。 |
shadow-tls | ShadowTLS | (disabled) | ShadowTLS | 可选的入站 Shadow-TLS 包装。 |
kcp-tun | KcpTun | (disabled) | KcpTun | 可选的入站 KCP 传输。 |
simple-obfs | SimpleObfs | (disabled) | SimpleObfs | simple-obfs(obfs-local)设置:`{ enable, mode }`,其中 `mode` 为 `http` 或 `tls`。 |
源码: listener/inbound/shadowsocks.go:12-21 · 锚定版本 v1.19.27 (5184081)
simple-obfs
监听器内置的 simple-obfs 包装 —— 无需外部插件二进制。
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
enable | bool | false | true | false | 在监听器上启用 simple-obfs。 |
mode | string | tls | http | tls | obfs 模式。`tls` 模拟 TLS ClientHello;`http` 模拟普通 HTTP 请求。 |
源码: listener/inbound/shadowsocks.go:23-26 · 锚定版本 v1.19.27 (5184081)
示例
普通 SS 出站:
proxies:
- name: ss-aead
type: ss
server: example.com
port: 8388
password: <password>
cipher: aes-256-gcm
udp: true启用 UDP-over-TCP 的 SS-2022 出站:
proxies:
- name: ss22
type: ss
server: example.com
port: 8388
password: <base64 16-byte key>
cipher: 2022-blake3-aes-128-gcm
udp-over-tcp: true
udp-over-tcp-version: 2走 v2ray-plugin(WebSocket + TLS)的 SS:
proxies:
- name: ss-v2ray
type: ss
server: example.com
port: 443
password: <password>
cipher: aes-256-gcm
udp: true
plugin: v2ray-plugin
plugin-opts:
mode: websocket
tls: true
host: example.com
path: /ss在 Shadow-TLS v3 前的 SS:
proxies:
- name: ss-stls
type: ss
server: example.com
port: 443
password: <ss password>
cipher: aes-256-gcm
plugin: shadow-tls
plugin-opts:
password: <stls password>
host: www.cloudflare.com
version: 3listeners 下的入站:
listeners:
- name: ss-in
type: ss
listen: 0.0.0.0
port: 8388
password: <password>
cipher: aes-256-gcm
udp: true说明
- mihomo 出站把
plugin-opts解码到一个按插件命名的结构体上。 这些结构体上的字段使用obfs:而非proxy:标签 —— 这是 mihomo 内部约定,不直接面向用户,例如adapter/outbound/shadowsocks.go:56-59的simpleObfsOption。 plugin: obfs是 mihomo 中simple-obfs的名字;TLS 形态用mode: tls,HTTP 形态用mode: http。- mihomo 监听器入站目前不支持
users[]多用户 —— 同一端口上的多 SS-2022 用户请按用户各定义一个监听器。
跨内核说明
- Xray 使用
method(而非cipher)以及uot/uotVersion。 它没有插件系统 —— 在另一个streamSettings传输中包装 Shadowsocks 载荷。参见 Shadowsocks — Xray-core。 - sing-box 使用
method,对 SS-2022 支持destinations[]中继 形态,UoT 以对象形式表示udp_over_tcp: {enabled, version},并 通过plugin/plugin_opts接受外部插件二进制。参见 Shadowsocks — sing-box。
源码: adapter/outbound/shadowsocks.go:41-100 · v1.19.27 (5184081)
