mirror of
https://github.com/eycorsican/leaf.git
synced 2026-12-05 08:01:26 +00:00
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.
AnyTLS through a plugin
client.json runs a SOCKS5 proxy on 127.0.0.1:1080 that sends everything
through an AnyTLS server, with the protocol supplied by the
anytls-cabi-go plugin.
Build
From the repository root:
cargo build -p leaf-cli --features leaf/plugin
(cd leaf-plugins/anytls-cabi-go && \
go build -buildmode=c-shared -o ../../target/debug/libanytls_cabi_go.dylib .)
On Linux the library is libanytls_cabi_go.so; change path to match.
A server to try it against
Any AnyTLS server will do. With sing-box:
{
"inbounds": [
{
"type": "anytls",
"listen": "::",
"listen_port": 443,
"users": [{ "name": "me", "password": "change-me" }],
"tls": {
"enabled": true,
"server_name": "server.example.com",
"certificate_path": "/etc/ssl/server.example.com.crt",
"key_path": "/etc/ssl/server.example.com.key"
}
}
],
"outbounds": [{ "type": "direct" }]
}
mihomo's anytls listener and anytls-go's own server work the same way; the
end-to-end suite runs the plugin against all three (make interop).
Run
./target/debug/leaf -c examples/anytls-cabi/client.json
curl -x socks5h://127.0.0.1:1080 https://example.com
Set host, server_name and password to your server's. The certificate is
checked against server_name; for a server with a private CA, add
"certificate": "/path/to/ca.pem" to args.