快速开始¶
本节介绍如何安装 ClashRS、编写最小可用配置并验证代理连通性。
安装方式¶
前往 GitHub Releases 下载与操作系统及 CPU 架构匹配的压缩包。
在 Linux / macOS 上赋予可执行权限并检查版本:
Windows TUN 依赖说明
在 Windows 上使用标准构建启用 TUN 时,需以管理员身份运行,并将对应架构的 wintun.dll 放在 clash-rs.exe 同级目录下。若自行通过 MSVC 编译,也可启用 --features wintun-embed 将 Wintun 直接内嵌进可执行文件。
官方镜像发布在 GitHub Container Registry:
docker run -d \
--name clash-rs \
--restart unless-stopped \
-p 7890:7890 \
-p 9090:9090 \
-v /path/to/clash-config:/etc/clash \
ghcr.io/watfaq/clash-rs:latest \
-d /etc/clash -c config.yaml
如在 Linux 容器内启用 TUN,还需附加 --cap-add NET_ADMIN --device /dev/net/tun。
构建依赖¶
- Rust 工具链(Edition 2024)
cmake(3.29 及以上)libclang(LLVM)protoc(用于生成 GeoData Protobuf 代码)nasm(仅 Windows 需要)
编译命令¶
git clone https://github.com/Watfaq/clash-rs.git
cd clash-rs
# 标准 Release 构建(默认特性:standard、aws-lc-rs、dashboard)
cargo build --release
# Plus 构建(额外包含 Tor / onion 出站)
cargo build --release --features plus
# 包含静态 Cronet 的 Naive 出站构建
cargo build --locked --release -p clash-rs --features naive-static,naive-download
Cargo 特性组合(Features)¶
| 特性名 | 包含能力 |
|---|---|
default(clash-bin) |
standard、aws-lc-rs、dashboard |
standard |
shadowsocks、tuic、ssh、shadowquic、wireguard、tailscale、zero_copy、tproxy、tun、redir |
plus |
standard 全部能力 + onion(Tor) |
naive / naive-static / naive-download |
Naive 出站(基于 Cronet);默认未启用 |
wintun-embed |
Windows MSVC 构建内嵌 wintun.dll |
telemetry |
OpenTelemetry / Jaeger 链路追踪导出 |
编写最小配置¶
创建一个工作目录并保存 config.yaml:
mixed-port: 7890
allow-lan: false
mode: rule
log-level: info
external-controller: 127.0.0.1:9090
proxies:
- name: demo-ss
type: ss
server: proxy.example.com
port: 8388
cipher: 2022-blake3-aes-128-gcm
password: "YOUR_BASE64_PASSWORD"
udp: true
proxy-groups:
- name: PROXY
type: select
proxies:
- demo-ss
- DIRECT
rules:
- DOMAIN-SUFFIX,example.com,PROXY
- MATCH,DIRECT
自动创建默认模板
在非 --service-mode 模式下,如果指定的配置文件尚不存在,ClashRS 会自动生成一个仅包含 port: 7890 的默认配置文件。
校验并启动¶
-
先校验配置文件语法与逻辑:
若希望拒绝配置中的未知字段(而非静默忽略),可同时加上
--strict-config: -
启动 ClashRS:
-
验证代理工作正常:
-
打开内置 Web 面板:
配置
external-controller且使用默认dashboard特性构建时,直接在浏览器访问http://127.0.0.1:9090/ui/即可管理节点与连接。