Docs(locales): add chinese locale support (#2772)
This commit is contained in:
59
docs/zh_CN/advanced-usages/golang-api.md
Normal file
59
docs/zh_CN/advanced-usages/golang-api.md
Normal file
@@ -0,0 +1,59 @@
|
||||
---
|
||||
sidebarTitle: 在 Golang 程序中集成 Clash
|
||||
sidebarOrder: 3
|
||||
---
|
||||
|
||||
# 在 Golang 程序中集成 Clash
|
||||
|
||||
如果 Clash 不能满足您的需求, 您可以在自己的 Golang 代码中使用 Clash.
|
||||
|
||||
目前已经有基本的支持:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
|
||||
"github.com/Dreamacro/clash/adapter/outbound"
|
||||
"github.com/Dreamacro/clash/constant"
|
||||
"github.com/Dreamacro/clash/listener/socks"
|
||||
)
|
||||
|
||||
func main() {
|
||||
in := make(chan constant.ConnContext, 100)
|
||||
defer close(in)
|
||||
|
||||
l, err := socks.New("127.0.0.1:10000", in)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer l.Close()
|
||||
|
||||
println("listen at:", l.Address())
|
||||
|
||||
direct := outbound.NewDirect()
|
||||
|
||||
for c := range in {
|
||||
conn := c
|
||||
metadata := conn.Metadata()
|
||||
fmt.Printf("请求从 %s 传入到 %s\n", metadata.SourceAddress(), metadata.RemoteAddress())
|
||||
go func () {
|
||||
remote, err := direct.DialContext(context.Background(), metadata)
|
||||
if err != nil {
|
||||
fmt.Printf("Dial 错误: %s\n", err.Error())
|
||||
return
|
||||
}
|
||||
relay(remote, conn.Conn())
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func relay(l, r net.Conn) {
|
||||
go io.Copy(l, r)
|
||||
io.Copy(r, l)
|
||||
}
|
||||
```
|
||||
102
docs/zh_CN/advanced-usages/openconnect.md
Normal file
102
docs/zh_CN/advanced-usages/openconnect.md
Normal file
@@ -0,0 +1,102 @@
|
||||
---
|
||||
sidebarTitle: 基于规则的 OpenConnect
|
||||
sidebarOrder: 2
|
||||
---
|
||||
|
||||
# 基于规则的 OpenConnect
|
||||
|
||||
支持以下 OpenConnect:
|
||||
|
||||
- Cisco AnyConnect SSL VPN
|
||||
- Juniper Network Connect
|
||||
- Palo Alto Networks (PAN) GlobalProtect SSL VPN
|
||||
- Pulse Connect Secure SSL VPN
|
||||
- F5 BIG-IP SSL VPN
|
||||
- FortiGate SSL VPN
|
||||
- Array Networks SSL VPN
|
||||
|
||||
例如, 您的公司使用 Cisco AnyConnect 作为内部网络访问的方式. 这里我将向您展示如何使用 Clash 提供的策略路由来使用 OpenConnect.
|
||||
|
||||
首先, [安装 vpn-slice](https://github.com/dlenski/vpn-slice#requirements). 这个工具会覆写 OpenConnect 的默认路由表行为. 简单来说, 它会阻止 VPN 覆写您的默认路由.
|
||||
|
||||
接下来您需要一个脚本 (比如 `tun0.sh`) 类似于这样:
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
ANYCONNECT_HOST="vpn.example.com"
|
||||
ANYCONNECT_USER="john"
|
||||
ANYCONNECT_PASSWORD="foobar"
|
||||
ROUTING_TABLE_ID="6667"
|
||||
TUN_INTERFACE="tun0"
|
||||
|
||||
# 如果服务器在中国大陆, 请添加 --no-dtls. 中国大陆的 UDP 会很卡.
|
||||
echo "$ANYCONNECT_PASSWORD" | \
|
||||
openconnect \
|
||||
--non-inter \
|
||||
--passwd-on-stdin \
|
||||
--protocol=anyconnect \
|
||||
--interface $TUN_INTERFACE \
|
||||
--script "vpn-slice
|
||||
if [ \"\$reason\" = 'connect' ]; then
|
||||
ip rule add from \$INTERNAL_IP4_ADDRESS table $ROUTING_TABLE_ID
|
||||
ip route add default dev \$TUNDEV scope link table $ROUTING_TABLE_ID
|
||||
elif [ \"\$reason\" = 'disconnect' ]; then
|
||||
ip rule del from \$INTERNAL_IP4_ADDRESS table $ROUTING_TABLE_ID
|
||||
ip route del default dev \$TUNDEV scope link table $ROUTING_TABLE_ID
|
||||
fi" \
|
||||
--user $ANYCONNECT_USER \
|
||||
https://$ANYCONNECT_HOST
|
||||
```
|
||||
|
||||
之后, 我们将其配置成一个 systemd 服务. 创建 `/etc/systemd/system/tun0.service`:
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Cisco AnyConnect VPN
|
||||
After=network-online.target
|
||||
Conflicts=shutdown.target sleep.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/path/to/tun0.sh
|
||||
KillSignal=SIGINT
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
然后我们启用并启动服务.
|
||||
|
||||
```shell
|
||||
chmod +x /path/to/tun0.sh
|
||||
systemctl daemon-reload
|
||||
systemctl enable tun0
|
||||
systemctl start tun0
|
||||
```
|
||||
|
||||
这里您可以查看日志来查看它是否正常运行. 简单的方法是查看 `tun0` 接口是否已经创建.
|
||||
|
||||
和 Wireguard 类似, 将 TUN 设备作为出站很简单, 只需要添加一个策略组:
|
||||
|
||||
```yaml
|
||||
proxy-groups:
|
||||
- name: Cisco AnyConnect VPN
|
||||
type: select
|
||||
interface-name: tun0
|
||||
proxies:
|
||||
- DIRECT
|
||||
```
|
||||
|
||||
... 然后就可以使用了!
|
||||
|
||||
添加您想要的规则:
|
||||
|
||||
```yaml
|
||||
rules:
|
||||
- DOMAIN-SUFFIX,internal.company.com,Cisco AnyConnect VPN
|
||||
```
|
||||
|
||||
当您发现有问题时, 您应该查看 debug 级别的日志.
|
||||
40
docs/zh_CN/advanced-usages/wireguard.md
Normal file
40
docs/zh_CN/advanced-usages/wireguard.md
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
sidebarTitle: 基于规则的 Wireguard
|
||||
sidebarOrder: 1
|
||||
---
|
||||
|
||||
# 基于规则的 Wireguard
|
||||
|
||||
假设您的内核支持 Wireguard 并且您已经启用了它. `Table` 选项可以阻止 _wg-quick_ 覆写默认路由.
|
||||
|
||||
例如 `wg0.conf`:
|
||||
|
||||
```ini
|
||||
[Interface]
|
||||
PrivateKey = ...
|
||||
Address = 172.16.0.1/32
|
||||
MTU = ...
|
||||
Table = off
|
||||
PostUp = ip rule add from 172.16.0.1/32 table 6666
|
||||
|
||||
[Peer]
|
||||
AllowedIPs = 0.0.0.0/0
|
||||
AllowedIPs = ::/0
|
||||
PublicKey = ...
|
||||
Endpoint = ...
|
||||
```
|
||||
|
||||
然后在 Clash 中您只需要有一个 DIRECT 策略组, 它包含一个指定的出站接口:
|
||||
|
||||
```yaml
|
||||
proxy-groups:
|
||||
- name: Wireguard
|
||||
type: select
|
||||
interface-name: wg0
|
||||
proxies:
|
||||
- DIRECT
|
||||
rules:
|
||||
- DOMAIN,google.com,Wireguard
|
||||
```
|
||||
|
||||
这通常比 Clash 自己实现的用户空间 Wireguard 客户端性能更好. Wireguard 在内核中支持.
|
||||
476
docs/zh_CN/configuration/configuration-reference.md
Normal file
476
docs/zh_CN/configuration/configuration-reference.md
Normal file
@@ -0,0 +1,476 @@
|
||||
---
|
||||
sidebarTitle: 参考配置
|
||||
sidebarOrder: 7
|
||||
---
|
||||
|
||||
# 参考配置
|
||||
|
||||
```yaml
|
||||
# HTTP(S) 代理服务端口
|
||||
port: 7890
|
||||
|
||||
# SOCKS5 代理服务端口
|
||||
socks-port: 7891
|
||||
|
||||
# Linux 和 macOS 的透明代理服务端口 (TCP 和 TProxy UDP 重定向)
|
||||
# redir-port: 7892
|
||||
|
||||
# Linux 的透明代理服务端口 (TProxy TCP 和 TProxy UDP)
|
||||
# tproxy-port: 7893
|
||||
|
||||
# HTTP(S) 和 SOCKS4(A)/SOCKS5 代理服务共用一个端口
|
||||
# mixed-port: 7890
|
||||
|
||||
# 本地 SOCKS5/HTTP(S) 代理服务的认证
|
||||
# authentication:
|
||||
# - "user1:pass1"
|
||||
# - "user2:pass2"
|
||||
|
||||
# 设置为 true 以允许来自其他 LAN IP 地址的连接
|
||||
# allow-lan: false
|
||||
|
||||
# 仅当 `allow-lan` 为 `true` 时有效
|
||||
# '*': 绑定所有 IP 地址
|
||||
# 192.168.122.11: 绑定单个 IPv4 地址
|
||||
# "[aaaa::a8aa:ff:fe09:57d8]": 绑定单个 IPv6 地址
|
||||
# bind-address: '*'
|
||||
|
||||
# Clash 路由工作模式
|
||||
# rule: 基于规则的数据包路由
|
||||
# global: 所有数据包将被转发到单个节点
|
||||
# direct: 直接将数据包转发到互联网
|
||||
mode: rule
|
||||
|
||||
# 默认情况下, Clash 将日志打印到 STDOUT
|
||||
# 日志级别: info / warning / error / debug / silent
|
||||
# log-level: info
|
||||
|
||||
# 当设置为 false 时, 解析器不会将主机名解析为 IPv6 地址
|
||||
# ipv6: false
|
||||
|
||||
# RESTful Web API 监听地址
|
||||
external-controller: 127.0.0.1:9090
|
||||
|
||||
# 配置目录的相对路径或静态 Web 资源目录的绝对路径. Clash core 将在
|
||||
# `http://{{external-controller}}/ui` 中提供服务.
|
||||
# external-ui: folder
|
||||
|
||||
# RESTful API 密钥 (可选)
|
||||
# 通过指定 HTTP 头 `Authorization: Bearer ${secret}` 进行身份验证
|
||||
# 如果RESTful API在 0.0.0.0 上监听, 务必设置一个 secret 密钥.
|
||||
# secret: ""
|
||||
|
||||
# 出站接口名称
|
||||
# interface-name: en0
|
||||
|
||||
# fwmark (仅在 Linux 上有效)
|
||||
# routing-mark: 6666
|
||||
|
||||
# 用于DNS服务器和连接建立的静态主机 (如/etc/hosts) .
|
||||
#
|
||||
# 支持通配符主机名 (例如 *.clash.dev, *.foo.*.example.com)
|
||||
# 非通配符域名优先级高于通配符域名
|
||||
# 例如 foo.example.com > *.example.com > .example.com
|
||||
# P.S. +.foo.com 等于 .foo.com 和 foo.com
|
||||
# hosts:
|
||||
# '*.clash.dev': 127.0.0.1
|
||||
# '.dev': 127.0.0.1
|
||||
# 'alpha.clash.dev': '::1'
|
||||
|
||||
# profile:
|
||||
# 将 `select` 手动选择 结果存储在 $HOME/.config/clash/.cache 中
|
||||
# 如果不需要此行为, 请设置为 false
|
||||
# 当两个不同的配置具有同名的组时, 将共享所选值
|
||||
# store-selected: true
|
||||
|
||||
# 持久化 fakeip
|
||||
# store-fake-ip: false
|
||||
|
||||
# DNS 服务设置
|
||||
# 此部分是可选的. 当不存在时, DNS 服务将被禁用.
|
||||
dns:
|
||||
enable: false
|
||||
listen: 0.0.0.0:53
|
||||
# ipv6: false # 当为 false 时, AAAA 查询的响应将为空
|
||||
|
||||
# 这些 名称服务器(nameservers) 用于解析下列 DNS 名称服务器主机名.
|
||||
# 仅指定 IP 地址
|
||||
default-nameserver:
|
||||
- 114.114.114.114
|
||||
- 8.8.8.8
|
||||
# enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16 # Fake IP 地址池 CIDR
|
||||
# use-hosts: true # 查找 hosts 并返回 IP 记录
|
||||
|
||||
# search-domains: [local] # A/AAAA 记录的搜索域
|
||||
|
||||
# 此列表中的主机名将不会使用 Fake IP 解析
|
||||
# 即, 对这些域名的请求将始终使用其真实 IP 地址进行响应
|
||||
# fake-ip-filter:
|
||||
# - '*.lan'
|
||||
# - localhost.ptlogin2.qq.com
|
||||
|
||||
# 支持 UDP、TCP、DoT、DoH. 您可以指定要连接的端口.
|
||||
# 所有 DNS 查询都直接发送到名称服务器, 无需代理
|
||||
# Clash 使用第一个收到的响应作为 DNS 查询的结果.
|
||||
nameserver:
|
||||
- 114.114.114.114 # 默认值
|
||||
- 8.8.8.8 # 默认值
|
||||
- tls://dns.rubyfish.cn:853 # DNS over TLS
|
||||
- https://1.1.1.1/dns-query # DNS over HTTPS
|
||||
- dhcp://en0 # 来自 dhcp 的 dns
|
||||
# - '8.8.8.8#en0'
|
||||
|
||||
# 当 `fallback` 存在时, DNS 服务器将向此部分中的服务器
|
||||
# 与 `nameservers` 中的服务器发送并发请求
|
||||
# 当 GEOIP 国家不是 `CN` 时, 将使用 fallback 服务器的响应
|
||||
# fallback:
|
||||
# - tcp://1.1.1.1
|
||||
# - 'tcp://1.1.1.1#en0'
|
||||
|
||||
# 如果使用 `nameservers` 解析的 IP 地址在下面指定的子网中,
|
||||
# 则认为它们无效, 并使用 `fallback` 服务器的结果.
|
||||
#
|
||||
# 当 `fallback-filter.geoip` 为 true 且 IP 地址的 GEOIP 为 `CN` 时,
|
||||
# 将使用 `nameservers` 服务器解析的 IP 地址.
|
||||
#
|
||||
# 如果 `fallback-filter.geoip` 为 false, 且不匹配 `fallback-filter.ipcidr`,
|
||||
# 则始终使用 `nameservers` 服务器的结果
|
||||
#
|
||||
# 这是对抗 DNS 污染攻击的一种措施.
|
||||
# fallback-filter:
|
||||
# geoip: true
|
||||
# geoip-code: CN
|
||||
# ipcidr:
|
||||
# - 240.0.0.0/4
|
||||
# domain:
|
||||
# - '+.google.com'
|
||||
# - '+.facebook.com'
|
||||
# - '+.youtube.com'
|
||||
|
||||
# 通过特定的名称服务器查找域名
|
||||
# nameserver-policy:
|
||||
# 'www.baidu.com': '114.114.114.114'
|
||||
# '+.internal.crop.com': '10.0.0.1'
|
||||
|
||||
proxies:
|
||||
# Shadowsocks
|
||||
# 支持的加密方法:
|
||||
# aes-128-gcm aes-192-gcm aes-256-gcm
|
||||
# aes-128-cfb aes-192-cfb aes-256-cfb
|
||||
# aes-128-ctr aes-192-ctr aes-256-ctr
|
||||
# rc4-md5 chacha20-ietf xchacha20
|
||||
# chacha20-ietf-poly1305 xchacha20-ietf-poly1305
|
||||
- name: "ss1"
|
||||
type: ss
|
||||
server: server
|
||||
port: 443
|
||||
cipher: chacha20-ietf-poly1305
|
||||
password: "password"
|
||||
# udp: true
|
||||
|
||||
- name: "ss2"
|
||||
type: ss
|
||||
server: server
|
||||
port: 443
|
||||
cipher: chacha20-ietf-poly1305
|
||||
password: "password"
|
||||
plugin: obfs
|
||||
plugin-opts:
|
||||
mode: tls # or http
|
||||
# host: bing.com
|
||||
|
||||
- name: "ss3"
|
||||
type: ss
|
||||
server: server
|
||||
port: 443
|
||||
cipher: chacha20-ietf-poly1305
|
||||
password: "password"
|
||||
plugin: v2ray-plugin
|
||||
plugin-opts:
|
||||
mode: websocket # 暂不支持 QUIC
|
||||
# tls: true # wss
|
||||
# skip-cert-verify: true
|
||||
# host: bing.com
|
||||
# path: "/"
|
||||
# mux: true
|
||||
# headers:
|
||||
# custom: value
|
||||
|
||||
# vmess
|
||||
# 支持的加密方法:
|
||||
# auto/aes-128-gcm/chacha20-poly1305/none
|
||||
- name: "vmess"
|
||||
type: vmess
|
||||
server: server
|
||||
port: 443
|
||||
uuid: uuid
|
||||
alterId: 32
|
||||
cipher: auto
|
||||
# udp: true
|
||||
# tls: true
|
||||
# skip-cert-verify: true
|
||||
# servername: example.com # 优先于 wss 主机
|
||||
# network: ws
|
||||
# ws-opts:
|
||||
# path: /path
|
||||
# headers:
|
||||
# Host: v2ray.com
|
||||
# max-early-data: 2048
|
||||
# early-data-header-name: Sec-WebSocket-Protocol
|
||||
|
||||
- name: "vmess-h2"
|
||||
type: vmess
|
||||
server: server
|
||||
port: 443
|
||||
uuid: uuid
|
||||
alterId: 32
|
||||
cipher: auto
|
||||
network: h2
|
||||
tls: true
|
||||
h2-opts:
|
||||
host:
|
||||
- http.example.com
|
||||
- http-alt.example.com
|
||||
path: /
|
||||
|
||||
- name: "vmess-http"
|
||||
type: vmess
|
||||
server: server
|
||||
port: 443
|
||||
uuid: uuid
|
||||
alterId: 32
|
||||
cipher: auto
|
||||
# udp: true
|
||||
# network: http
|
||||
# http-opts:
|
||||
# # method: "GET"
|
||||
# # path:
|
||||
# # - '/'
|
||||
# # - '/video'
|
||||
# # headers:
|
||||
# # Connection:
|
||||
# # - keep-alive
|
||||
|
||||
- name: vmess-grpc
|
||||
server: server
|
||||
port: 443
|
||||
type: vmess
|
||||
uuid: uuid
|
||||
alterId: 32
|
||||
cipher: auto
|
||||
network: grpc
|
||||
tls: true
|
||||
servername: example.com
|
||||
# skip-cert-verify: true
|
||||
grpc-opts:
|
||||
grpc-service-name: "example"
|
||||
|
||||
# socks5
|
||||
- name: "socks"
|
||||
type: socks5
|
||||
server: server
|
||||
port: 443
|
||||
# username: username
|
||||
# password: password
|
||||
# tls: true
|
||||
# skip-cert-verify: true
|
||||
# udp: true
|
||||
|
||||
# http
|
||||
- name: "http"
|
||||
type: http
|
||||
server: server
|
||||
port: 443
|
||||
# username: username
|
||||
# password: password
|
||||
# tls: true # https
|
||||
# skip-cert-verify: true
|
||||
# sni: custom.com
|
||||
|
||||
# Snell
|
||||
# 请注意, 目前还没有UDP支持.
|
||||
- name: "snell"
|
||||
type: snell
|
||||
server: server
|
||||
port: 44046
|
||||
psk: yourpsk
|
||||
# version: 2
|
||||
# obfs-opts:
|
||||
# mode: http # or tls
|
||||
# host: bing.com
|
||||
|
||||
# Trojan
|
||||
- name: "trojan"
|
||||
type: trojan
|
||||
server: server
|
||||
port: 443
|
||||
password: yourpsk
|
||||
# udp: true
|
||||
# sni: example.com # aka 服务器名称
|
||||
# alpn:
|
||||
# - h2
|
||||
# - http/1.1
|
||||
# skip-cert-verify: true
|
||||
|
||||
- name: trojan-grpc
|
||||
server: server
|
||||
port: 443
|
||||
type: trojan
|
||||
password: "example"
|
||||
network: grpc
|
||||
sni: example.com
|
||||
# skip-cert-verify: true
|
||||
udp: true
|
||||
grpc-opts:
|
||||
grpc-service-name: "example"
|
||||
|
||||
- name: trojan-ws
|
||||
server: server
|
||||
port: 443
|
||||
type: trojan
|
||||
password: "example"
|
||||
network: ws
|
||||
sni: example.com
|
||||
# skip-cert-verify: true
|
||||
udp: true
|
||||
# ws-opts:
|
||||
# path: /path
|
||||
# headers:
|
||||
# Host: example.com
|
||||
|
||||
# ShadowsocksR
|
||||
# 支持的加密方法: ss 中的所有流加密方法
|
||||
# 支持的混淆方式:
|
||||
# plain http_simple http_post
|
||||
# random_head tls1.2_ticket_auth tls1.2_ticket_fastauth
|
||||
# 支持的协议:
|
||||
# origin auth_sha1_v4 auth_aes128_md5
|
||||
# auth_aes128_sha1 auth_chain_a auth_chain_b
|
||||
- name: "ssr"
|
||||
type: ssr
|
||||
server: server
|
||||
port: 443
|
||||
cipher: chacha20-ietf
|
||||
password: "password"
|
||||
obfs: tls1.2_ticket_auth
|
||||
protocol: auth_sha1_v4
|
||||
# obfs-param: domain.tld
|
||||
# protocol-param: "#"
|
||||
# udp: true
|
||||
|
||||
proxy-groups:
|
||||
# 中继链路代理节点. 节点不应包含中继. 不支持 UDP.
|
||||
# 流量节点链路: clash <-> http <-> vmess <-> ss1 <-> ss2 <-> Internet
|
||||
- name: "relay"
|
||||
type: relay
|
||||
proxies:
|
||||
- http
|
||||
- vmess
|
||||
- ss1
|
||||
- ss2
|
||||
|
||||
# url-test 通过对 指定URL 进行基准速度测试来选择将使用哪个代理.
|
||||
- name: "auto"
|
||||
type: url-test
|
||||
proxies:
|
||||
- ss1
|
||||
- ss2
|
||||
- vmess1
|
||||
# tolerance: 150
|
||||
# lazy: true
|
||||
url: 'http://www.gstatic.com/generate_204'
|
||||
interval: 300
|
||||
|
||||
# fallback-auto 基于优先级选择可用策略. 可用性通过访问 指定URL 来测试, 就像自动 url-test 组一样.
|
||||
- name: "fallback-auto"
|
||||
type: fallback
|
||||
proxies:
|
||||
- ss1
|
||||
- ss2
|
||||
- vmess1
|
||||
url: 'http://www.gstatic.com/generate_204'
|
||||
interval: 300
|
||||
|
||||
# 负载均衡: 同一 eTLD+1 的请求将拨号到同一代理.
|
||||
- name: "load-balance"
|
||||
type: load-balance
|
||||
proxies:
|
||||
- ss1
|
||||
- ss2
|
||||
- vmess1
|
||||
url: 'http://www.gstatic.com/generate_204'
|
||||
interval: 300
|
||||
# strategy: consistent-hashing # or round-robin
|
||||
|
||||
# select 手动选择, 用于选择代理或策略组
|
||||
# 您可以使用 RESTful API 来切换代理, 建议在GUI中切换.
|
||||
- name: Proxy
|
||||
type: select
|
||||
# disable-udp: true
|
||||
# filter: 'someregex'
|
||||
proxies:
|
||||
- ss1
|
||||
- ss2
|
||||
- vmess1
|
||||
- auto
|
||||
|
||||
# 直接连接到另一个接口名称或 fwmark, 也支持代理
|
||||
- name: en1
|
||||
type: select
|
||||
interface-name: en1
|
||||
routing-mark: 6667
|
||||
proxies:
|
||||
- DIRECT
|
||||
|
||||
- name: UseProvider
|
||||
type: select
|
||||
use:
|
||||
- provider1
|
||||
proxies:
|
||||
- Proxy
|
||||
- DIRECT
|
||||
|
||||
proxy-providers:
|
||||
provider1:
|
||||
type: http
|
||||
url: "url"
|
||||
interval: 3600
|
||||
path: ./provider1.yaml
|
||||
health-check:
|
||||
enable: true
|
||||
interval: 600
|
||||
# lazy: true
|
||||
url: http://www.gstatic.com/generate_204
|
||||
test:
|
||||
type: file
|
||||
path: /test.yaml
|
||||
health-check:
|
||||
enable: true
|
||||
interval: 36000
|
||||
url: http://www.gstatic.com/generate_204
|
||||
|
||||
tunnels:
|
||||
# 单行配置
|
||||
- tcp/udp,127.0.0.1:6553,114.114.114.114:53,proxy
|
||||
- tcp,127.0.0.1:6666,rds.mysql.com:3306,vpn
|
||||
# 全 yaml 配置
|
||||
- network: [tcp, udp]
|
||||
address: 127.0.0.1:7777
|
||||
target: target.com
|
||||
proxy: proxy
|
||||
|
||||
rules:
|
||||
- DOMAIN-SUFFIX,google.com,auto
|
||||
- DOMAIN-KEYWORD,google,auto
|
||||
- DOMAIN,google.com,auto
|
||||
- DOMAIN-SUFFIX,ad.com,REJECT
|
||||
- SRC-IP-CIDR,192.168.1.201/32,DIRECT
|
||||
# 用于 IP 规则 (GEOIP, IP-CIDR, IP-CIDR6) 的可选参数 "no-resolve"
|
||||
- IP-CIDR,127.0.0.0/8,DIRECT
|
||||
- GEOIP,CN,DIRECT
|
||||
- DST-PORT,80,DIRECT
|
||||
- SRC-PORT,7777,DIRECT
|
||||
- RULE-SET,apple,REJECT # 仅 Premium 版本支持
|
||||
- MATCH,auto
|
||||
```
|
||||
72
docs/zh_CN/configuration/dns.md
Normal file
72
docs/zh_CN/configuration/dns.md
Normal file
@@ -0,0 +1,72 @@
|
||||
---
|
||||
sidebarTitle: Clash DNS
|
||||
sidebarOrder: 6
|
||||
---
|
||||
|
||||
# Clash DNS
|
||||
|
||||
由于 Clash 的某些部分运行在第 3 层 (网络层) , 因此其数据包的域名是无法获取的, 也就无法进行基于规则的路由.
|
||||
|
||||
*Enter fake-ip*: 它支持基于规则的路由, 最大程度地减少了 DNS 污染攻击的影响, 并且提高了网络性能, 有时甚至是显著的.
|
||||
|
||||
## fake-ip
|
||||
|
||||
"fake IP" 的概念源自 [RFC 3089](https://tools.ietf.org/rfc/rfc3089):
|
||||
|
||||
> 一个 "fake IP" 地址被用于查询相应的 "FQDN" 信息的关键字.
|
||||
|
||||
fake-ip 池的默认 CIDR 是 `198.18.0.1/16` (一个保留的 IPv4 地址空间, 可以在 `dns.fake-ip-range` 中进行更改).
|
||||
|
||||
当 DNS 请求被发送到 Clash DNS 时, Clash 内核会通过管理内部的域名和其 fake-ip 地址的映射, 从池中分配一个 *空闲* 的 fake-ip 地址.
|
||||
|
||||
以使用浏览器访问 `http://google.com` 为例.
|
||||
|
||||
1. 浏览器向 Clash DNS 请求 `google.com` 的 IP 地址
|
||||
2. Clash 检查内部映射并返回 `198.18.1.5`
|
||||
3. 浏览器向 `198.18.1.5` 的 `80/tcp` 端口发送 HTTP 请求
|
||||
4. 当收到 `198.18.1.5` 的入站数据包时, Clash 查询内部映射, 发现客户端实际上是在向 `google.com` 发送数据包
|
||||
5. 根据规则的不同:
|
||||
|
||||
1. Clash 可能仅将域名发送到 SOCKS5 或 shadowsocks 等出站代理, 并与代理服务器建立连接
|
||||
|
||||
2. 或者 Clash 可能会基于 `SCRIPT`、`GEOIP`、`IP-CIDR` 规则或者使用 DIRECT 直连出口查询 `google.com` 的真实 IP 地址
|
||||
|
||||
由于这是一个令人困惑的概念, 我将以使用 cURL 程序访问 `http://google.com` 为例:
|
||||
|
||||
```txt{2,3,5,6,8,9}
|
||||
$ curl -v http://google.com
|
||||
<---- cURL 向您的系统 DNS (Clash) 询问 google.com 的 IP 地址
|
||||
----> Clash 决定使用 198.18.1.70 作为 google.com 的 IP 地址, 并记住它
|
||||
* Trying 198.18.1.70:80...
|
||||
<---- cURL 连接到 198.18.1.70 tcp/80
|
||||
----> Clash 将立即接受连接, 并且..
|
||||
* Connected to google.com (198.18.1.70) port 80 (#0)
|
||||
----> Clash 在其内存中查找到 198.18.1.70 对应于 google.com
|
||||
----> Clash 查询对应的规则, 并通过匹配的出口发送数据包
|
||||
> GET / HTTP/1.1
|
||||
> Host: google.com
|
||||
> User-Agent: curl/8.0.1
|
||||
> Accept: */*
|
||||
>
|
||||
< HTTP/1.1 301 Moved Permanently
|
||||
< Location: http://www.google.com/
|
||||
< Content-Type: text/html; charset=UTF-8
|
||||
< Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-ahELFt78xOoxhySY2lQ34A' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
|
||||
< Date: Thu, 11 May 2023 06:52:19 GMT
|
||||
< Expires: Sat, 10 Jun 2023 06:52:19 GMT
|
||||
< Cache-Control: public, max-age=2592000
|
||||
< Server: gws
|
||||
< Content-Length: 219
|
||||
< X-XSS-Protection: 0
|
||||
< X-Frame-Options: SAMEORIGIN
|
||||
<
|
||||
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
|
||||
<TITLE>301 Moved</TITLE></HEAD><BODY>
|
||||
<H1>301 Moved</H1>
|
||||
The document has moved
|
||||
<A HREF="http://www.google.com/">here</A>.
|
||||
</BODY></HTML>
|
||||
* Connection #0 to host google.com left intact
|
||||
```
|
||||
|
||||
<!-- TODO: nameserver, fallback, fallback-filter, hosts, search-domains, fake-ip-filter, nameserver-policy -->
|
||||
76
docs/zh_CN/configuration/getting-started.md
Normal file
76
docs/zh_CN/configuration/getting-started.md
Normal file
@@ -0,0 +1,76 @@
|
||||
---
|
||||
sidebarTitle: 快速入手
|
||||
sidebarOrder: 2
|
||||
---
|
||||
|
||||
# 快速入手
|
||||
|
||||
建议您在继续阅读本节之前, 先阅读[介绍](/zh_CN/configuration/introduction). 在您对Clash的工作原理有了简单的了解后, 您可以开始编写您自己的配置.
|
||||
|
||||
## 配置文件
|
||||
|
||||
主配置文件名为 `config.yaml`. 默认情况下, Clash会在 `$HOME/.config/clash` 目录读取配置文件. 如果该目录不存在, Clash会在该位置生成一个最小的配置文件.
|
||||
|
||||
如果您想将配置文件放在其他地方 (例如 `/etc/clash`) , 您可以使用命令行选项 `-d` 来指定配置目录:
|
||||
|
||||
```shell
|
||||
clash -d . # current directory
|
||||
clash -d /etc/clash
|
||||
```
|
||||
|
||||
或者, 您可以使用选项 `-f` 来指定配置文件:
|
||||
|
||||
```shell
|
||||
clash -f ./config.yaml
|
||||
clash -f /etc/clash/config.yaml
|
||||
```
|
||||
|
||||
## 特殊语法
|
||||
|
||||
Clash 配置文件中有一些特殊的语法, 您可能需要了解:
|
||||
|
||||
### IPv6 地址
|
||||
|
||||
您应该使用方括号 (`[]`) 来包裹 IPv6 地址, 例如:
|
||||
|
||||
```txt
|
||||
[aaaa::a8aa:ff:fe09:57d8]
|
||||
```
|
||||
|
||||
### DNS 通配符域名匹配
|
||||
|
||||
在某些情况下, 您需要匹配通配符域名. 例如, 当您设置 [Clash DNS](/zh_CN/configuration/dns) 时, 您可能想要匹配 `localdomain` 的所有子域名.
|
||||
|
||||
Clash 在 DNS 配置中提供了匹配不同级别通配符域名的支持, 其语法如下:
|
||||
|
||||
::: tip
|
||||
任何包含这些字符的域名都应该用单引号 (`'`) 包裹. 例如, `'*.google.com'`.
|
||||
静态域名的优先级高于通配符域名 (foo.example.com > *.example.com > .example.com) .
|
||||
:::
|
||||
|
||||
使用星号 (`*`) 来匹配单级通配符子域名.
|
||||
|
||||
| 表达式 | 匹配 | 不匹配 |
|
||||
| ---------- | ------- | -------------- |
|
||||
| `*.google.com` | `www.google.com` | `google.com` |
|
||||
| `*.bar.google.com` | `foo.bar.google.com` | `bar.google.com` |
|
||||
| `*.*.google.com` | `thoughtful.sandbox.google.com` | `one.two.three.google.com` |
|
||||
|
||||
使用点号 (`.`) 来匹配多级通配符子域名.
|
||||
|
||||
| 表达式 | 匹配 | 不匹配 |
|
||||
| ---------- | ------- | -------------- |
|
||||
| `.google.com` | `www.google.com` | `google.com` |
|
||||
| `.google.com` | `thoughtful.sandbox.google.com` | `google.com` |
|
||||
| `.google.com` | `one.two.three.google.com` | `google.com` |
|
||||
|
||||
使用加号 (`+`) 来匹配多级通配符子域名.
|
||||
|
||||
`+` 通配符的工作方式类似于 `DOMAIN-SUFFIX`, 您可以一次进行多级的快速匹配.
|
||||
|
||||
| 表达式 | 匹配 |
|
||||
| ---------- | ------- |
|
||||
| `+.google.com` | `google.com` |
|
||||
| `+.google.com` | `www.google.com` |
|
||||
| `+.google.com` | `thoughtful.sandbox.google.com` |
|
||||
| `+.google.com` | `one.two.three.google.com` |
|
||||
69
docs/zh_CN/configuration/inbound.md
Normal file
69
docs/zh_CN/configuration/inbound.md
Normal file
@@ -0,0 +1,69 @@
|
||||
---
|
||||
sidebarTitle: Inbound 入站
|
||||
sidebarOrder: 3
|
||||
---
|
||||
|
||||
# Inbound 入站
|
||||
|
||||
Clash 支持多种入站协议, 包括:
|
||||
|
||||
- SOCKS5
|
||||
- HTTP(S)
|
||||
- Redirect TCP
|
||||
- TProxy TCP
|
||||
- TProxy UDP
|
||||
- Linux TUN 设备 (仅 Premium 版本)
|
||||
|
||||
任何入站协议的连接都将由同一个内部规则匹配引擎处理. 也就是说, Clash **目前**不支持为不同的入站协议设置不同的规则集.
|
||||
|
||||
## 配置
|
||||
|
||||
```yaml
|
||||
# HTTP(S) 代理服务端口
|
||||
# port: 7890
|
||||
|
||||
# SOCKS5 代理服务端口
|
||||
socks-port: 7891
|
||||
|
||||
# HTTP(S) 和 SOCKS4(A)/SOCKS5 代理服务共用一个端口
|
||||
mixed-port: 7890
|
||||
|
||||
# Linux 和 macOS 的透明代理服务端口 (TCP 和 TProxy UDP 重定向)
|
||||
# redir-port: 7892
|
||||
|
||||
# Linux 的透明代理服务端口 (TProxy TCP 和 TProxy UDP)
|
||||
# tproxy-port: 7893
|
||||
|
||||
# 设置为 true 以允许来自其他 LAN IP 地址的连接
|
||||
# allow-lan: false
|
||||
```
|
||||
|
||||
## Mixed 混合端口
|
||||
|
||||
混合端口是一个特殊的端口, 它同时支持 HTTP(S) 和 SOCKS5 协议. 您可以使用任何支持 HTTP 或 SOCKS 代理的程序连接到这个端口, 例如:
|
||||
|
||||
```shell
|
||||
$ curl -x socks5h://127.0.0.1:7890 -v http://connect.rom.miui.com/generate_204
|
||||
* Trying 127.0.0.1:7890...
|
||||
* SOCKS5 connect to connect.rom.miui.com:80 (remotely resolved)
|
||||
* SOCKS5 request granted.
|
||||
* Connected to (nil) (127.0.0.1) port 7890 (#0)
|
||||
> GET /generate_204 HTTP/1.1
|
||||
> Host: connect.rom.miui.com
|
||||
> User-Agent: curl/7.81.0
|
||||
> Accept: */*
|
||||
>
|
||||
* Mark bundle as not supporting multiuse
|
||||
< HTTP/1.1 204 No Content
|
||||
< Date: Thu, 11 May 2023 06:18:22 GMT
|
||||
< Connection: keep-alive
|
||||
< Content-Type: text/plain
|
||||
<
|
||||
* Connection #0 to host (nil) left intact
|
||||
```
|
||||
|
||||
## Redirect 和 TProxy
|
||||
|
||||
Redirect 和 TProxy 是两种实现透明代理的不同方式, 均被 Clash 所支持.
|
||||
|
||||
然而, 您不一定需要手动设置这两个功能 - 我们建议您使用 [Clash Premium 版本](/zh_CN/premium/introduction) 来配置透明代理, 因为它内置了对操作系统路由表、规则和 nftables 的自动管理.
|
||||
39
docs/zh_CN/configuration/introduction.md
Normal file
39
docs/zh_CN/configuration/introduction.md
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
sidebarTitle: 介绍
|
||||
sidebarOrder: 1
|
||||
---
|
||||
|
||||
# 介绍
|
||||
|
||||
在本章中, 我们将介绍 Clash 的常见功能以及如何使用和配置它们.
|
||||
|
||||
Clash 使用 [YAML](https://yaml.org) (YAML Ain't Markup Language) 作为配置文件格式. YAML 旨在易于阅读、编写和解析, 通常用于配置文件.
|
||||
|
||||
## 了解 Clash 的工作原理
|
||||
|
||||
在继续之前, 有必要了解 Clash 的工作原理, 其中有两个关键部分:
|
||||
|
||||

|
||||
|
||||
<!-- https://excalidraw.com/clash-connection-flow#json=OHsOdaqAUPuuN7VPvdZ9Z,NT7rRrtzRgbVIM0tpkPnGA -->
|
||||
|
||||
### Inbound 入站
|
||||
|
||||
Inbound 入站是在本地端监听的部分, 它通过打开一个本地端口并监听传入的连接来工作. 当连接进来时, Clash 会查询配置文件中配置的规则, 并决定连接应该去哪个 Outbound 出站.
|
||||
|
||||
### Outbound 出站
|
||||
|
||||
Outbound 出站是连接到远程端的部分. 根据配置的不同, 它可以是一个特定的网络接口、一个代理服务器或一个[策略组](/zh_CN/configuration/outbound#proxy-groups-策略组).
|
||||
|
||||
## 基于规则的路由
|
||||
|
||||
Clash 支持基于规则的路由, 这意味着您可以根据各种规则将数据包路由到不同的出站. 规则可以在配置文件的 `rules` 部分中定义.
|
||||
|
||||
有许多可用的规则类型, 每种规则类型都有自己的语法. 规则的一般语法是:
|
||||
|
||||
```txt
|
||||
# 类型,参数,策略(,no-resolve)
|
||||
TYPE,ARGUMENT,POLICY(,no-resolve)
|
||||
```
|
||||
|
||||
在下一步指南中, 您将了解有关如何配置规则的更多信息.
|
||||
434
docs/zh_CN/configuration/outbound.md
Normal file
434
docs/zh_CN/configuration/outbound.md
Normal file
@@ -0,0 +1,434 @@
|
||||
---
|
||||
sidebarTitle: Outbound 出站
|
||||
sidebarOrder: 4
|
||||
---
|
||||
|
||||
# Outbound 出站
|
||||
|
||||
Clash 中有几种类型的出站. 每种类型都有自己的特点和使用场景. 在本页中, 我们将介绍每种类型的通用特点以及如何使用和配置它们.
|
||||
|
||||
[[toc]]
|
||||
|
||||
## Proxies 代理节点
|
||||
|
||||
Proxies 代理节点是您可以配置的一些出站目标. 就像代理服务器一样, 您在这里为数据包定义目的地.
|
||||
|
||||
### Shadowsocks
|
||||
|
||||
Clash 支持以下 Shadowsocks 的加密方法:
|
||||
|
||||
| 系列 | 加密方法 |
|
||||
| ------ | ------- |
|
||||
| AEAD | aes-128-gcm, aes-192-gcm, aes-256-gcm, chacha20-ietf-poly1305, xchacha20-ietf-poly1305 |
|
||||
| 流式 | aes-128-cfb, aes-192-cfb, aes-256-cfb, rc4-md5, chacha20-ietf, xchacha20 |
|
||||
| 块式 | aes-128-ctr, aes-192-ctr, aes-256-ctr |
|
||||
|
||||
此外, Clash 还支持流行的 Shadowsocks 插件 `obfs` 和 `v2ray-plugin`.
|
||||
|
||||
::: code-group
|
||||
|
||||
```yaml [basic]
|
||||
- name: "ss1"
|
||||
type: ss
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
cipher: chacha20-ietf-poly1305
|
||||
password: "password"
|
||||
# udp: true
|
||||
```
|
||||
|
||||
```yaml [obfs]
|
||||
- name: "ss2"
|
||||
type: ss
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
cipher: chacha20-ietf-poly1305
|
||||
password: "password"
|
||||
plugin: obfs
|
||||
plugin-opts:
|
||||
mode: tls # or http
|
||||
# host: bing.com
|
||||
```
|
||||
|
||||
```yaml [ws (websocket)]
|
||||
- name: "ss3"
|
||||
type: ss
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
cipher: chacha20-ietf-poly1305
|
||||
password: "password"
|
||||
plugin: v2ray-plugin
|
||||
plugin-opts:
|
||||
mode: websocket # 暂不支持 QUIC
|
||||
# tls: true # wss
|
||||
# skip-cert-verify: true
|
||||
# host: bing.com
|
||||
# path: "/"
|
||||
# mux: true
|
||||
# headers:
|
||||
# custom: value
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### ShadowsocksR
|
||||
|
||||
Clash 也支持声名狼藉的反审查协议 ShadowsocksR.
|
||||
|
||||
支持以下 ShadowsocksR 的加密方法:
|
||||
|
||||
| 系列 | 加密方法 |
|
||||
| ------ | ------- |
|
||||
| 流式 | aes-128-cfb, aes-192-cfb, aes-256-cfb, rc4-md5, chacha20-ietf, xchacha20 |
|
||||
|
||||
支持的混淆方法:
|
||||
|
||||
- plain
|
||||
- http_simple
|
||||
- http_post
|
||||
- random_head
|
||||
- tls1.2_ticket_auth
|
||||
- tls1.2_ticket_fastauth
|
||||
|
||||
支持的协议:
|
||||
|
||||
- origin
|
||||
- auth_sha1_v4
|
||||
- auth_aes128_md5
|
||||
- auth_aes128_sha1
|
||||
- auth_chain_a
|
||||
- auth_chain_b
|
||||
|
||||
```yaml
|
||||
- name: "ssr"
|
||||
type: ssr
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
cipher: chacha20-ietf
|
||||
password: "password"
|
||||
obfs: tls1.2_ticket_auth
|
||||
protocol: auth_sha1_v4
|
||||
# obfs-param: domain.tld
|
||||
# protocol-param: "#"
|
||||
# udp: true
|
||||
```
|
||||
|
||||
### Vmess
|
||||
|
||||
Clash 支持以下 Vmess 的加密方法:
|
||||
|
||||
- auto
|
||||
- aes-128-gcm
|
||||
- chacha20-poly1305
|
||||
- none
|
||||
|
||||
::: code-group
|
||||
|
||||
```yaml [basic]
|
||||
- name: "vmess"
|
||||
type: vmess
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
uuid: uuid
|
||||
alterId: 32
|
||||
cipher: auto
|
||||
# udp: true
|
||||
# tls: true
|
||||
# skip-cert-verify: true
|
||||
# servername: example.com # 优先于 wss 主机
|
||||
# network: ws
|
||||
# ws-opts:
|
||||
# path: /path
|
||||
# headers:
|
||||
# Host: v2ray.com
|
||||
# max-early-data: 2048
|
||||
# early-data-header-name: Sec-WebSocket-Protocol
|
||||
```
|
||||
|
||||
```yaml [HTTP]
|
||||
- name: "vmess-http"
|
||||
type: vmess
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
uuid: uuid
|
||||
alterId: 32
|
||||
cipher: auto
|
||||
# udp: true
|
||||
# network: http
|
||||
# http-opts:
|
||||
# # method: "GET"
|
||||
# # path:
|
||||
# # - '/'
|
||||
# # - '/video'
|
||||
# # headers:
|
||||
# # Connection:
|
||||
# # - keep-alive
|
||||
```
|
||||
|
||||
```yaml [HTTP/2]
|
||||
- name: "vmess-h2"
|
||||
type: vmess
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
uuid: uuid
|
||||
alterId: 32
|
||||
cipher: auto
|
||||
network: h2
|
||||
tls: true
|
||||
h2-opts:
|
||||
host:
|
||||
- http.example.com
|
||||
- http-alt.example.com
|
||||
path: /
|
||||
```
|
||||
|
||||
```yaml [gRPC]
|
||||
- name: vmess-grpc
|
||||
type: vmess
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
uuid: uuid
|
||||
alterId: 32
|
||||
cipher: auto
|
||||
network: grpc
|
||||
tls: true
|
||||
servername: example.com
|
||||
# skip-cert-verify: true
|
||||
grpc-opts:
|
||||
grpc-service-name: "example"
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### Socks5
|
||||
|
||||
此外, Clash 还支持 Socks5 代理.
|
||||
|
||||
```yaml
|
||||
- name: "socks"
|
||||
type: socks5
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
# username: username
|
||||
# password: password
|
||||
# tls: true
|
||||
# skip-cert-verify: true
|
||||
# udp: true
|
||||
```
|
||||
|
||||
### HTTP
|
||||
|
||||
Clash 也支持 HTTP 代理:
|
||||
|
||||
::: code-group
|
||||
|
||||
```yaml [HTTP]
|
||||
- name: "http"
|
||||
type: http
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
# username: username
|
||||
# password: password
|
||||
```
|
||||
|
||||
```yaml [HTTPS]
|
||||
- name: "http"
|
||||
type: http
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
# username: username
|
||||
# password: password
|
||||
tls: true
|
||||
skip-cert-verify: true
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### Snell
|
||||
|
||||
作为可选的反审查协议, Clash也集成了对Snell的支持.
|
||||
|
||||
```yaml
|
||||
# 暂不支持 UDP
|
||||
- name: "snell"
|
||||
type: snell
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 44046
|
||||
psk: yourpsk
|
||||
# version: 2
|
||||
# obfs-opts:
|
||||
# mode: http # or tls
|
||||
# host: bing.com
|
||||
```
|
||||
|
||||
### Trojan
|
||||
|
||||
Clash 内置了对流行协议 Trojan 的支持:
|
||||
|
||||
::: code-group
|
||||
|
||||
```yaml [basic]
|
||||
- name: "trojan"
|
||||
type: trojan
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
password: yourpsk
|
||||
# udp: true
|
||||
# sni: example.com # aka server name
|
||||
# alpn:
|
||||
# - h2
|
||||
# - http/1.1
|
||||
# skip-cert-verify: true
|
||||
```
|
||||
|
||||
```yaml [gRPC]
|
||||
- name: trojan-grpc
|
||||
type: trojan
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
password: "example"
|
||||
network: grpc
|
||||
sni: example.com
|
||||
# skip-cert-verify: true
|
||||
udp: true
|
||||
grpc-opts:
|
||||
grpc-service-name: "example"
|
||||
```
|
||||
|
||||
```yaml [ws (websocket)]
|
||||
- name: trojan-ws
|
||||
type: trojan
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
password: "example"
|
||||
network: ws
|
||||
sni: example.com
|
||||
# skip-cert-verify: true
|
||||
udp: true
|
||||
# ws-opts:
|
||||
# path: /path
|
||||
# headers:
|
||||
# Host: example.com
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
## Proxy Groups 策略组
|
||||
|
||||
Proxy Groups 策略组用于根据不同策略分发规则传递过来的请求, 其可以直接被规则引用, 也可以被其他策略组引用, 而最上级策略组被规则引用.
|
||||
|
||||
### relay 中继
|
||||
|
||||
请求将依次通过指定的代理服务器进行中继, 目前不支持 UDP. 指定的代理服务器不应包含另一个 relay 中继.
|
||||
|
||||
### url-test 延迟测试
|
||||
|
||||
Clash 会周期性地通过指定的 URL 向列表中的代理服务器发送 HTTP HEAD 请求来测试每个代理服务器的**延迟**. 可以设置最大容忍值、测试间隔和目标 URL.
|
||||
|
||||
### fallback 可用性测试
|
||||
|
||||
Clash 会周期性地通过指定的 URL 向列表中的代理服务器发送 HTTP HEAD 请求来测试每个代理服务器的**可用性**. 第一个可用的服务器将被使用.
|
||||
|
||||
### load-balance 负载均衡
|
||||
|
||||
相同 eTLD+1 的请求将使用同一个代理服务器.
|
||||
|
||||
### select 手动选择
|
||||
|
||||
Clash 启动时默认使用策略组中的第一个代理服务器. 用户可以使用 RESTful API 选择要使用的代理服务器. 在此模式下, 您可以在配置中硬编码服务器或使用 [Proxy Providers 代理集](#proxy-providers-代理集) 动态添加服务器.
|
||||
|
||||
无论哪种方式, 有时您也可以使用直接连接来路由数据包. 在这种情况下, 您可以使用 `DIRECT` 直连出站.
|
||||
|
||||
要使用不同的网络接口, 您需要使用包含 `DIRECT` 直连出站的策略组, 并设置 `interface-name` 选项.
|
||||
|
||||
```yaml
|
||||
- name: "My Wireguard Outbound"
|
||||
type: select
|
||||
interface-name: wg0
|
||||
proxies: [ 'DIRECT' ]
|
||||
```
|
||||
|
||||
## Proxy Providers 代理集
|
||||
|
||||
代理集使用户可以动态加载代理服务器列表, 而不是在配置文件中硬编码. 目前有两种代理集可以加载服务器列表:
|
||||
|
||||
- `http`: Clash 会在启动时从指定的 URL 加载服务器列表. 如果设置了 `interval` 选项, Clash 会定期从远程拉取服务器列表.
|
||||
- `file`: Clash 会在启动时从指定的文件位置加载服务器列表.
|
||||
|
||||
健康检查对两种模式都可用, 并且与策略组中的 `fallback` 完全相同. 服务器列表文件的配置格式在主配置文件中也完全相同:
|
||||
|
||||
::: code-group
|
||||
|
||||
```yaml [config.yaml]
|
||||
proxy-providers:
|
||||
provider1:
|
||||
type: http
|
||||
url: "url"
|
||||
interval: 3600
|
||||
path: ./provider1.yaml
|
||||
# filter: 'a|b' # golang regex 正则表达式
|
||||
health-check:
|
||||
enable: true
|
||||
interval: 600
|
||||
# lazy: true
|
||||
url: http://www.gstatic.com/generate_204
|
||||
test:
|
||||
type: file
|
||||
path: /test.yaml
|
||||
health-check:
|
||||
enable: true
|
||||
interval: 36000
|
||||
url: http://www.gstatic.com/generate_204
|
||||
```
|
||||
|
||||
```yaml [test.yaml]
|
||||
proxies:
|
||||
- name: "ss1"
|
||||
type: ss
|
||||
server: server
|
||||
port: 443
|
||||
cipher: chacha20-ietf-poly1305
|
||||
password: "password"
|
||||
|
||||
- name: "ss2"
|
||||
type: ss
|
||||
server: server
|
||||
port: 443
|
||||
cipher: chacha20-ietf-poly1305
|
||||
password: "password"
|
||||
plugin: obfs
|
||||
plugin-opts:
|
||||
mode: tls
|
||||
```
|
||||
|
||||
:::
|
||||
168
docs/zh_CN/configuration/rules.md
Normal file
168
docs/zh_CN/configuration/rules.md
Normal file
@@ -0,0 +1,168 @@
|
||||
---
|
||||
sidebarTitle: Rules 规则
|
||||
sidebarOrder: 5
|
||||
---
|
||||
|
||||
# Rules 规则
|
||||
|
||||
在[快速入手](/zh_CN/configuration/getting-started)中, 我们介绍了Clash中基于规则的匹配的基本知识. 在本章中, 我们将介绍最新版本的 Clash 中所有可用的规则类型.
|
||||
|
||||
```txt
|
||||
# 类型,参数,策略(,no-resolve)
|
||||
TYPE,ARGUMENT,POLICY(,no-resolve)
|
||||
```
|
||||
|
||||
`no-resolve` 选项是可选的, 它用于跳过规则的 DNS 解析. 当您想要使用 `GEOIP`、`IP-CIDR`、`IP-CIDR6`、`SCRIPT` 规则, 但又不想立即将域名解析为 IP 地址时, 这个选项就很有用了.
|
||||
|
||||
[[toc]]
|
||||
|
||||
## 策略
|
||||
|
||||
目前有四种策略类型, 其中:
|
||||
|
||||
- DIRECT: 通过 `interface-name` 直接连接到目标 (不查找系统路由表)
|
||||
- REJECT: 丢弃数据包
|
||||
- Proxy: 将数据包路由到指定的代理服务器
|
||||
- Proxy Group: 将数据包路由到指定的策略组
|
||||
|
||||
## 规则类型
|
||||
|
||||
以下部分介绍了每种规则类型及其使用方法:
|
||||
|
||||
### DOMAIN 域名
|
||||
|
||||
`DOMAIN,www.google.com,policy` 将 `www.google.com` 路由到 `policy`.
|
||||
|
||||
### DOMAIN-SUFFIX 域名后缀
|
||||
|
||||
`DOMAIN-SUFFIX,youtube.com,policy` 将任何以 `youtube.com` 结尾的域名路由到 `policy`.
|
||||
|
||||
在这种情况下, `www.youtube.com` 和 `foo.bar.youtube.com` 都将路由到 `policy`.
|
||||
|
||||
### DOMAIN-KEYWORD 域名关键字
|
||||
|
||||
`DOMAIN-KEYWORD,google,policy` 将任何包含 `google` 关键字的域名路由到 `policy`.
|
||||
|
||||
在这种情况下, `www.google.com` 或 `googleapis.com` 都将路由到 `policy`.
|
||||
|
||||
### GEOIP IP地理位置 (国家代码)
|
||||
|
||||
GEOIP 规则用于根据数据包的目标 IP 地址的**国家代码**路由数据包. Clash 使用 [MaxMind GeoLite2](https://dev.maxmind.com/geoip/geoip2/geolite2/) 数据库来实现这一功能.
|
||||
|
||||
::: warning
|
||||
使用这种规则时, Clash 将域名解析为 IP 地址, 然后查找 IP 地址的国家代码.
|
||||
如果要跳过 DNS 解析, 请使用 `no-resolve` 选项.
|
||||
:::
|
||||
|
||||
`GEOIP,CN,policy` 将任何目标 IP 地址为中国的数据包路由到 `policy`.
|
||||
|
||||
### IP-CIDR IPv4地址段
|
||||
|
||||
IP-CIDR 规则用于根据数据包的**目标 IPv4 地址**路由数据包.
|
||||
|
||||
::: warning
|
||||
使用这种规则时, Clash 将域名解析为 IPv4 地址.
|
||||
如果要跳过 DNS 解析, 请使用 `no-resolve` 选项.
|
||||
:::
|
||||
|
||||
`IP-CIDR,127.0.0.0/8,DIRECT` 将任何目标 IP 地址为 `127.0.0.0/8` 的数据包路由到 `DIRECT`.
|
||||
|
||||
### IP-CIDR6 IPv6地址段
|
||||
|
||||
IP-CIDR6 规则用于根据数据包的**目标 IPv6 地址**路由数据包.
|
||||
|
||||
::: warning
|
||||
使用这种规则时, Clash 将域名解析为 IPv6 地址.
|
||||
如果要跳过 DNS 解析, 请使用 `no-resolve` 选项.
|
||||
:::
|
||||
|
||||
`IP-CIDR6,2620:0:2d0:200::7/32,policy` 将任何目标 IP 地址为 `2620:0:2d0:200::7/32` 的数据包路由到 `policy`.
|
||||
|
||||
### SRC-IP-CIDR 源IP段地址
|
||||
|
||||
SRC-IP-CIDR 规则用于根据数据包的**源 IPv4 地址**路由数据包.
|
||||
|
||||
`SRC-IP-CIDR,192.168.1.201/32,DIRECT` 将任何源 IP 地址为 `192.168.1.201/32` 的数据包路由到 `DIRECT`.
|
||||
|
||||
### SRC-PORT 源端口
|
||||
|
||||
SRC-PORT 规则用于根据数据包的**源端口**路由数据包.
|
||||
|
||||
`SRC-PORT,80,policy` 将任何源端口为 `80` 的数据包路由到 `policy`.
|
||||
|
||||
### DST-PORT 目标端口
|
||||
|
||||
DST-PORT 规则用于根据数据包的**目标端口**路由数据包.
|
||||
|
||||
`DST-PORT,80,policy` 将任何目标端口为 `80` 的数据包路由到 `policy`.
|
||||
|
||||
### PROCESS-NAME 源进程名
|
||||
|
||||
PROCESS-NAME 规则用于根据发送数据包的进程名称路由数据包.
|
||||
|
||||
::: warning
|
||||
目前, 仅支持 macOS、Linux、FreeBSD 和 Windows.
|
||||
:::
|
||||
|
||||
`PROCESS-NAME,nc,DIRECT` 将任何来自进程 `nc` 的数据包路由到 `DIRECT`.
|
||||
|
||||
### PROCESS-PATH 源进程路径
|
||||
|
||||
PROCESS-PATH 规则用于根据发送数据包的进程路径路由数据包.
|
||||
|
||||
::: warning
|
||||
目前, 仅支持 macOS、Linux、FreeBSD 和 Windows.
|
||||
:::
|
||||
|
||||
`PROCESS-PATH,/usr/local/bin/nc,DIRECT` 将任何来自路径为 `/usr/local/bin/nc` 的进程的数据包路由到 `DIRECT`.
|
||||
|
||||
### IPSET IP集
|
||||
|
||||
IPSET 规则用于根据 IP 集匹配并路由数据包. 根据 [IPSET 的官方网站](https://ipset.netfilter.org/) 的介绍:
|
||||
|
||||
> IP 集是 Linux 内核中的一个框架, 可以通过 ipset 程序进行管理. 根据类型, IP 集可以存储 IP 地址、网络、 (TCP/UDP) 端口号、MAC 地址、接口名称或它们以某种方式的组合, 以确保在集合中匹配条目时具有闪电般的速度.
|
||||
|
||||
因此, 此功能仅在 Linux 上工作, 并且需要安装 `ipset`.
|
||||
|
||||
::: warning
|
||||
使用此规则时, Clash 将解析域名以获取 IP 地址, 然后查找 IP 地址是否在 IP 集中.
|
||||
如果要跳过 DNS 解析, 请使用 `no-resolve` 选项.
|
||||
:::
|
||||
|
||||
`IPSET,chnroute,policy` 将任何目标 IP 地址在 IP 集 `chnroute` 中的数据包路由到 `policy`.
|
||||
|
||||
### RULE-SET 规则集
|
||||
|
||||
::: info
|
||||
此功能仅在 [Premium 版本](/zh_CN/premium/introduction) 中可用.
|
||||
:::
|
||||
|
||||
RULE-SET 规则用于根据 [Rule Providers 规则集](/zh_CN/premium/rule-providers) 的结果路由数据包. 当 Clash 使用此规则时, 它会从指定的 Rule Providers 规则集中加载规则, 然后将数据包与规则进行匹配. 如果数据包与任何规则匹配, 则将数据包路由到指定的策略, 否则跳过此规则.
|
||||
|
||||
::: warning
|
||||
使用 RULE-SET 时, 当规则集的类型为 IPCIDR , Clash 将解析域名以获取 IP 地址.
|
||||
如果要跳过 DNS 解析, 请使用 `no-resolve` 选项.
|
||||
:::
|
||||
|
||||
`RULE-SET,my-rule-provider,DIRECT` 从 `my-rule-provider` 加载所有规则
|
||||
|
||||
### SCRIPT 脚本
|
||||
|
||||
::: info
|
||||
此功能仅在 [Premium 版本](/zh_CN/premium/introduction) 中可用.
|
||||
:::
|
||||
|
||||
SCRIPT 规则用于根据脚本的结果路由数据包. 当 Clash 使用此规则时, 它会执行指定的脚本, 然后将数据包路由到脚本的输出.
|
||||
|
||||
::: warning
|
||||
使用 SCRIPT 时, Clash 将解析域名以获取 IP 地址.
|
||||
如果要跳过 DNS 解析, 请使用 `no-resolve` 选项.
|
||||
:::
|
||||
|
||||
`SCRIPT,script-path,DIRECT` 将数据包路由到脚本 `script-path` 的输出.
|
||||
|
||||
### MATCH 全匹配
|
||||
|
||||
MATCH 规则用于路由剩余的数据包. 该规则是**必需**的, 通常用作最后一条规则.
|
||||
|
||||
`MATCH,policy` 将剩余的数据包路由到 `policy`.
|
||||
38
docs/zh_CN/index.md
Normal file
38
docs/zh_CN/index.md
Normal file
@@ -0,0 +1,38 @@
|
||||
<!-- 这是 index 页面, 由位于 Introduction/_dummy-index.md 的虚拟侧边栏文件链接 -->
|
||||
# 什么是 Clash?
|
||||
|
||||
欢迎访问 Clash 内核项目的官方说明文档.
|
||||
|
||||
Clash是一个跨平台的基于规则的代理工具, 在网络和应用层运行, 支持各种代理和反审查协议的开箱即用.
|
||||
|
||||
在一些互联网受到严格审查或封锁的国家和地区, 它已被互联网用户广泛采用. 无论如何, 任何想要改善其 Internet 体验的人都可以使用 Clash.
|
||||
|
||||
目前, Clash 包含两个版本:
|
||||
|
||||
- [Clash](https://github.com/Dreamacro/clash): 发布于[github.com/Dreamacro/clash](https://github.com/Dreamacro/clash)的开源版本
|
||||
- [Clash Premium 版本](https://github.com/Dreamacro/clash/releases/tag/premium): 具有[TUN 和更多支持](/zh_CN/premium/introduction) 的专有内核 (免费)
|
||||
|
||||
虽然这个 Wiki 涵盖了上述两个版本的内容, 然而对于普通用户来说, Clash 的使用可能仍是一种挑战. 而对于考虑使用 GUI 客户端的用户, 我们确实有一些建议:
|
||||
|
||||
- [Clash for Windows](https://github.com/Fndroid/clash_for_windows_pkg/releases) (Windows 和 macOS)
|
||||
- [Clash for Android](https://github.com/Kr328/ClashForAndroid)
|
||||
- [ClashX](https://github.com/yichengchen/clashX) 或 [ClashX Pro](https://install.appcenter.ms/users/clashx/apps/clashx-pro/distribution_groups/public) (macOS)
|
||||
|
||||
## 特点概述
|
||||
|
||||
- 入站连接支持: HTTP, HTTPS, SOCKS5 服务端, TUN 设备*
|
||||
- 出站连接支持: Shadowsocks(R), VMess, Trojan, Snell, SOCKS5, HTTP(S), Wireguard*
|
||||
- 基于规则的路由: 动态脚本、域名、IP地址、进程名称和更多*
|
||||
- Fake-IP DNS: 尽量减少 DNS 污染的影响, 提高网络性能
|
||||
- 透明代理: 使用自动路由表/规则管理 Redirect TCP 和 TProxy TCP/UDP*
|
||||
- Proxy Groups 策略组: 自动化的可用性测试 (fallback)、负载均衡 (load balance) 或 延迟测试 (url-test)
|
||||
- 远程 Providers: 动态加载远程代理列表
|
||||
- RESTful API: 通过一个全面的 API 就地更新配置
|
||||
|
||||
<!-- markdownlint-disable MD033 -->
|
||||
<small>\*: 只在免费的 Premium 版本中提供. </small>
|
||||
<!-- markdownlint-enable MD033 -->
|
||||
|
||||
## License
|
||||
|
||||
Clash 是根据 [GPL-3.0](https://github.com/Dreamacro/clash/blob/master/LICENSE) 开源许可证发布的. 在 [v0.16.0](https://github.com/Dreamacro/clash/releases/tag/v0.16.0) 或 [e5284c](https://github.com/Dreamacro/clash/commit/e5284cf647717a8087a185d88d15a01096274bc2) 提交之前, 其基于 MIT 许可证授权.
|
||||
6
docs/zh_CN/introduction/_dummy-index.md
Normal file
6
docs/zh_CN/introduction/_dummy-index.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
sidebarTitle: 什么是 Clash?
|
||||
sidebarOrder: 1
|
||||
---
|
||||
|
||||
<!-- 此文件用作始终链接到 / 的虚拟侧边栏项目 -->
|
||||
95
docs/zh_CN/introduction/faq.md
Normal file
95
docs/zh_CN/introduction/faq.md
Normal file
@@ -0,0 +1,95 @@
|
||||
---
|
||||
sidebarTitle: 常见问题
|
||||
sidebarOrder: 4
|
||||
---
|
||||
|
||||
# 常见问题
|
||||
|
||||
这里是一些大家遇到的常见问题. 如果您有任何此处未列出的问题, 请随时[提交一个 issue](https://github.com/Dreamacro/clash/issues/new/choose).
|
||||
|
||||
[[toc]]
|
||||
|
||||
## amd64 和 amd64-v3 有什么区别?
|
||||
|
||||
引用自 [golang/go](https://github.com/golang/go/wiki/MinimumRequirements#amd64):
|
||||
|
||||
> 在 Go 1.17 之前, Go 编译器总是生成任何 64 位 x86 处理器都可以执行的 x86 二进制文件.
|
||||
>
|
||||
> Go 1.18 引入了 AMD64 的 [4 个架构级别](https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels).
|
||||
> 每个级别都有不同的x86指令集, 编译器可以在生成的二进制文件中包含这些指令:
|
||||
>
|
||||
> - GOAMD64=v1 (默认) : 基线. 仅生成所有 64 位 x86 处理器都可以执行的指令.
|
||||
> - GOAMD64=v2: 所有 v1 指令, 加上 CMPXCHG16B、LAHF、SAHF、POPCNT、SSE3、SSE4.1、SSE4.2、SSSE3.
|
||||
> - GOAMD64=v3: 所有 v2 指令, 加上 AVX、AVX2、BMI1、BMI2、F16C、FMA、LZCNT、MOVBE、OSXSAVE.
|
||||
> - GOAMD64=v4: 所有 v3 指令, 加上 AVX512F、AVX512BW、AVX512CD、AVX512DQ、AVX512VL.
|
||||
>
|
||||
> 例如, 设置 `GOAMD64=v3` 将允许 Go 编译器在生成的二进制文件中使用 AVX2 指令 (这可能会在某些情况下提高性能) ;但是这些二进制文件将无法在不支持 AVX2 的旧 x86 处理器上运行.
|
||||
>
|
||||
> Go工具链也可能生成较新的指令, 但会存在动态检查保护, 确保它们只在有能力的处理器上执行. 例如在 `GOAMD64=v1` 的情况下, 如果 [CPUID](https://www.felixcloutier.com/x86/cpuid) 报告说 [POPCNT](https://www.felixcloutier.com/x86/popcnt) 指令可用, [math/bits.OnesCount](https://pkg.go.dev/math/bits#OnesCount) 仍将使用该指令. 否则, 它就会退回到一个通用的实现.
|
||||
>
|
||||
> Go 工具链目前不会生成任何 AVX512 指令.
|
||||
>
|
||||
> 请注意, 在这种情况下, *处理器*是一个简化. 实际上, 整个系统 (固件、hypervisor、内核) 都需要支持.
|
||||
|
||||
## 我的系统应该使用哪个版本?
|
||||
|
||||
这里是一些人们在 Clash 上使用的常见系统, 以及每个系统的推荐版本:
|
||||
|
||||
- NETGEAR WNDR3700v2: mips-hardfloat [#846](https://github.com/Dreamacro/clash/issues/846)
|
||||
- NETGEAR WNDR3800: mips-softfloat [#579](https://github.com/Dreamacro/clash/issues/579)
|
||||
- 华硕RT-AC5300: armv5 [#2356](https://github.com/Dreamacro/clash/issues/2356)
|
||||
- 联发科MT7620A, MT7621A: mipsle-softfloat ([#136](https://github.com/Dreamacro/clash/issues/136))
|
||||
- mips_24kc: [#192](https://github.com/Dreamacro/clash/issues/192)
|
||||
|
||||
如果您的设备未在此处列出, 您可以使用 `uname -m` 检查设备的 CPU 架构, 并在发布页面中找到相应的版本.
|
||||
|
||||
## 不会修复的问题
|
||||
|
||||
官方 Clash 内核项目不会实现/修复以下内容:
|
||||
|
||||
- [Snell](https://github.com/Dreamacro/clash/issues/2466)
|
||||
- [Custom CA](https://github.com/Dreamacro/clash/issues/2333)
|
||||
- [VMess Mux](https://github.com/Dreamacro/clash/issues/450)
|
||||
- [VLess](https://github.com/Dreamacro/clash/issues/1185)
|
||||
- [KCP](https://github.com/Dreamacro/clash/issues/16)
|
||||
- [mKCP](https://github.com/Dreamacro/clash/issues/2308)
|
||||
- [TLS Encrypted Client Hello](https://github.com/Dreamacro/clash/issues/2295)
|
||||
- [TCP support for Clash DNS server](https://github.com/Dreamacro/clash/issues/368)
|
||||
- [MITM](https://github.com/Dreamacro/clash/issues/227#issuecomment-508693628)
|
||||
|
||||
当官方Go QUIC库发布时, 以下内容将被考虑实施:
|
||||
|
||||
- [TUIC](https://github.com/Dreamacro/clash/issues/2222)
|
||||
- [Hysteria](https://github.com/Dreamacro/clash/issues/1863)
|
||||
|
||||
## 在本地机器上节点正常工作, 但在路由器或容器中不起作用
|
||||
|
||||
您的系统可能未与世界时间同步. 请参考您的平台关于时间同步的文件 - 如果时间不同步, 某些协议可能无法正常工作.
|
||||
|
||||
## 规则匹配的时间复杂度
|
||||
|
||||
请参考这个讨论: [#422](https://github.com/Dreamacro/clash/issues/422)
|
||||
|
||||
## Clash Premium 无法访问互联网
|
||||
|
||||
您可以参考这些相关讨论:
|
||||
|
||||
- [#432](https://github.com/Dreamacro/clash/issues/432#issuecomment-571634905)
|
||||
- [#2480](https://github.com/Dreamacro/clash/issues/2480)
|
||||
|
||||
## 错误: 不支持的 RULE-SET 规则类型
|
||||
|
||||
如果您遇到了这个错误信息:
|
||||
|
||||
```txt
|
||||
FATA[0000] Parse config error: Rules[0] [RULE-SET,apple,REJECT] error: unsupported rule type RULE-SET
|
||||
```
|
||||
|
||||
您正在使用 Clash 开源版. 规则 Providers 目前仅在 [免费 Premium 内核](https://github.com/Dreamacro/clash/releases/tag/premium) 中可用.
|
||||
|
||||
## DNS 劫持不起作用
|
||||
|
||||
由于 `tun.auto-route` 不会拦截局域网流量, 如果您的系统 DNS 设置为私有子网中的服务器, 则 DNS 劫持将不起作用. 您可以:
|
||||
|
||||
1. 使用非私有 DNS 服务器作为系统 DNS, 如 `1.1.1.1`
|
||||
2. 或者手动将系统 DNS 设置为 Clash DNS (默认为 `198.18.0.1`)
|
||||
50
docs/zh_CN/introduction/getting-started.md
Normal file
50
docs/zh_CN/introduction/getting-started.md
Normal file
@@ -0,0 +1,50 @@
|
||||
---
|
||||
sidebarTitle: 快速开始
|
||||
sidebarOrder: 2
|
||||
---
|
||||
|
||||
# 快速开始
|
||||
|
||||
为了开始使用 Clash, 您可以从源码编译或者下载预编译的二进制文件.
|
||||
|
||||
## 使用预编译的二进制文件
|
||||
|
||||
您可以在这里下载 Clash 的内核二进制文件: [https://github.com/Dreamacro/clash/releases](https://github.com/Dreamacro/clash/releases)
|
||||
|
||||
## 从源码编译
|
||||
|
||||
您可以使用 Golang 1.19+ 在您的设备上编译 Clash:
|
||||
|
||||
```shell
|
||||
$ go install github.com/Dreamacro/clash@latest
|
||||
go: downloading github.com/Dreamacro/clash v1.15.1
|
||||
```
|
||||
|
||||
二进制文件将会被编译到 `$GOPATH/bin` 目录下:
|
||||
|
||||
```shell
|
||||
$ $GOPATH/bin/clash -v
|
||||
Clash unknown version darwin arm64 with go1.20.3 unknown time
|
||||
```
|
||||
|
||||
## 跨平台/操作系统编译
|
||||
|
||||
Golang 支持交叉编译, 所以您可以为不同架构或操作系统的设备编译 Clash. 您可以使用 _make_ 来轻松地编译它们, 例如:
|
||||
|
||||
```shell
|
||||
$ git clone --depth 1 https://github.com/Dreamacro/clash
|
||||
Cloning into 'clash'...
|
||||
remote: Enumerating objects: 359, done.
|
||||
remote: Counting objects: 100% (359/359), done.
|
||||
remote: Compressing objects: 100% (325/325), done.
|
||||
remote: Total 359 (delta 25), reused 232 (delta 17), pack-reused 0
|
||||
Receiving objects: 100% (359/359), 248.99 KiB | 1.63 MiB/s, done.
|
||||
Resolving deltas: 100% (25/25), done.
|
||||
$ cd clash && make darwin-arm64
|
||||
fatal: No names found, cannot describe anything.
|
||||
GOARCH=arm64 GOOS=darwin CGO_ENABLED=0 go build -trimpath -ldflags '-X "github.com/Dreamacro/clash/constant.Version=unknown version" -X "github.com/Dreamacro/clash/constant.BuildTime=Mon May 8 16:47:10 UTC 2023" -w -s -buildid=' -o bin/clash-darwin-arm64
|
||||
$ file bin/clash-darwin-arm64
|
||||
bin/clash-darwin-arm64: Mach-O 64-bit executable arm64
|
||||
```
|
||||
|
||||
对于其他构建目标, 请查看 [Makefile](https://github.com/Dreamacro/clash/blob/master/Makefile).
|
||||
131
docs/zh_CN/introduction/service.md
Normal file
131
docs/zh_CN/introduction/service.md
Normal file
@@ -0,0 +1,131 @@
|
||||
---
|
||||
sidebarTitle: Clash 服务运行
|
||||
sidebarOrder: 3
|
||||
---
|
||||
|
||||
# Clash 服务运行
|
||||
|
||||
Clash 需要在后台运行, 但是目前 Golang 还没有很好的守护进程实现, 因此我们推荐使用第三方工具来创建 Clash 的守护进程.
|
||||
|
||||
## systemd
|
||||
|
||||
使用以下命令将 Clash 二进制文件复制到 `/usr/local/bin`, 配置文件复制到 `/etc/clash`:
|
||||
|
||||
```shell
|
||||
cp clash /usr/local/bin
|
||||
cp config.yaml /etc/clash/
|
||||
cp Country.mmdb /etc/clash/
|
||||
```
|
||||
|
||||
创建 systemd 配置文件 `/etc/systemd/system/clash.service`:
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Clash 守护进程, Go 语言实现的基于规则的代理.
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
ExecStart=/usr/local/bin/clash -d /etc/clash
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
之后, 您应该使用以下命令重新加载 systemd:
|
||||
|
||||
```shell
|
||||
systemctl daemon-reload
|
||||
```
|
||||
|
||||
使用以下命令在系统启动时启动 Clash:
|
||||
|
||||
```shell
|
||||
systemctl enable clash
|
||||
```
|
||||
|
||||
使用以下命令立即启动 Clash:
|
||||
|
||||
```shell
|
||||
systemctl start clash
|
||||
```
|
||||
|
||||
使用以下命令检查 Clash 的运行状况和日志:
|
||||
|
||||
```shell
|
||||
systemctl status clash
|
||||
journalctl -xe
|
||||
```
|
||||
|
||||
本指南贡献者为 [ktechmidas](https://github.com/ktechmidas). ([#754](https://github.com/Dreamacro/clash/issues/754))
|
||||
|
||||
## Docker
|
||||
|
||||
本项目提供了预构建的 Clash 和 Clash Premium Docker 镜像. 因此, 在 Linux 上您可以使用 [Docker Compose](https://docs.docker.com/compose/) 部署 Clash. 但是, 您应该知道在容器中运行 **Clash Premium** 是[不被推荐的](https://github.com/Dreamacro/clash/issues/2249#issuecomment-1203494599)
|
||||
|
||||
::: warning
|
||||
由于 Mac 版 Docker 中缺少[主机网络和 TUN 支持](https://github.com/Dreamacro/clash/issues/770#issuecomment-650951876), 此设置将无法在 macOS 系统上运行.
|
||||
:::
|
||||
|
||||
::: code-group
|
||||
|
||||
```yaml [Clash]
|
||||
services:
|
||||
clash:
|
||||
image: ghcr.io/dreamacro/clash
|
||||
restart: always
|
||||
volumes:
|
||||
- ./config.yaml:/root/.config/clash/config.yaml:ro
|
||||
# - ./ui:/ui:ro # 仪表盘 Volume 映射
|
||||
ports:
|
||||
- "7890:7890"
|
||||
- "7891:7891"
|
||||
# - "8080:8080" # 外部控制 (RESTful API)
|
||||
network_mode: "bridge"
|
||||
```
|
||||
|
||||
```yaml [Clash Premium]
|
||||
services:
|
||||
clash:
|
||||
image: ghcr.io/dreamacro/clash-premium
|
||||
restart: always
|
||||
volumes:
|
||||
- ./config.yaml:/root/.config/clash/config.yaml:ro
|
||||
# - ./ui:/ui:ro # 仪表盘 Volume 映射
|
||||
ports:
|
||||
- "7890:7890"
|
||||
- "7891:7891"
|
||||
# - "8080:8080" # 外部控制 (RESTful API)
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
devices:
|
||||
- /dev/net/tun
|
||||
network_mode: "host"
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
保存为 `docker-compose.yaml`, 并将您的 `config.yaml` 放在同一目录下.
|
||||
|
||||
::: tip
|
||||
在继续操作之前, 请参考您的平台关于时间同步的文件 - 如果时间不同步, 某些协议可能无法正常工作.
|
||||
:::
|
||||
|
||||
准备就绪后, 运行以下命令以启动 Clash:
|
||||
|
||||
```shell
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
您可以使用以下命令查看日志:
|
||||
|
||||
```shell
|
||||
docker-compose logs
|
||||
```
|
||||
|
||||
Stop Clash with:
|
||||
|
||||
```shell
|
||||
docker-compose stop
|
||||
```
|
||||
26
docs/zh_CN/premium/ebpf.md
Normal file
26
docs/zh_CN/premium/ebpf.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
sidebarTitle: "功能: eBPF 重定向到 TUN"
|
||||
sidebarOrder: 3
|
||||
---
|
||||
|
||||
# 功能: eBPF 重定向到 TUN
|
||||
|
||||
eBPF 重定向到 TUN 是一项拦截特定网络接口上的所有网络流量, 并将其重定向到 TUN 接口的功能. 该功能需要[内核支持](https://github.com/iovisor/bcc/blob/master/INSTALL.md#kernel-configuration).
|
||||
|
||||
::: warning
|
||||
此功能与 `tun.auto-route` 冲突.
|
||||
:::
|
||||
|
||||
虽然它通常与 `tun.auto-redir` 和 `tun.auto-route` 相比具有更好的性能, 但与 `auto-route` 相比, 它并不够成熟. 因此, 您应该谨慎使用.
|
||||
|
||||
## 配置
|
||||
|
||||
```yaml
|
||||
ebpf:
|
||||
redirect-to-tun:
|
||||
- eth0
|
||||
```
|
||||
|
||||
## 已知问题
|
||||
|
||||
- 此功能与 Tailscaled 冲突, 因此您应该使用 `tun.auto-route` 作为替代.
|
||||
19
docs/zh_CN/premium/experimental-features.md
Normal file
19
docs/zh_CN/premium/experimental-features.md
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebarTitle: 实验功能
|
||||
sidebarOrder: 9
|
||||
---
|
||||
|
||||
# 实验功能
|
||||
|
||||
偶尔我们会做一些新的功能, 这些功能需要大量的测试才能在主要版本中使用. 这些功能被标记为实验性的, 并且默认是禁用的.
|
||||
|
||||
::: warning
|
||||
这里列出的一些功能可能不稳定, 并且可能在任何未来版本中被删除 - 我们不建议使用它们, 除非您有特定的原因.
|
||||
:::
|
||||
|
||||
## 嗅探 TLS SNI
|
||||
|
||||
```yaml
|
||||
experimental:
|
||||
sniff-tls-sni: true
|
||||
```
|
||||
26
docs/zh_CN/premium/introduction.md
Normal file
26
docs/zh_CN/premium/introduction.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
sidebarTitle: 简介
|
||||
sidebarOrder: 1
|
||||
---
|
||||
|
||||
# 简介
|
||||
|
||||
在过去, 只有一个开源版本的 Clash, 直到一些 [不当使用和再分发](https://github.com/Dreamacro/clash/issues/541#issuecomment-672029110) 的 Clash 出现. 从那时起, 我们决定分叉 Clash 并在私有 GitHub 存储库中开发更高级的功能.
|
||||
|
||||
不要担心 - Premium 内核将保持免费, 并且其源代码的安全性通过多个可信的开发人员相互审查以保证.
|
||||
|
||||
## 有什么区别?
|
||||
|
||||
Premium 内核是开源 Clash 内核的 Fork 分支, 增加了以下功能:
|
||||
|
||||
- [TUN 设备](/zh_CN/premium/tun-device) 支持 `auto-redir` 和 `auto-route`
|
||||
- [eBPF 重定向到 TUN](/zh_CN/premium/ebpf)
|
||||
- [Rule Providers 规则集](/zh_CN/premium/rule-providers)
|
||||
- [Script 脚本](/zh_CN/premium/script)
|
||||
- [Script Shotcuts 脚本捷径](/zh_CN/premium/script-shortcuts)
|
||||
- [用户空间 Wireguard](/zh_CN/premium/userspace-wireguard)
|
||||
- [性能分析引擎](/zh_CN/premium/the-profiling-engine)
|
||||
|
||||
## 获取副本
|
||||
|
||||
您可以从 [GitHub Releases](https://github.com/Dreamacro/clash/releases/tag/premium) 下载最新的 Clash Premium 二进制文件.
|
||||
100
docs/zh_CN/premium/rule-providers.md
Normal file
100
docs/zh_CN/premium/rule-providers.md
Normal file
@@ -0,0 +1,100 @@
|
||||
---
|
||||
sidebarTitle: "功能: Rule Providers 规则集"
|
||||
sidebarOrder: 4
|
||||
---
|
||||
|
||||
# Rule Providers 规则集
|
||||
|
||||
Rule Providers 规则集和 [Proxy Providers 代理集](/zh_CN/configuration/outbound#proxy-providers-代理集) 基本相同. 它允许用户从外部源加载规则, 从而使配置更加简洁. 该功能目前仅适用于 Clash Premium 内核.
|
||||
|
||||
要定义 Rule Providers 规则集, 请将 `rule-providers` 规则集字段添加到主配置中:
|
||||
|
||||
```yaml
|
||||
rule-providers:
|
||||
apple:
|
||||
behavior: "domain" # domain, ipcidr or classical (仅限 Clash Premium 内核)
|
||||
type: http
|
||||
url: "url"
|
||||
# format: 'yaml' # or 'text'
|
||||
interval: 3600
|
||||
path: ./apple.yaml
|
||||
microsoft:
|
||||
behavior: "domain"
|
||||
type: file
|
||||
path: /microsoft.yaml
|
||||
|
||||
rules:
|
||||
- RULE-SET,apple,REJECT
|
||||
- RULE-SET,microsoft,policy
|
||||
```
|
||||
|
||||
有三种行为类型可用:
|
||||
|
||||
## `domain`
|
||||
|
||||
yaml:
|
||||
|
||||
```yaml
|
||||
payload:
|
||||
- '.blogger.com'
|
||||
- '*.*.microsoft.com'
|
||||
- 'books.itunes.apple.com'
|
||||
```
|
||||
|
||||
text:
|
||||
|
||||
```txt
|
||||
# comment
|
||||
.blogger.com
|
||||
*.*.microsoft.com
|
||||
books.itunes.apple.com
|
||||
```
|
||||
|
||||
## `ipcidr`
|
||||
|
||||
yaml
|
||||
|
||||
```yaml
|
||||
payload:
|
||||
- '192.168.1.0/24'
|
||||
- '10.0.0.0.1/32'
|
||||
```
|
||||
|
||||
text:
|
||||
|
||||
```txt
|
||||
# comment
|
||||
192.168.1.0/24
|
||||
10.0.0.0.1/32
|
||||
```
|
||||
|
||||
## `classical`
|
||||
|
||||
yaml:
|
||||
|
||||
```yaml
|
||||
payload:
|
||||
- DOMAIN-SUFFIX,google.com
|
||||
- DOMAIN-KEYWORD,google
|
||||
- DOMAIN,ad.com
|
||||
- SRC-IP-CIDR,192.168.1.201/32
|
||||
- IP-CIDR,127.0.0.0/8
|
||||
- GEOIP,CN
|
||||
- DST-PORT,80
|
||||
- SRC-PORT,7777
|
||||
# MATCH 在这里并不是必须的
|
||||
```
|
||||
|
||||
text:
|
||||
|
||||
```txt
|
||||
# comment
|
||||
DOMAIN-SUFFIX,google.com
|
||||
DOMAIN-KEYWORD,google
|
||||
DOMAIN,ad.com
|
||||
SRC-IP-CIDR,192.168.1.201/32
|
||||
IP-CIDR,127.0.0.0/8
|
||||
GEOIP,CN
|
||||
DST-PORT,80
|
||||
SRC-PORT,7777
|
||||
```
|
||||
59
docs/zh_CN/premium/script-shortcuts.md
Normal file
59
docs/zh_CN/premium/script-shortcuts.md
Normal file
@@ -0,0 +1,59 @@
|
||||
---
|
||||
sidebarTitle: "功能: Script Shortcuts 脚本捷径"
|
||||
sidebarOrder: 6
|
||||
---
|
||||
|
||||
# Script Shortcuts 脚本捷径
|
||||
|
||||
Clash Premium 实现了基于 Python3 的脚本功能, 允许用户以动态灵活的方式为数据包选择策略.
|
||||
|
||||
您可以使用单个 Python 脚本控制整个规则匹配引擎, 也可以定义一些 Shortcuts 捷径并将它们与常规规则一起使用. 本页参考后者功能. 有关前者, 请参见 [脚本](./script.md).
|
||||
|
||||
此功能使得在 `rules` 模式下使用脚本成为可能. 默认情况下, DNS 解析将在 SCRIPT 规则中进行. 可以在规则后面添加 `no-resolve` 来阻止解析. (例如: `SCRIPT,quic,DIRECT,no-resolve`)
|
||||
|
||||
```yaml
|
||||
mode: Rule
|
||||
|
||||
script:
|
||||
engine: expr # or starlark (10x to 20x slower)
|
||||
shortcuts:
|
||||
quic: network == 'udp' and dst_port == 443
|
||||
curl: resolve_process_name() == 'curl'
|
||||
# curl: resolve_process_path() == '/usr/bin/curl'
|
||||
|
||||
rules:
|
||||
- SCRIPT,quic,REJECT
|
||||
```
|
||||
|
||||
## 评估引擎
|
||||
|
||||
[Expr](https://expr.medv.io/) 作为 Script Shortcuts 的默认引擎, 相比 Starlark 提供了 10 倍到 20 倍的性能提升.
|
||||
|
||||
[Starlark](https://github.com/google/starlark-go) 是一种类似 Python 的配置语言, 您也可以将其用于 Script Shortcuts.
|
||||
|
||||
## 变量
|
||||
|
||||
- network: string
|
||||
- type: string
|
||||
- src_ip: string
|
||||
- dst_ip: string
|
||||
- src_port: uint16
|
||||
- dst_port: uint16
|
||||
- host: string
|
||||
- process_path: string
|
||||
|
||||
::: warning
|
||||
Starlark 目前不包含 `process_path` 变量.
|
||||
:::
|
||||
|
||||
## 函数
|
||||
|
||||
```ts
|
||||
type resolve_ip = (host: string) => string // ip string
|
||||
type in_cidr = (ip: string, cidr: string) => boolean // ip in cidr
|
||||
type in_ipset = (name: string, ip: string) => boolean // ip in ipset
|
||||
type geoip = (ip: string) => string // country code
|
||||
type match_provider = (name: string) => boolean // in rule provider
|
||||
type resolve_process_name = () => string // find process name (curl .e.g)
|
||||
type resolve_process_path = () => string // find process path (/usr/bin/curl .e.g)
|
||||
```
|
||||
70
docs/zh_CN/premium/script.md
Normal file
70
docs/zh_CN/premium/script.md
Normal file
@@ -0,0 +1,70 @@
|
||||
---
|
||||
sidebarTitle: "功能: Script 脚本"
|
||||
sidebarOrder: 5
|
||||
---
|
||||
|
||||
# Script 脚本
|
||||
|
||||
Clash Premium 实现了基于 Python3 的脚本功能, 使用户能够以动态灵活的方式为数据包选择策略.
|
||||
|
||||
您可以使用单个 Python 脚本控制整个规则匹配引擎, 也可以定义一些快捷方式, 并与常规规则一起使用. 本页介绍了第一种功能, 有关后者, 请参见[Script Shortcuts 脚本捷径](./script-shortcuts.md).
|
||||
|
||||
## 控制整个规则匹配引擎
|
||||
|
||||
```yaml
|
||||
mode: Script
|
||||
|
||||
# https://lancellc.gitbook.io/clash/clash-config-file/script
|
||||
script:
|
||||
code: |
|
||||
def main(ctx, metadata):
|
||||
ip = metadata["dst_ip"] = ctx.resolve_ip(metadata["host"])
|
||||
if ip == "":
|
||||
return "DIRECT"
|
||||
|
||||
code = ctx.geoip(ip)
|
||||
if code == "LAN" or code == "CN":
|
||||
return "DIRECT"
|
||||
|
||||
return "Proxy" # default policy for requests which are not matched by any other script
|
||||
```
|
||||
|
||||
如果您想使用 IP 规则 (即: IP-CIDR、GEOIP 等) , 您首先需要手动解析 IP 地址并将其分配给 metadata:
|
||||
|
||||
```python
|
||||
def main(ctx, metadata):
|
||||
# ctx.rule_providers["geoip"].match(metadata) return false
|
||||
|
||||
ip = ctx.resolve_ip(metadata["host"])
|
||||
if ip == "":
|
||||
return "DIRECT"
|
||||
metadata["dst_ip"] = ip
|
||||
|
||||
# ctx.rule_providers["iprule"].match(metadata) return true
|
||||
|
||||
return "Proxy"
|
||||
```
|
||||
|
||||
Metadata 和 Context 的接口定义:
|
||||
|
||||
```ts
|
||||
interface Metadata {
|
||||
type: string // socks5、http
|
||||
network: string // tcp
|
||||
host: string
|
||||
src_ip: string
|
||||
src_port: string
|
||||
dst_ip: string
|
||||
dst_port: string
|
||||
}
|
||||
|
||||
interface Context {
|
||||
resolve_ip: (host: string) => string // ip string
|
||||
resolve_process_name: (metadata: Metadata) => string
|
||||
resolve_process_path: (metadata: Metadata) => string
|
||||
geoip: (ip: string) => string // country code
|
||||
log: (log: string) => void
|
||||
proxy_providers: Record<string, Array<{ name: string, alive: boolean, delay: number }>>
|
||||
rule_providers: Record<string, { match: (metadata: Metadata) => boolean }>
|
||||
}
|
||||
```
|
||||
13
docs/zh_CN/premium/the-profiling-engine.md
Normal file
13
docs/zh_CN/premium/the-profiling-engine.md
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebarTitle: "功能: 性能分析引擎"
|
||||
sidebarOrder: 8
|
||||
---
|
||||
|
||||
# 性能分析引擎
|
||||
|
||||
https://github.com/Dreamacro/clash-tracing
|
||||
|
||||
```yaml
|
||||
profile:
|
||||
tracing: true
|
||||
```
|
||||
65
docs/zh_CN/premium/tun-device.md
Normal file
65
docs/zh_CN/premium/tun-device.md
Normal file
@@ -0,0 +1,65 @@
|
||||
---
|
||||
sidebarTitle: "功能: TUN 设备"
|
||||
sidebarOrder: 2
|
||||
---
|
||||
|
||||
# TUN 设备
|
||||
|
||||
Premium 内核支持 TUN 设备. 作为网络层设备, 它可以用来处理 TCP、UDP、ICMP 流量. 它已经在生产环境中进行了广泛的测试和使用 - 您甚至可以用它来玩竞技游戏.
|
||||
|
||||
使用 Clash TUN 的最大优势之一是内置支持对操作系统路由表、路由规则和 nftable 的自动管理. 您可以通过选项 `tun.auto-route` 和 `tun.auto-redir` 来启用它. 这个功能替换了古老的配置选项 `redir-port`(TCP), 以方便配置和提高稳定性.
|
||||
|
||||
::: tip
|
||||
`tun.auto-route` 和 `tun.auto-redir` 仅在 macOS、Windows、Linux 和 Android 上可用, 并且仅接收 IPv4 流量.
|
||||
:::
|
||||
|
||||
Clash 有两种可供选择的 TCP/IP 协议栈: `system` or `gvisor`. 为了获得最好的性能, 我们建议您优先使用 `system` 栈, 只有遇到兼容性问题时才使用 `gvisor`. 并且如果你遇到这样的情况, 请立即[提交 Issue](https://github.com/Dreamacro/clash/issues/new/choose).
|
||||
|
||||
## 技术限制
|
||||
|
||||
* 对于 Android, 控制设备位于 `/dev/tun` 而不是 `/dev/net/tun`, 您需要先创建一个软链接 (i.e. `ln -sf /dev/tun /dev/net/tun`)
|
||||
|
||||
* 如果系统 DNS 位于私有 IP 地址上, DNS 劫持可能会失败 (因为 `auto-route` 不会捕获私有网络流量).
|
||||
|
||||
## Linux, macOS 和 Windows
|
||||
|
||||
这是 TUN 功能的示例配置:
|
||||
|
||||
```yaml
|
||||
interface-name: en0 # 与 `tun.auto-detect-interface` 冲突
|
||||
|
||||
tun:
|
||||
enable: true
|
||||
stack: system # or gvisor
|
||||
# dns-hijack:
|
||||
# - 8.8.8.8:53
|
||||
# - tcp://8.8.8.8:53
|
||||
# - any:53
|
||||
# - tcp://any:53
|
||||
auto-route: true # manage `ip route` and `ip rules`
|
||||
auto-redir: true # manage nftable REDIRECT
|
||||
auto-detect-interface: true # 与 `interface-name` 冲突
|
||||
```
|
||||
|
||||
请注意, 由于使用了 TUN 设备和对系统路由表、nftable 的操作, Clash 在此处将需要超级用户权限来运行.
|
||||
|
||||
```shell
|
||||
sudo ./clash
|
||||
```
|
||||
|
||||
如果您的设备已经有一些 TUN 设备, Clash TUN 可能无法工作 - 您必须手动检查路由表和路由规则. 在这种情况下, `fake-ip-filter` 也许也有帮助.
|
||||
|
||||
## Windows
|
||||
|
||||
您需要访问 [WinTUN 网站](https://www.wintun.net) 并下载最新版本. 之后, 将 `wintun.dll` 复制到 Clash 主目录. 示例配置:
|
||||
|
||||
```yaml
|
||||
tun:
|
||||
enable: true
|
||||
stack: gvisor # or system
|
||||
dns-hijack:
|
||||
- 198.18.0.2:53 # 当 `fake-ip-range` 是 198.18.0.1/16, 应该劫持 198.18.0.2:53
|
||||
auto-route: true # 为 Windows 自动设置全局路由
|
||||
# 推荐使用 `interface-name`
|
||||
auto-detect-interface: true # 自动检测接口, 与 `interface-name` 冲突
|
||||
```
|
||||
25
docs/zh_CN/premium/userspace-wireguard.md
Normal file
25
docs/zh_CN/premium/userspace-wireguard.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
sidebarTitle: "功能: 用户空间 Wireguard"
|
||||
sidebarOrder: 7
|
||||
---
|
||||
|
||||
# 用户空间 Wireguard
|
||||
|
||||
由于依赖 gvisor TCP/IP 栈, 用户空间 Wireguard 目前仅在 Premium 内核中可用.
|
||||
|
||||
```yaml
|
||||
proxies:
|
||||
- name: "wg"
|
||||
type: wireguard
|
||||
server: 127.0.0.1
|
||||
port: 443
|
||||
ip: 172.16.0.2
|
||||
# ipv6: your_ipv6
|
||||
private-key: eCtXsJZ27+4PbhDkHnB923tkUn2Gj59wZw5wFA75MnU=
|
||||
public-key: Cr8hWlKvtDt7nrvf+f0brNQQzabAqrjfBvas9pmowjo=
|
||||
# preshared-key: base64
|
||||
# remote-dns-resolve: true # 远程解析 DNS, 使用 `dns` 字段, 默认为 true
|
||||
# dns: [1.1.1.1, 8.8.8.8]
|
||||
# mtu: 1420
|
||||
udp: true
|
||||
```
|
||||
130
docs/zh_CN/runtime/external-controller.md
Normal file
130
docs/zh_CN/runtime/external-controller.md
Normal file
@@ -0,0 +1,130 @@
|
||||
---
|
||||
sidebarTitle: 外部控制设置
|
||||
sidebarOrder: 1
|
||||
---
|
||||
|
||||
# 外部控制设置
|
||||
|
||||
## 简介
|
||||
|
||||
外部控制允许用户通过 HTTP RESTful API 来控制 Clash. 第三方 Clash GUI 就是基于这个功能的. 通过在 `external-controller` 中指定地址来启用这个功能.
|
||||
|
||||
## 认证
|
||||
|
||||
- 外部控制器接受 `Bearer Tokens` 作为访问认证方式.
|
||||
- 使用 `Authorization: Bearer <Your Secret>` 作为请求头来传递凭证.
|
||||
|
||||
## RESTful API 文档
|
||||
|
||||
### 日志
|
||||
|
||||
- `/logs`
|
||||
- 方法: `GET`
|
||||
- 完整路径: `GET /logs`
|
||||
- 描述: 获取实时日志
|
||||
|
||||
### 流量
|
||||
|
||||
- `/traffic`
|
||||
- 方法: `GET`
|
||||
- 完整路径: `GET /traffic`
|
||||
- 描述: 获取实时流量数据
|
||||
|
||||
### 版本
|
||||
|
||||
- `/version`
|
||||
- 方法: `GET`
|
||||
- 完整路径: `GET /version`
|
||||
- 描述: 获取 Clash 版本
|
||||
|
||||
### 配置
|
||||
|
||||
- `/configs`
|
||||
- 方法: `GET`
|
||||
- 完整路径: `GET /configs`
|
||||
- 描述: 获取基础配置
|
||||
|
||||
- 方法: `PUT`
|
||||
- 完整路径: `PUT /configs`
|
||||
- 描述: 重新加载配置文件
|
||||
|
||||
- 方法: `PATCH`
|
||||
- 完整路径: `PATCH /configs`
|
||||
- 描述: 增量修改配置
|
||||
|
||||
### 节点
|
||||
|
||||
- `/proxies`
|
||||
- 方法: `GET`
|
||||
- 完整路径: `GET /proxies`
|
||||
- 描述: 获取所有节点信息
|
||||
|
||||
- `/proxies/:name`
|
||||
- 方法: `GET`
|
||||
- 完整路径: `GET /proxies/:name`
|
||||
- 描述: 获取指定节点信息
|
||||
|
||||
- 方法: `PUT`
|
||||
- 完整路径: `PUT /proxies/:name`
|
||||
- 描述: 切换 Selector 中选中的节点
|
||||
|
||||
- `/proxies/:name/delay`
|
||||
- 方法: `GET`
|
||||
- 完整路径: `GET /proxies/:name/delay`
|
||||
- 描述: 获取指定节点的延迟测试信息
|
||||
|
||||
### 规则
|
||||
|
||||
- `/rules`
|
||||
- 方法: `GET`
|
||||
- 完整路径: `GET /rules`
|
||||
- 描述: 获取规则信息
|
||||
|
||||
### 连接
|
||||
|
||||
- `/connections`
|
||||
- 方法: `GET`
|
||||
- 完整路径: `GET /connections`
|
||||
- 描述: 获取连接信息
|
||||
|
||||
- 方法: `DELETE`
|
||||
- 完整路径: `DELETE /connections`
|
||||
- 描述: 关闭所有连接
|
||||
|
||||
- `/connections/:id`
|
||||
- 方法: `DELETE`
|
||||
- 完整路径: `DELETE /connections/:id`
|
||||
- 描述: 关闭指定连接
|
||||
|
||||
### 代理集
|
||||
|
||||
- `/providers/proxies`
|
||||
- 方法: `GET`
|
||||
- 完整路径: `GET /providers/proxies`
|
||||
- 描述: 获取所有代理集的代理信息
|
||||
|
||||
- `/providers/proxies/:name`
|
||||
- 方法: `GET`
|
||||
- 完整路径: `GET /providers/proxies/:name`
|
||||
- 描述: 获取指定代理集的代理信息
|
||||
|
||||
- 方法: `PUT`
|
||||
- 完整路径: `PUT /providers/proxies/:name`
|
||||
- 描述: 切换指定代理集
|
||||
|
||||
- `/providers/proxies/:name/healthcheck`
|
||||
- 方法: `GET`
|
||||
- 完整路径: `GET /providers/proxies/:name/healthcheck`
|
||||
- 描述: 获取指定代理集的代理信息
|
||||
|
||||
### DNS 查询
|
||||
|
||||
- `/dns/query`
|
||||
- 方法: `GET`
|
||||
- 完整路径: `GET /dns/query?name={name}[&type={type}]`
|
||||
- 描述: 获取指定域名和类型的 DNS 查询数据
|
||||
- 参数:
|
||||
- `name` (必填): 要查询的域名
|
||||
- `type` (可选): 要查询的 DNS 记录类型 (例如, A, MX, CNAME 等). 如果未提供, 则默认为 `A`.
|
||||
|
||||
- 示例: `GET /dns/query?name=example.com&type=A`
|
||||
Reference in New Issue
Block a user