Files
eric 00eb09a0cb feat(plugins): add the AnyTLS and ShadowTLS v3 reference plugins
Two protocols leaf does not implement, each a thin Go adapter over the
library existing implementations use: anytls/sing-anytls for AnyTLS, and
sing-shadowtls with metacubex/utls for ShadowTLS, at sing-box v1.14.4's pins.

AnyTLS keeps TLS inside the plugin, since its padding scheme is defined over
TLS records, and shares one client per outbound so a server's own scheme
carries to the next connection. ShadowTLS is a transport under a chain,
usually Shadowsocks.

The ShadowTLS adapter signs the session ID itself rather than through uTLS's
hook: with a browser fingerprint that hook sends Go's own ClientHello, and
breaks on a HelloRetryRequest.

Each has unit tests against the library's server, READMEs, and example
configs. Both binaries are GPL-3.0, from their libraries.
2026-12-03 19:31:53 +08:00

2.0 KiB

ShadowTLS v3 through a plugin

client.json runs a SOCKS5 proxy on 127.0.0.1:1080 that sends everything through Shadowsocks carried by ShadowTLS v3. leaf's own Shadowsocks outbound names the server; the shadowtls-cabi-go plugin layers ShadowTLS under it as the first actor of the chain.

Build

From the repository root:

cargo build -p leaf-cli --features leaf/plugin
(cd leaf-plugins/shadowtls-cabi-go && \
  go build -buildmode=c-shared -o ../../target/debug/libshadowtls_cabi_go.dylib .)

On Linux the library is libshadowtls_cabi_go.so; change path to match.

A server to try it against

The server needs a site whose handshake to borrow: a real HTTPS site that negotiates TLS 1.3, named in the client's server_name. With sing-box:

{
  "inbounds": [
    {
      "type": "shadowtls",
      "listen": "::",
      "listen_port": 443,
      "version": 3,
      "users": [{ "name": "me", "password": "change-me" }],
      "handshake": { "server": "www.example.com", "server_port": 443 },
      "strict_mode": true,
      "detour": "ss-in"
    },
    {
      "type": "shadowsocks",
      "tag": "ss-in",
      "listen": "127.0.0.1",
      "listen_port": 8388,
      "method": "aes-128-gcm",
      "password": "change-me-too"
    }
  ],
  "outbounds": [{ "type": "direct" }]
}

With the original server, in front of any Shadowsocks server on port 8388:

shadow-tls --v3 --strict server --listen [::]:443 \
  --server 127.0.0.1:8388 --tls www.example.com:443 --password change-me

mihomo takes it as the shadow-tls option of a shadowsocks listener. The end-to-end suite runs the plugin against all three (make interop).

Run

./target/debug/leaf -c examples/shadowtls-cabi/client.json
curl -x socks5h://127.0.0.1:1080 https://example.com

Set the Shadowsocks address, both passwords, and server_name to match the server. Keep fingerprint set: without it the ClientHello is Go's, which a censor can tell from a browser's.