From b270b7fc2b639b9282f224d490a720b63bbf0bb6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E3=81=A1=E3=81=8B?=
<88967758+chika0801@users.noreply.github.com>
Date: Tue, 26 Dec 2023 12:28:27 +0800
Subject: [PATCH] Add explanation for domainStrategy in freedom (#440)
* Add explanation for domainStrategy in freedom
* Update freedom.md
* Update freedom.md
---
docs/config/outbounds/freedom.md | 63 ++++++++++++++++++++++++++++++--
1 file changed, 59 insertions(+), 4 deletions(-)
diff --git a/docs/config/outbounds/freedom.md b/docs/config/outbounds/freedom.md
index 80556dc6e..543b9e541 100644
--- a/docs/config/outbounds/freedom.md
+++ b/docs/config/outbounds/freedom.md
@@ -17,13 +17,20 @@ Freedom 是一个出站协议,可以用来向任意网络发送(正常的)
}
```
-> `domainStrategy`: "AsIs" | "UseIP" | "UseIPv4" | "UseIPv6"
+> `domainStrategy`: "AsIs"
+> "UseIP" | "UseIPv6v4" | "UseIPv6" | "UseIPv4v6" | "UseIPv4"
+> "ForceIP" | "ForceIPv6v4" | "ForceIPv6" | "ForceIPv4v6" | "ForceIPv4"
+
+Xray-core v1.8.6 新增功能:
+`"UseIPv6v4"` | `"UseIPv4v6"`
+`"ForceIP"` | `"ForceIPv6v4"` | `"ForceIPv6"` | `"ForceIPv4v6"` | `"ForceIPv4"`
+
+若不写此参数,或留空,默认值 `"AsIs"`。
在目标地址为域名时, 配置相应的值, Freedom 的行为模式如下:
-- `"AsIs"`: Freedom 通过系统 DNS 服务器解析获取 IP, 向此域名发出连接.
-- `"UseIP"`、`"UseIPv4"` 和 `"UseIPv6"`: Xray 使用 [内置 DNS 服务器](../dns.md) 解析获取 IP, 向此域名发出连接.
- 默认值为 `"AsIs"`。
+- `"AsIs"`: Freedom 通过系统 DNS 服务器解析获取 IP, 向此域名发出连接。
+- `"UseIP"`、`"UseIPv4"` 和 `"UseIPv6"`: Xray 使用 [内置 DNS 服务器](../dns.md) 解析获取 IP, 向此域名发出连接。
::: tip TIP 1
当使用 `"UseIP"` 模式,并且 [出站连接配置](../outbound.md#outboundobject) 中指定了 `sendThrough` 时,Freedom 会根据 `sendThrough` 的值自动判断所需的 IP 类型,IPv4 或 IPv6。
@@ -33,6 +40,54 @@ Freedom 是一个出站协议,可以用来向任意网络发送(正常的)
当使用 `"UseIPv4"` 或 `"UseIPv6"` 模式时,Freedom 会只使用对应的 IPv4 或 IPv6 地址。当 `sendThrough` 指定了不匹配的本地地址时,将导致连接失败。
:::
+::: tip TIP 3
+`UseIP` 和 `ForceIP` 的区别是,前者解析失败了会走 AsIs,后者解析失败了会被 block。这样整个 `domainStrategy` 都更加灵活了。
+:::
+
+```jsonc
+ "dns": {
+ "servers": [
+ "https://1.1.1.1/dns-query"
+ ],
+ "queryStrategy": "UseIP" // 默认值 UseIP
+ }
+```
+
+- UseIP 同时查询 A 和 AAAA 记录
+- UseIPv4 只查询 A 记录
+- UseIPv6 只查询 AAAA 记录
+
+```jsonc
+ {
+ "protocol": "freedom",
+ "settings": {
+ "domainStrategy": "AsIs" // 默认值 AsIs
+ }
+ }
+```
+
+| | UseIP | UseIPv6v4 | UseIPv6 | UseIPv4v6 | UseIPv4 |
+| :--- | :---: | :---: | :---: | :---: | :---: |
+| `"queryStrategy": "UseIP"` | **1** | **2** | IPv6 | **3** | IPv4 |
+| `"queryStrategy": "UseIPv4"` | IPv4 | **4** | **5** | **6** | IPv4 |
+| `"queryStrategy": "UseIPv6"` | IPv6 | **7** | IPv6 | **8** | **9** |
+
+| | ForceIP | ForceIPv6v4 | ForceIPv6 | ForceIPv4v6 | ForceIPv4 |
+| :--- | :---: | :---: | :---: | :---: | :---: |
+| `"queryStrategy": "UseIP"` | **1** | **2** | IPv6 | **3** | IPv4 |
+| `"queryStrategy": "UseIPv4"` | IPv4 | IPv4 | 冲突 | IPv4 | IPv4 |
+| `"queryStrategy": "UseIPv6"` | IPv6 | IPv6 | IPv6 | IPv6 | 冲突 |
+
+**1:** IPv4 IPv6 地址,随机优先
+**2:** IPv4 IPv6 地址,IPv6 优先
+**3:** IPv4 IPv6 地址,IPv4 优先
+**4:** IPv4 IPv6 地址,IPv6 优先,IPv6 地址由系统 DNS 查询
+**5:** IPv6 地址,IPv6 地址由系统 DNS 查询
+**6:** IPv4 IPv6 地址,IPv4 优先,IPv6 地址由系统 DNS 查询
+**7:** IPv4 IPv6 地址,IPv6 优先,IPv4 地址由系统 DNS 查询
+**8:** IPv4 IPv6 地址,IPv4 优先,IPv4 地址由系统 DNS 查询
+**9:** IPv4 地址,IPv4 地址由系统 DNS 查询
+
> `redirect`: address_port
Freedom 会强制将所有数据发送到指定地址(而不是 inbound 指定的地址)。