AnyTLS — mihomo
mihomo 双端支持 AnyTLS,沿用 mihomo 常规约定(无 cipher,出站把 TLS / ECH / uTLS 旋钮放在顶层)。
出站
proxies: 下 type: anytls 条目。内嵌 BasicOption。
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
name | string | (required) | <string> | 唯一的代理名。 |
server | string | (required) | <host> | 上游服务器主机名或 IP。 |
port | int | (required) | <port> | 上游服务器端口。 |
password | string | (required) | <string> | 服务端密码。 |
alpn | []string | [] | h2 | http/1.1 | TLS 握手时宣告的 ALPN 列表。 |
sni | string | (server) | <SNI> | TLS Server Name Indication。 |
ech-opts | ECHOptions | (disabled) | ECHOptions | Encrypted Client Hello 配置。 |
client-fingerprint | string | (global) | chrome | firefox | safari | ios | edge | random | randomized | uTLS ClientHello 指纹。 |
skip-cert-verify | bool | false | true | false | 禁用 TLS 校验(仅供测试)。 |
fingerprint | string | (unset) | <SHA256 hex> | 锚定服务端 TLS 证书指纹。 |
certificate | string | (unset) | <PEM file path> | 客户端证书(mTLS)。 |
private-key | string | (unset) | <key file path> | 与 `certificate` 配对的私钥。 |
udp | bool | false | true | false | 允许 UDP 包经此出站转发。 |
idle-session-check-interval | int | 0 | <seconds> | 会话池扫描间隔。0 使用运行时默认。 |
idle-session-timeout | int | 0 | <seconds> | 空闲超过该秒数的会话会被回收。0 使用运行时默认。 |
min-idle-session | int | 0 | <int> | 池中需保持温热的最少会话数。 |
源码: adapter/outbound/anytls.go:25-43 · 锚定版本 v1.19.27 (5184081)
入站
listeners: 下 type: anytls 条目。内嵌 BaseOption。
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
users | map[string]string | {} | {<username>: <password>} | 用户表 —— 用户名到密码的映射。 |
certificate | string | (required) | <PEM file path> | TLS 服务端证书。 |
private-key | string | (required) | <key file path> | TLS 私钥。 |
client-auth-type | string | (none) | no-client-cert | request-client-cert | require-any-client-cert | verify-client-cert-if-given | require-and-verify-client-cert | mTLS 客户端鉴权模式。 |
client-auth-cert | string | (unset) | <PEM file path> | 作为客户端根的 CA 集合。 |
ech-key | string | (unset) | <ECH config> | Encrypted Client Hello 配置 / 密钥。 |
allow-insecure | bool | false | true | false | 在监听器上跳过 TLS 客户端证书校验(仅供测试)。 |
padding-scheme | string | (server default) | <scheme> | 自定义 padding 方案。单字符串,遵循上游协议规范。 |
源码: listener/inbound/anytls.go:12-22 · 锚定版本 v1.19.27 (5184081)
示例
出站:
yaml
proxies:
- name: anytls
type: anytls
server: example.com
port: 443
password: <password>
sni: example.com
alpn: [h2, http/1.1]
udp: true
client-fingerprint: chrome
idle-session-check-interval: 30
idle-session-timeout: 60
min-idle-session: 4入站:
yaml
listeners:
- name: anytls-in
type: anytls
listen: 0.0.0.0
port: 443
users:
alice: <alice-password>
bob: <bob-password>
certificate: /etc/mihomo/server.crt
private-key: /etc/mihomo/server.key说明
- mihomo 对三个会话池超时使用 秒;sing-box 对同样字段使用时长 字符串(
"30s")。字段拼写也不同 —— 这里 kebab-case,sing-box 那边 snake_case。 users:是 username → password 的 YAML 映射,与 mihomo 的 TUIC、 Hysteria2 入站保持一致。- mihomo 出站把 TLS、ECH、uTLS 指纹旋钮内联在代理对象上。sing-box 把它们放在内嵌的
tls:块中。
跨内核说明
- Xray-core 不支持 AnyTLS。参见 AnyTLS — Xray-core。
- sing-box 使用 snake_case 字段名,会话池超时使用 Go 风格时长 字符串,用户列表为
[{name, password}]数组。参见 AnyTLS — sing-box。
源码: adapter/outbound/anytls.go:25-43 · v1.19.27 (5184081)
