ClashRS

A custom protocol, rule based network proxy software.

CI codecov

✨ Features

📡 Protocol Support

Inbounds

Type Description Notes
http HTTP proxy
socks SOCKS5 (TCP + UDP)
mixed HTTP + SOCKS5 on a single port
shadowsocks Shadowsocks inbound with multi-user support shadowsocks feature
anytls AnyTLS inbound with multi-user support, GFW fallback camouflage
tun TUN device for transparent proxying All platforms
tproxy Transparent proxy (TCP + UDP) Linux; tproxy feature
redir TCP redirect Linux; redir feature
tunnel Routes all traffic to a fixed target

Outbounds

Protocol Transports Notes
direct
reject
ss plain · obfs-http · obfs-tls · v2ray-plugin-ws · v2ray-plugin-ws-tls · shadow-tls shadowsocks feature
socks5 plain TCP · TLS
anytls TLS
trojan TLS · WebSocket+TLS · gRPC+TLS
vmess TCP · TCP+TLS · WebSocket+TLS · H2+TLS · gRPC+TLS
vless TLS · WebSocket+TLS · H2+TLS · gRPC+TLS · REALITY
wireguard UDP (userspace) wireguard feature
hysteria2 QUIC · obfs-salamander
tuic QUIC (bbr / cubic / new_reno) tuic feature
shadowquic QUIC · over-stream shadowquic feature
ssh SSH tunnel ssh feature
tor Onion routing onion feature (plus build)
tailscale Mesh VPN tailscale feature (plus build)

🖥 Environment Support

💰 Sponsors

📦 Install

Use With GUI

https://github.com/LibNyanpasu/clash-nyanpasu

Download Prebuilt Binary

Can be found at https://github.com/Watfaq/clash-rs/releases

Docker Image

https://github.com/Watfaq/clash-rs/pkgs/container/clash-rs

Local Build

Dependencies

$ pipx install pre-commit
$ pre-commit install

$ cargo build

🔨 Usage

Example Config

sample.yaml:

port: 7890

Run

-> % ./target/debug/clash-rs -c sample.yaml

Help

-> % ./target/debug/clash-rs -h
Usage: clash-rs [OPTIONS]

Options:
  -d, --directory <DIRECTORY>      Set working directory (config-relative paths resolve from here)
  -c, --config <FILE>              Specify configuration file [default: config.yaml] [short aliases: f]
  -t, --test-config                Test configuration and exit
  -v, --version                    Print clash-rs version and exit [short aliases: V]
  -l, --log-file <LOG_FILE>        Additionally log to file
      --help-improve               Enable crash report to help improve clash
      --controller-ipc <IPC_PATH>  Specify the IPC path for the controller [aliases: --ext-ctl-pipe, --ext-ctl-unix]
      --compatibility              Enable compatibility mode for mihomo-consistent behavior
  -h, --help                       Print help

FFI

Compile for apple platforms

To create a framework for iOS and macOS platforms

git clone https://github.com/Watfaq/clash-rs.git
cd clash-rs
chmod +x scripts/build_apple.sh
./scripts/build_apple.sh

This command will generate a clashrs.xcframework file in the build directory.

🔗 Links

🤝 Contributing

❤️ Inspired By