mirror of
https://github.com/eycorsican/leaf.git
synced 2026-12-05 08:01:26 +00:00
97ea9fabd2e523685ab899696421aee216ac3caa
Plugins are dynamic libraries, and the boundary between them and leaf has to be something both sides can name without agreeing on a compiler. This crate is that boundary and nothing else: dependency-free, no_std, every repr(C) type and constant in one place, with include/leaf_plugin_abi.h as the single C declaration for plugins that are not written in Rust. A plugin exports a descriptor naming its ABI version, its struct sizes, optional stream and datagram engines, and whether it embeds a language runtime. abi_major must match exactly; abi_minor is informational and never gates loading. Each struct freezes a REQUIRED_SIZE prefix for its major version, and peers validate against that rather than their own sizeof, so an old plugin runs on a newer host and the reverse. The contract is written next to the declarations, because the parts that matter are the ones a signature cannot state: what each object's lifetime is, that instances move between threads and calls never overlap, that no call may block -- the readiness callback is what makes that workable -- and that decode_packet reports how much input it consumed, which is the only way a codec can be driven over a transport with no message boundaries. A parity test compiles a C probe and compares sizeof, offsetof and every constant against the Rust definitions, so the two declarations cannot drift unnoticed.
Leaf
A versatile and efficient proxy framework.
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, Usage) |
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; lwip, smoltcp |
| NF | ✅ | ❌ | Windows, NetFilter SDK |
| TPROXY | ❌ | ❌ | Linux; Coming soon |
Building
cargo build -p leaf-cli --release
./target/debug/leaf --help
License
This project is licensed under the Apache License 2.0.
Description
A versatile and efficient proxy framework.
4.5 MiB
0 Stars
1 Watchers
0 Forks
Languages
Rust
99.5%
Shell
0.5%
