mirror of
https://github.com/eycorsican/leaf.git
synced 2026-12-05 08:01:26 +00:00
b83e44ec9f6ebb614b17dd53da791fb463d4eb5a
A chain has to answer three questions about every actor -- which of its two handlers runs, what address it is told to reach, and which actor the caller should dial before any of it starts -- and it answered them in the middle of doing the I/O. `next_connect_addr` served two of those questions at once with subtly different rules on the stream and datagram sides, recomputed per actor per connection; the datagram fold then made the same decisions again in five branches with a lookahead. Nothing said that actor zero is the one nearest the wire, or why only the last one is shown the client's stream. The rules now live in `outbound/plan.rs` as a function from actors to stages: one backward pass for what each suffix names, one forward fold for which handler each actor runs. It touches no sockets, so the seven tests under it are the first statement anywhere of what a chain is supposed to do -- that a transport leaves the address to what is inside it, that every actor but the last is told to reach the next hop, that a datagram stays a stream until the actor that tunnels it. The handlers are left with the I/O and with naming the actor in any error, which they never did. Inbound had the same fold written four times -- two handlers and two functions for the actors behind a multiplexed transport -- agreeing on the interesting parts and differing in the rest: one panicked with `unimplemented!()` where another returned, one timed out each actor and the others did not. One fold now, and the case that used to panic ends the chain instead. Behaviour is unchanged with two exceptions, both where the old code was indefensible: a datagram handed to an actor that speaks only streams was silently dropped and reported as that actor being handed nothing, and is now an error naming it; and the datagram lookahead asked about the wrong suffix for every actor after the first, which no configuration here reaches but which was wrong on its own terms. Verified against 178 end-to-end cases that put traffic through chains -- every stack, every relay shape, quic and amux and ws among them -- plus leaf's own suite.
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%
