Docs(locales): add chinese locale support (#2772)

This commit is contained in:
a76yyyy
2023-07-14 22:20:15 +08:00
committed by GitHub
parent 24186a488a
commit c7e34bdc11
33 changed files with 2636 additions and 97 deletions

View 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` 作为替代.

View File

@ -0,0 +1,19 @@
---
sidebarTitle: 实验功能
sidebarOrder: 9
---
# 实验功能
偶尔我们会做一些新的功能, 这些功能需要大量的测试才能在主要版本中使用. 这些功能被标记为实验性的, 并且默认是禁用的.
::: warning
这里列出的一些功能可能不稳定, 并且可能在任何未来版本中被删除 - 我们不建议使用它们, 除非您有特定的原因.
:::
## 嗅探 TLS SNI
```yaml
experimental:
sniff-tls-sni: true
```

View 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 二进制文件.

View 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
```

View 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)
```

View 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 }>
}
```

View File

@ -0,0 +1,13 @@
---
sidebarTitle: "功能: 性能分析引擎"
sidebarOrder: 8
---
# 性能分析引擎
https://github.com/Dreamacro/clash-tracing
```yaml
profile:
tracing: true
```

View 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` 冲突
```

View 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
```