Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions docs/config/transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"tcpFastOpen": false,
"tproxy": "off",
"domainStrategy": "AsIs",
"happyEyeballs": {},
"dialerProxy": "",
"acceptProxyProtocol": false,
"tcpKeepAliveInterval": 0,
Expand Down Expand Up @@ -816,3 +817,39 @@ PS: 如果有正常上网的域名流量被 AsIs 的 freedom 出站送过来,
要设置的选项值,此处示例为设置为bbr.

当 type 指定为 int 时需要使用十进制数字。


> `happyEyeballs`: {}

RFC-8305 实现的 happyEyeballs 仅适用于 TCP, 当目标为域名时对它们竞速并选择第一个成功的返回,当 `domainStrategy` 被设置为 `UseIP`/`ForceIP` (包括它们的v4/v6/v4v6版本,但这会使可用的IP列表被缩减到仅剩v4或v6,不推荐这么用)

::: warning
使用这个功能时不要使用 `Freedom` 出站的 `domainStrategy`, 这会导致 `Sockopt` 只能看到被替换完毕的 IP.
:::

```json
"happyEyeballs": {
"tryDelayMs": 250,
"prioritizeIPv6": false,
"interleave": 1,
"maxConcurrentTry": 4,
}
```

> `tryDelayMs`: number

每个竞速请求发起时间的间隔,单位毫秒,默认为0(代表禁用该功能),推荐值为 250.

> `prioritizeIPv6`: bool

排序 IP 时首个 IP 的类型,默认为 false (即 IPv4 会被排在第一个)

> `interleave`: number

RFC-8305 中的 "First Address Family count", 默认值为 1. 它定义了对不同IP版本进行排序时的交错行为。

比如等待 dial 的 IP 队列会被排序为 46464646 (设置为1) 44664466 (设置为2) (6 代表 IPv6 地址, 4 代表 IPv4 地址).

> `maxConcurrentTry`: number

最大并发数量,用于防止解析出的IP过多且均未成功时候核心也对这些IP产生大量连接。默认为4, 设置为0代表禁用 happyEyeballs.
53 changes: 52 additions & 1 deletion docs/en/config/transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Transports specify how to achieve stable data transmission. Both ends of a conne
"tcpFastOpen": false,
"tproxy": "off",
"domainStrategy": "AsIs",
"happyEyeballs": {"tryDelayMs": 250},
"dialerProxy": "",
"acceptProxyProtocol": false,
"tcpKeepAliveInterval": 0,
Expand Down Expand Up @@ -461,6 +462,7 @@ A string array representing the key content, in the format shown in the example.
"tcpFastOpen": false,
"tproxy": "off",
"domainStrategy": "AsIs",
"happyEyeballs": {"tryDelayMs": 250},
"dialerProxy": "",
"acceptProxyProtocol": false,
"tcpKeepAliveInterval": 0,
Expand Down Expand Up @@ -509,14 +511,19 @@ Transparent proxy requires Root or `CAP\_NET\_ADMIN` permission.
When `followRedirect` is set to `true` in [Dokodemo-door](./inbounds/dokodemo.md), and `tproxy` in the Sockopt settings is empty, the value of `tproxy` in the Sockopt settings will be set to `"redirect"`.
:::

> `domainStrategy`: "AsIs" | "UseIP" | "UseIPv4" | "UseIPv6"
> `domainStrategy`: "AsIs"
"UseIP" | "UseIPv6v4" | "UseIPv6" | "UseIPv4v6" | "UseIPv4"
"ForceIP" | "ForceIPv6v4" | "ForceIPv6" | "ForceIPv4v6" | "ForceIPv4"

In previous versions, when Xray attempted to establish a system connection using a domain name, the resolution of the domain name was completed by the system and not controlled by Xray. This led to issues such as the inability to resolve domain names in non-standard Linux environments. To solve this problem, Xray 1.3.1 introduced Freedom's `domainStrategy` into Sockopt.

When the target address is a domain name, the corresponding value is configured, and the behavior of SystemDialer is as follows:

- `"AsIs"`: Resolve the IP address using the system DNS server and connect to the domain name.
- `"UseIP"`, `"UseIPv4"`, and `"UseIPv6"`: Resolve the IP address using the [built-in DNS server](./dns.md) and connect to the IP address directly.
- "IPv4" means that you are trying to connect using only IPv4, "IPv4v6" means that you are trying to connect using either IPv4 or IPv6, but for dual-stack domain names, IPv4 is used. (The same applies to the v4v6 switch, so I won't go into details.)
- When using "Use" the option beginning with , if the resolution result does not meet the requirements (for example, the domain name only has IPv4 resolution results but UseIPv6 is used), it will fall back to AsIs.
- When using "Force" an option beginning with , if the parsing result does not meet the requirements, the connection cannot be established.

The default value is `"AsIs"`.

Expand Down Expand Up @@ -643,3 +650,47 @@ The option name of the operation, using decimal (the example here is that the va
The option value to be set, the example here is set to bbr.

Decimal numbers are required when type is specified as int.


> `happyEyeballs`: {}

only TCP, this is RFC-8305 implementation of happyEyeballs, only apply when built-in-dns is used(domainStrategy is `UseIP`/`ForceIP`).
When we have multiple IPs, this algorithm tries to connect to each IP, the first-stablished-connection is winner connection and selected for sending/receiving data.

::: warning

in `freedom` settings when you set `domainStrategy` to `UseIP`/`ForceIP` just a random IP will replace the domain and `happyEyeballs` does not apply, so for using `happyEyeballs` you should set `sockopt domainStrategy` to `UseIP/ForceIP` not `freedom domainStrategy`.

:::

```json
"happyEyeballs": {
"tryDelayMs": 250,
"prioritizeIPv6": false,
"interleave": 1,
"maxConcurrentTry": 4,
}
```

> `tryDelayMs`: number

delay time between each attempt in millisecond, RFC-8305 recommend `250`, default is `0`.
(if it is `0`, happy-eyeballs is disabled)

> `prioritizeIPv6`: bool

indicate "First Address Family" in RFC-8305, default is false(= prioritizeIPv4)

> `interleave`: number

indicate "First Address Family count" in RFC-8305, default is 1.

for example suppose our IP-list is [ip4-1, ip4-2, ip4-3, ip4-4, ip6-1, ip6-2, ip6-3, ip6-4]
when interleave is 1 and prioritizeIPv6 is false, the sorted-ip-list is:
[ip4-1, ip6-1, ip4-2, ip6-2, ip4-3, ip6-3, ip4-4, ip6-4]
and when for example interleave is 2 and prioritizeIPv6 is true:
[ip6-1, ip6-2, ip4-1, ip4-2, ip6-3, ip6-4, ip4-3, ip4-4]

> `maxConcurrentTry`: number

maximum concurrent attempt (this is only maximum and in most cases our concurrent attempts is less, unless all connection fail to connect) also we can always have a maximum of concurrent-attempt as many IPs as we have, and this option is useful when the number of IPs is too high, and we want to control the number of concurrent-attempts, default is 4. if it is 0, happy-eyeballs is disabled.