A versatile and efficient proxy framework with nice features suitable for various use cases.
There are 2 transports for traffic multiplexing:
- AMux: A multiplexd transport based on reliable streams suitable for TCP-based protocols and transports
- QUIC: A UDP-based, multiplexed and secure transport
The benefit of amux
is that we can reuse connections to reduce handshake overhead, it's not designed to be memory efficient because it focus only on reusing connections and not reducing the number of connections. While quic
can reduce both handshake overhead and memory usage without suffering the head-of-line blocking issue.
There's the TUN inbound for this purpose, which is also of fundamental importance for VPN-like proxying use cases such as VPN apps on iOS and Android.
Outbounds such as failover
, tryall
, retry
, random
and their combinations are able to flexibly deliver reqeusts to other outbounds based on their own metrics to achieve high availability or load balancing behaviors.
Rule-based request routing is also supported. Requests can be routed to different outbounds based on domain, IP, GEOIP and port rules.
[General]
dns-server = 223.5.5.5
socks-interface = 127.0.0.1
socks-port = 1080
[Proxy]
Direct = direct
More configuration examples can be found here.
This syntax (tun = auto
) is supported on macOS and Linux.
[General]
dns-server = 223.5.5.5
tun = auto
[Proxy]
Direct = direct
Running in gateway mode requires a configuration with TUN mode enabled. Gateway mode can be enabled by an environment variable.
GATEWAY_MODE=true leaf -c config.conf
- Maple: A lightweight Universal Windows proxy app based on leaf
- Leaf: A simple iOS VPN app built with leaf
There are example projects demonstrating how you could easily build VPN apps for iOS and Android with leaf:
Install Rust: https://www.rust-lang.org/tools/install
Install GCC or Clang.
Clone & Build:
git clone --recursive https://github.com/eycorsican/leaf.git
cd leaf
cargo build -p leaf-bin
Run:
./target/debug/leaf -h
This project is licensed under the Apache License 2.0.