From 03f457f3d0f964671668ffedf670bc74289e242b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 24 Aug 2022 16:23:21 +0800 Subject: [PATCH] Initial zh-CN document translation: DNS --- .github/ISSUE_TEMPLATE/bug_report.yml | 21 ++- docs/configuration/dns/index.zh.md | 44 +++++ docs/configuration/dns/rule.md | 6 +- docs/configuration/dns/rule.zh.md | 243 +++++++++++++++++++++++++ docs/configuration/dns/server.md | 3 +- docs/configuration/dns/server.zh.md | 91 +++++++++ docs/configuration/experimental.md | 2 +- docs/configuration/experimental.zh.md | 37 ++++ docs/configuration/inbound/direct.md | 2 + docs/configuration/inbound/hysteria.md | 2 + docs/configuration/index.zh.md | 39 ++++ docs/configuration/log.zh.md | 31 ++++ docs/configuration/route/index.md | 2 +- docs/configuration/route/index.zh.md | 59 ++++++ docs/faq/index.zh.md | 4 +- docs/index.zh.md | 18 +- 16 files changed, 585 insertions(+), 19 deletions(-) create mode 100644 docs/configuration/dns/index.zh.md create mode 100644 docs/configuration/dns/rule.zh.md create mode 100644 docs/configuration/dns/server.zh.md create mode 100644 docs/configuration/experimental.zh.md create mode 100644 docs/configuration/index.zh.md create mode 100644 docs/configuration/log.zh.md create mode 100644 docs/configuration/route/index.zh.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 2d9d2489..a0e16c3a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -9,9 +9,11 @@ body: options: - label: Yes, I'm using the latest major release. Only such installations are supported. required: true + - label: Yes, I'm using the latest Golang release. Only such installations are supported. + required: true - label: Yes, I've searched similar issues on GitHub and didn't find any. required: true - - label: Yes, I've included all information below (version, config, etc). + - label: Yes, I've included all information below (version, config, log, etc). required: true - type: textarea @@ -51,4 +53,19 @@ body: validations: - required: true \ No newline at end of file + required: true + + - type: textarea + id: config + attributes: + label: Server and client log file + value: |- +
+ + ```console + # paste log here + ``` + +
+ validations: + required: true diff --git a/docs/configuration/dns/index.zh.md b/docs/configuration/dns/index.zh.md new file mode 100644 index 00000000..2b3d0db4 --- /dev/null +++ b/docs/configuration/dns/index.zh.md @@ -0,0 +1,44 @@ +### 结构 + +```json +{ + "dns": { + "servers": [], + "rules": [], + "final": "", + "strategy": "", + "disable_cache": false, + "disable_expire": false + } +} + +``` + +### 字段 + +| 键 | 格式 | +|----------|------------------------| +| `server` | 一组 [DNS 服务器](./server) | +| `rules` | 一组 [DNS 规则](./rule) | + +#### final + +默认 DNS 服务器的标签。 + +将使用第一个服务器,如果为空。 + +#### strategy + +默认解析域名策略。 + +可选值: `prefer_ipv4` `prefer_ipv6` `ipv4_only` `ipv6_only`。 + +如果设置了 `server.strategy`,则不生效。 + +#### disable_cache + +禁用 DNS 缓存。 + +#### disable_expire + +禁用 DNS 缓存过期。 \ No newline at end of file diff --git a/docs/configuration/dns/rule.md b/docs/configuration/dns/rule.md index 91cb669b..2a3a7ff0 100644 --- a/docs/configuration/dns/rule.md +++ b/docs/configuration/dns/rule.md @@ -104,11 +104,11 @@ #### inbound -Tags of [inbound](../inbound). +Tags of [Inbound](/configuration/inbound). #### ip_version -4 (A query) or 6 (AAAA dns query). +4 (A DNS query) or 6 (AAAA DNS query). Not limited if empty. @@ -116,7 +116,7 @@ Not limited if empty. `tcp` or `udp`. -#### user +#### auth_user Username, see each inbound for details. diff --git a/docs/configuration/dns/rule.zh.md b/docs/configuration/dns/rule.zh.md new file mode 100644 index 00000000..70a5d401 --- /dev/null +++ b/docs/configuration/dns/rule.zh.md @@ -0,0 +1,243 @@ +### 结构 + +```json +{ + "dns": { + "rules": [ + { + "inbound": [ + "mixed-in" + ], + "ip_version": 6, + "network": "tcp", + "auth_user": [ + "usera", + "userb" + ], + "protocol": [ + "tls", + "http", + "quic" + ], + "domain": [ + "test.com" + ], + "domain_suffix": [ + ".cn" + ], + "domain_keyword": [ + "test" + ], + "domain_regex": [ + "^stun\\..+" + ], + "geosite": [ + "cn" + ], + "source_geoip": [ + "private" + ], + "source_ip_cidr": [ + "10.0.0.0/24" + ], + "source_port": [ + 12345 + ], + "source_port_range": [ + "1000:2000", + ":3000", + "4000:" + ], + "port": [ + 80, + 443 + ], + "port_range": [ + "1000:2000", + ":3000", + "4000:" + ], + "process_name": [ + "curl" + ], + "package_name": [ + "com.termux" + ], + "user": [ + "sekai" + ], + "user_id": [ + 1000 + ], + "invert": false, + "outbound": [ + "direct" + ], + "server": "local", + "disable_cache": false + }, + { + "type": "logical", + "mode": "and", + "rules": [], + "server": "local", + "disable_cache": false + } + ] + } +} + +``` + +!!! note "" + + 当内容只有一项时,可以忽略 JSON 数组 [] 标签 + +### 默认字段 + +!!! note "" + + 默认规则使用以下匹配逻辑: + (`domain` || `domain_suffix` || `domain_keyword` || `domain_regex` || `geosite`) && + (`source_geoip` || `source_ip_cidr`) && + `other fields` + +#### inbound + +[入站](/zh/configuration/inbound) 标签. + +#### ip_version + +4 (A DNS 查询) 或 6 (AAAA DNS 查询)。 + +留空不限制。 + +#### network + +`tcp` 或 `udp`。 + +#### auth_user + +认证用户名,参阅入站设置。 + +#### protocol + +探测到的协议, 参阅 [协议探测](/zh/configuration/route/sniff/)。 + +#### domain + +匹配完整域名。Match user name. + +#### domain_suffix + +匹配域名后缀。 + +#### domain_keyword + +匹配域名关键字。 + +#### domain_regex + +匹配域名正则表达式。 + +#### geosite + +匹配 GeoSite. + +#### source_geoip + +匹配源 GeoIP。 + +#### source_ip_cidr + +匹配源 IP CIDR。 + +#### source_port + +匹配源端口。 + +#### source_port_range + +匹配源端口范围。 + +#### port + +匹配端口。 + +#### port_range + +匹配端口范围。 + +#### process_name + +!!! error "" + + 仅支持 Linux, Windows, 和 macOS. + +匹配进程名称。 + +#### package_name + +匹配 Android 应用包名。 + +#### user + +!!! error "" + + 仅支持 Linux. + +匹配用户名。 + +#### user_id + +!!! error "" + + 仅支持 Linux. + +匹配用户 ID。 + +#### invert + +反选匹配结果。 + +#### outbound + +匹配出站。 + +#### server + +==必须== + +目标 DNS 服务器的标签。 + +#### disable_cache + +在此查询中禁用缓存 + +### 逻辑字段 + +#### type + +`logical` + +#### mode + +`and` 或 `or` + +#### rules + +包括的默认规则。 + +#### invert + +反选匹配结果。 + +#### server + +==必须== + +目标 DNS 服务器的标签。 + +#### disable_cache + +在此查询中禁用缓存。 \ No newline at end of file diff --git a/docs/configuration/dns/server.md b/docs/configuration/dns/server.md index 4861d2f4..a4d2bbbe 100644 --- a/docs/configuration/dns/server.md +++ b/docs/configuration/dns/server.md @@ -43,7 +43,7 @@ The address of the dns server. !!! warning "" - To ensure that system DNS is in effect, rather than go's built-in default resolver, enable CGO at compile time. + To ensure that system DNS is in effect, rather than Go's built-in default resolver, enable CGO at compile time. !!! warning "" @@ -60,6 +60,7 @@ The address of the dns server. | `server_failure` | `Server failure` | | `name_error` | `Non-existent domain` | | `not_implemented` | `Not implemented` | +| `refused` | `Query refused` | #### address_resolver diff --git a/docs/configuration/dns/server.zh.md b/docs/configuration/dns/server.zh.md new file mode 100644 index 00000000..accb516a --- /dev/null +++ b/docs/configuration/dns/server.zh.md @@ -0,0 +1,91 @@ +### 结构 + +```json +{ + "dns": { + "servers": [ + { + "tag": "google", + "address": "tls://dns.google", + "address_resolver": "local", + "address_strategy": "prefer_ipv4", + "strategy": "ipv4_only", + "detour": "direct" + } + ] + } +} + +``` + +### 字段 + +#### tag + +DNS 服务器的标签。 + +#### address + +==必须== + +DNS 服务器的地址。 + +| 协议 | 格式 | +|----------|-----------------------------| +| `System` | `local` | +| `TCP` | `tcp://1.0.0.1` | +| `UDP` | `8.8.8.8` `udp://8.8.4.4` | +| `TLS` | `tls://dns.google` | +| `HTTPS` | `https://1.1.1.1/dns-query` | +| `QUIC` | `quic://dns.adguard.com` | +| `HTTP3` | `h3://8.8.8.8/dns-query` | +| `RCode` | `rcode://refused` | + +!!! warning "" + + 为了确保系统 DNS 生效,而不是 Go 的内置默认解析器,请在编译时启用 CGO。 + +!!! warning "" + + 默认安装下包括 QUIC 和 HTTP3 传输层,请参阅 [安装](/zh/#installation)。 + +!!! info "" + + RCode 传输层传输层常用于屏蔽请求. 与 DNS 规则和 `disable_cache` 规则选项一起使用. + +| RCode | 描述 | +|-------------------|----------| +| `success` | `无错误` | +| `format_error` | `请求格式错误` | +| `server_failure` | `服务器出错` | +| `name_error` | `域名不存在` | +| `not_implemented` | `功能未实现` | +| `refused` | `请求被拒绝` | + +#### address_resolver + +==如果服务器地址包括域名则必须== + +用于解析本 DNS 服务器的域名的另一个 DNS 服务器的标签。 + +#### address_strategy + +用于解析本 DNS 服务器的域名的策略。 + +可选项:`prefer_ipv4` `prefer_ipv6` `ipv4_only` `ipv6_only`. + +如果为空,则使用 `dns.strategy`. + +#### strategy + +默认解析策略。 + +可选项:`prefer_ipv4` `prefer_ipv6` `ipv4_only` `ipv6_only`. + +如果被其他设置覆盖则不生效。 + +#### detour + +用于连接到 DNS 服务器的出站的标签。 + +如果为空,则使用默认出站。 diff --git a/docs/configuration/experimental.md b/docs/configuration/experimental.md index ec9a3e09..8a369322 100644 --- a/docs/configuration/experimental.md +++ b/docs/configuration/experimental.md @@ -29,7 +29,7 @@ RESTful web API listening address. Disabled if empty. #### external_ui A relative path to the configuration directory or an absolute path to a -directory in which you put some static web resource. Clash core will then +directory in which you put some static web resource. sing-box will then serve it at `http://{{external-controller}}/ui`. #### secret diff --git a/docs/configuration/experimental.zh.md b/docs/configuration/experimental.zh.md new file mode 100644 index 00000000..b5399c9e --- /dev/null +++ b/docs/configuration/experimental.zh.md @@ -0,0 +1,37 @@ +### 结构 + +```json +{ + "experimental": { + "clash_api": { + "external_controller": "127.0.0.1:9090", + "external_ui": "folder", + "secret": "" + } + } +} +``` + +### Clash API 字段 + +!!! error "" + + 默认安装不包含 Clash API, 参阅 [安装](/zh/#installation). + +!!! note "" + + 流量统计和连接管理将禁用 Linux 中的 TCP splice 并降低性能,使用风险自负。 + +#### external_controller + +RESTful web API 监听地址。 如果为空则禁用。 + +#### external_ui + +到静态网页资源目录的相对路径或绝对路径。 sing-box 会在 `http://{{external-controller}}/ui` 下提供它。 + +#### secret + +RESTful API 的密钥(可选) +通过指定 HTTP 标头 `Authorization: Bearer ${secret}` 进行身份验证 +如果 RESTful API 正在监听 0.0.0.0,始终设置一个密钥。 \ No newline at end of file diff --git a/docs/configuration/inbound/direct.md b/docs/configuration/inbound/direct.md index edfc4c09..0ce9fab3 100644 --- a/docs/configuration/inbound/direct.md +++ b/docs/configuration/inbound/direct.md @@ -8,6 +8,7 @@ { "type": "direct", "tag": "direct-in", + "listen": "::", "listen_port": 5353, "tcp_fast_open": false, @@ -17,6 +18,7 @@ "udp_timeout": 300, "network": "udp", "proxy_protocol": false, + "override_address": "1.0.0.1", "override_port": 53 } diff --git a/docs/configuration/inbound/hysteria.md b/docs/configuration/inbound/hysteria.md index 782d8d83..c337c8ba 100644 --- a/docs/configuration/inbound/hysteria.md +++ b/docs/configuration/inbound/hysteria.md @@ -6,11 +6,13 @@ { "type": "hysteria", "tag": "hysteria-in", + "listen": "::", "listen_port": 443, "sniff": false, "sniff_override_destination": false, "domain_strategy": "prefer_ipv6", + "up": "100 Mbps", "up_mbps": 100, "down": "100 Mbps", diff --git a/docs/configuration/index.zh.md b/docs/configuration/index.zh.md new file mode 100644 index 00000000..b5c3db6e --- /dev/null +++ b/docs/configuration/index.zh.md @@ -0,0 +1,39 @@ +# 引言 + +sing-box 使用 JSON 作为配置文件格式. + +### 结构 + +```json +{ + "log": {}, + "dns": {}, + "inbounds": {}, + "outbounds": {}, + "route": {}, + "experimental": {} +} +``` + +### 字段 + +| Key | Format | +|----------------|-----------------------| +| `log` | [日志](./log) | +| `dns` | [DNS](./dns) | +| `inbounds` | [入站](./inbound) | +| `outbounds` | [出站](./outbound) | +| `route` | [路由](./route) | +| `experimental` | [实验性](./experimental) | + +### 检查 + +```bash +$ sing-box check +``` + +### 格式化 + +```bash +$ sing-box format -w +``` \ No newline at end of file diff --git a/docs/configuration/log.zh.md b/docs/configuration/log.zh.md new file mode 100644 index 00000000..fc623b04 --- /dev/null +++ b/docs/configuration/log.zh.md @@ -0,0 +1,31 @@ +### 结构 + +```json +{ + "log": { + "disabled": false, + "level": "info", + "output": "box.log", + "timestamp": false + } +} + +``` + +### 字段 + +#### disabled + +禁用日志,启动后不输出日志。 + +#### level + +日志等级,可选值:`trace` `debug` `info` `warn` `error` `fatal` `panic`. + +#### output + +输出文件路径,启动后将不输出到控制台。 + +#### timestamp + +添加时间到每行。 \ No newline at end of file diff --git a/docs/configuration/route/index.md b/docs/configuration/route/index.md index ebdd638a..7593fe8d 100644 --- a/docs/configuration/route/index.md +++ b/docs/configuration/route/index.md @@ -52,6 +52,6 @@ Takes no effect if `auto_detect_interface` is set. Only supported on Linux. -Set iptables routing mark by default. +Set routing mark by default. Takes no effect if `outbound.routing_mark` is set. \ No newline at end of file diff --git a/docs/configuration/route/index.zh.md b/docs/configuration/route/index.zh.md new file mode 100644 index 00000000..3b19d938 --- /dev/null +++ b/docs/configuration/route/index.zh.md @@ -0,0 +1,59 @@ +# 路由 + +### 结构 + +```json +{ + "route": { + "geoip": {}, + "geosite": {}, + "rules": [], + "final": "", + "auto_detect_interface": false, + "default_interface": "en0", + "default_mark": 233 + } +} +``` + +### Fields + +| 键 | 格式 | +|-----------|----------------------| +| `geoip` | [GeoIP](./geoip) | +| `geosite` | [GeoSite](./geosite) | +| `rules` | 一组 [路由规则](./rule) | + +#### final + +默认出站标签。如果未空,将使用第一个可用于对应协议的出站。 + +#### auto_detect_interface + +!!! error "" + + 仅支持 Linux, Windows, 和 macOS. + +默认将出站连接绑定到默认网卡,以防止在 Tun 下出现路由环路。 + +如果设置了 `outbound.bind_interface` 设置,则不生效。 + +#### default_interface + +!!! error "" + + 仅支持 Linux, Windows, 和 macOS. + +默认将出站连接绑定到指定网卡,以防止在 Tun 下出现路由环路。 + +如果设置了 `auto_detect_interface` 设置,则不生效。 + +#### default_mark + +!!! error "" + + 仅支持 Linux. + +默认为出站连接设置路由标记。 + +如果设置了 `outbound.routing_mark` 设置,则不生效。 diff --git a/docs/faq/index.zh.md b/docs/faq/index.zh.md index 0116030a..24e0dc35 100644 --- a/docs/faq/index.zh.md +++ b/docs/faq/index.zh.md @@ -11,12 +11,12 @@ #### Fake IP -Fake IP(也称 Fake DNS)是一种侵入性和不完善的DNS解决方案,它打破了预期的行为,导致DNS泄漏并使许多软件无法使用。 +Fake IP(也称 Fake DNS)是一种侵入性和不完善的 DNS 解决方案,它打破了预期的行为,导致 DNS 泄漏并使许多软件无法使用。 一些缺乏 DNS 处理和缓存的软件推荐使用它,但 sing-box 不需要。 #### Naive 出站 -NaïveProxy's 的主要功能是 chromium 的网络栈,仅实现它的传输协议是舍本逐末的。 +NaïveProxy 的主要功能是 chromium 的网络栈,仅实现它的传输协议是舍本逐末的。 #### 协议组合 diff --git a/docs/index.zh.md b/docs/index.zh.md index 48492450..7fd3d1ca 100644 --- a/docs/index.zh.md +++ b/docs/index.zh.md @@ -20,14 +20,14 @@ go install -v -tags with_clash_api github.com/sagernet/sing-box/cmd/sing-box@lat | 构建标志 | 描述 | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `with_quic` | 启用 QUIC 支持, 查看 [QUIC 和 HTTP3 DNS 传输层](./configuration/dns/server), [Naive 入站](./configuration/inbound/naive), [Hysteria 入站](./configuration/inbound/hysteria) 和 [Hysteria 出站](./configuration/outbound/hysteria). | -| `with_grpc` | 启用 gRPC 之后, 查看 [V2Ray 传输层#gRPC](/configuration/shared/v2ray-transport#grpc). | -| `with_wireguard` | 启用 WireGuard 支持, 查看 [WireGuard 出站](./configuration/outbound/wireguard). | -| `with_acme` | 启用 ACME TLS 证书签发支持, 查看 [TLS](./configuration/shared/tls). | -| `with_clash_api` | 启用 Clash api 支持, 查看 [实验性](./configuration/experimental#clash-api-fields). | -| `no_gvisor` | 禁用 gVisor Tun 栈支持, 查看 [Tun 入站](./configuration/inbound/tun#stack). | -| `with_embedded_tor` (需要 CGO) | 启用 嵌入式 Tor 支持, 查看 [Tor 出站](./configuration/outbound/tor). | -| `with_lwip` (需要 CGO) | 启用 LWIP Tun 栈支持, 查看 [Tun 入站](./configuration/inbound/tun#stack). | +| `with_quic` | 启用 QUIC 支持, 参阅 [QUIC 和 HTTP3 DNS 传输层](./configuration/dns/server), [Naive 入站](./configuration/inbound/naive), [Hysteria 入站](./configuration/inbound/hysteria) 和 [Hysteria 出站](./configuration/outbound/hysteria). | +| `with_grpc` | 启用 gRPC 之后, 参阅 [V2Ray 传输层#gRPC](/configuration/shared/v2ray-transport#grpc). | +| `with_wireguard` | 启用 WireGuard 支持, 参阅 [WireGuard 出站](./configuration/outbound/wireguard). | +| `with_acme` | 启用 ACME TLS 证书签发支持, 参阅 [TLS](./configuration/shared/tls). | +| `with_clash_api` | 启用 Clash api 支持, 参阅 [实验性](./configuration/experimental#clash-api-fields). | +| `no_gvisor` | 禁用 gVisor Tun 栈支持, 参阅 [Tun 入站](./configuration/inbound/tun#stack). | +| `with_embedded_tor` (需要 CGO) | 启用 嵌入式 Tor 支持, 参阅 [Tor 出站](./configuration/outbound/tor). | +| `with_lwip` (需要 CGO) | 启用 LWIP Tun 栈支持, 参阅 [Tun 入站](./configuration/inbound/tun#stack). | 二进制文件将被构建在 `$GOPATH/bin` 下 @@ -36,7 +36,7 @@ sing-box version ``` 同时推荐使用 Systemd 来管理 sing-box 服务器实例. -查看 [Linux 服务器安装示例](./examples/linux-server-installation). +参阅 [Linux 服务器安装示例](./examples/linux-server-installation). ## 贡献者