A versatile and efficient proxy framework.
## Documentation - [Configuration reference](docs/configuration.md): every option, what it accepts, and what happens when it is left out. - [Privacy, security and censorship](docs/security.md): which choices keep traffic behind the proxy, how the protocols compare on filtered networks, and a configuration to start from. - [Examples](examples/README.md): what each example is for, and what to change before deploying one. ## Supported Protocols ### Proxy Protocols | Protocol | Inbound | Outbound | |---|---|---| | HTTP | ✅ | ❌ | | SOCKS5 | ✅ | ✅ | | Shadowsocks | ✅ | ✅ | | Trojan | ✅ | ✅ | | VMess | ❌ | ✅ | | Vless | ❌ | ✅ | ### Transports & Security | Transport | Inbound | Outbound | Notes | |---|---|---|---| | WebSocket | ✅ | ✅ | | | TLS | ✅ | ✅ | | | QUIC | ✅ | ✅ | | | AMux | ✅ | ✅ | Leaf specific multiplexing | | Obfs | ❌ | ✅ | Simple obfuscation | | Reality | ❌ | ✅ | Xray Reality | | MPTP | ✅ | ✅ | Multi-path Transport Protocol (Aggregation) ([Architecture](docs/mptp_architecture.md), [Usage](docs/mptp_usage.md)) | ### Traffic Control | Feature | Inbound | Outbound | Notes | |---|---|---|---| | Chain | ✅ | ✅ | Proxy chaining | | Failover | ❌ | ✅ | Failover with health check | ### Transparent Proxying | Mechanism | Inbound | Outbound | Notes | |---|---|---|---| | TUN | ✅ | ❌ | Linux, macOS, Windows, iOS, Android | | NF | ✅ | ❌ | Windows, [NetFilter SDK](https://netfiltersdk.com/) | | TPROXY | ❌ | ❌ | Linux; Coming soon | ## Plugins Protocols and transports can also live outside the binary. A plugin is a shared library that exports a small C ABI, which leaf loads at startup and drives as an ordinary outbound -- so a plugin can be written in any language that can produce one, and shipped without rebuilding leaf. | Plugin | Language | Kind | |---|---|---| | [`shadowsocks-cabi-rs`](leaf-plugins/shadowsocks-cabi-rs) | Rust | Shadowsocks, TCP and UDP | | [`tls-cabi-rs`](leaf-plugins/tls-cabi-rs) | Rust | TLS transport | | [`tls-cabi-go`](leaf-plugins/tls-cabi-go) | Go | TLS transport | | [`trojan-cabi-go`](leaf-plugins/trojan-cabi-go) | Go | Trojan, TCP and UDP | | [`socks5-cabi-c`](leaf-plugins/socks5-cabi-c) | C | SOCKS5, TCP | | [`socks5-cabi-zig`](leaf-plugins/socks5-cabi-zig) | Zig | SOCKS5, TCP | | [`anytls-cabi-go`](leaf-plugins/anytls-cabi-go) | Go | AnyTLS, TCP | | [`shadowtls-cabi-go`](leaf-plugins/shadowtls-cabi-go) | Go | ShadowTLS v3 transport | The two SOCKS5 plugins are the same protocol written twice, in two languages with no runtime of their own, and both are held to the same end-to-end suite as leaf's own SOCKS5 outbound. AnyTLS and ShadowTLS are protocols leaf does not implement at all: they exist here only as plugins, each a thin adapter over the library the protocol's existing implementations use, and each tested against the servers people deploy -- anytls-go, sing-box, mihomo and the original shadow-tls -- with `make interop`. Both link GPL-3.0 libraries, so their binaries are GPL-3.0; leaf loads them at run time and is not affected. A plugin is configured as an outbound like any other, and can be chained with built-in ones: ```json { "tag": "ss-plugin", "protocol": "plugin", "settings": { "path": "./target/release/libshadowsocks_cabi_rs.dylib", "host": "example.com", "port": 8388, "args": "chacha20-ietf-poly1305;password", "sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" } } ``` `args` is passed to the plugin untouched; `host` and `port` are required by plugins that connect to a server of their own, and rejected by transport plugins that layer on the previous outbound in a chain. `path` must have a directory part -- a bare library name would let the dynamic loader search `LD_LIBRARY_PATH` or the DLL search order, which is not a choice a config file gets to hand to the environment -- and leaf refuses a library that anyone on the host can rewrite, whether that is the file's own mode or a world-writable directory with no sticky bit around it. There is no plugin directory and nothing is scanned. Every plugin leaf loads is one an outbound named, which is the same decision as refusing a bare name: what runs inside the proxy should be what the config says outright, not what the filesystem happened to be holding. `sha256` is optional and worth setting. Loading a shared library runs whatever its last writer put there, in leaf's process with leaf's privileges; the digest is the one check that still holds if that writer was not you. Get it with `shasum -a 256