Skip to content

AnyTLS — mihomo

mihomo 双端支持 AnyTLS,沿用 mihomo 常规约定(无 cipher,出站把 TLS / ECH / uTLS 旋钮放在顶层)。

出站

proxies:type: anytls 条目。内嵌 BasicOption

字段类型默认值允许值描述
namestring(required)<string>唯一的代理名。
serverstring(required)<host>上游服务器主机名或 IP。
portint(required)<port>上游服务器端口。
passwordstring(required)<string>服务端密码。
alpn[]string[]h2 | http/1.1TLS 握手时宣告的 ALPN 列表。
snistring(server)<SNI>TLS Server Name Indication。
ech-optsECHOptions(disabled)ECHOptionsEncrypted Client Hello 配置。
client-fingerprintstring(global)chrome | firefox | safari | ios | edge | random | randomizeduTLS ClientHello 指纹。
skip-cert-verifyboolfalsetrue | false禁用 TLS 校验(仅供测试)。
fingerprintstring(unset)<SHA256 hex>锚定服务端 TLS 证书指纹。
certificatestring(unset)<PEM file path>客户端证书(mTLS)。
private-keystring(unset)<key file path>与 `certificate` 配对的私钥。
udpboolfalsetrue | false允许 UDP 包经此出站转发。
idle-session-check-intervalint0<seconds>会话池扫描间隔。0 使用运行时默认。
idle-session-timeoutint0<seconds>空闲超过该秒数的会话会被回收。0 使用运行时默认。
min-idle-sessionint0<int>池中需保持温热的最少会话数。

源码: adapter/outbound/anytls.go:25-43 · 锚定版本 v1.19.27 (5184081)

入站

listeners:type: anytls 条目。内嵌 BaseOption

字段类型默认值允许值描述
usersmap[string]string{}{<username>: <password>}用户表 —— 用户名到密码的映射。
certificatestring(required)<PEM file path>TLS 服务端证书。
private-keystring(required)<key file path>TLS 私钥。
client-auth-typestring(none)no-client-cert | request-client-cert | require-any-client-cert | verify-client-cert-if-given | require-and-verify-client-certmTLS 客户端鉴权模式。
client-auth-certstring(unset)<PEM file path>作为客户端根的 CA 集合。
ech-keystring(unset)<ECH config>Encrypted Client Hello 配置 / 密钥。
allow-insecureboolfalsetrue | false在监听器上跳过 TLS 客户端证书校验(仅供测试)。
padding-schemestring(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)

由 Argsment 出品的 Core Tutorial