Refactor multi networks strategy

This commit is contained in:
世界
2024-11-13 19:05:28 +08:00
parent d1c23bc2da
commit ba454d1693
31 changed files with 495 additions and 336 deletions

View File

@@ -5,7 +5,9 @@ icon: material/new-box
!!! quote "Changes in sing-box 1.11.0"
:material-plus: [network_strategy](#network_strategy)
:material-alert: [fallback_delay](#fallback_delay)
:material-alert: [fallback_delay](#fallback_delay)
:material-alert: [network_type](#network_type)
:material-alert: [fallback_network_type](#fallback_network_type)
### Structure
@@ -23,10 +25,16 @@ icon: material/new-box
"udp_fragment": false,
"domain_strategy": "prefer_ipv6",
"network_strategy": "default",
"network_type": [],
"fallback_network_type": [],
"fallback_delay": "300ms"
}
```
!!! note ""
You can ignore the JSON Array [] tag when the content is only one item
### Fields
#### detour
@@ -101,30 +109,57 @@ If set, the requested domain name will be resolved to IP before connect.
!!! quote ""
Only supported in graphical clients on Android and iOS with `auto_detect_interface` enabled.
Only supported in graphical clients on Android and Apple platforms with `auto_detect_interface` enabled.
Strategy for selecting network interfaces.
Available values:
- `default` (default): Connect to the default interface.
- `fallback`: Try all other interfaces when timeout.
- `hybrid`: Connect to all interfaces concurrently and choose the fastest one.
- `wifi`: Prioritize WIFI, but try all other interfaces when unavailable or timeout.
- `cellular`: Prioritize Cellular, but try all other interfaces when unavailable or timeout.
- `ethernet`: Prioritize Ethernet, but try all other interfaces when unavailable or timeout.
- `wifi_only`: Connect to WIFI only.
- `cellular_only`: Connect to Cellular only.
- `ethernet_only`: Connect to Ethernet only.
- `default` (default): Connect to default network or networks specified in `network_type` sequentially.
- `hybrid`: Connect to all networks or networks specified in `network_type` concurrently.
- `fallback`: Connect to default network or preferred networks specified in `network_type` concurrently, and try fallback networks when unavailable or timeout.
For fallback strategies, when preferred interfaces fails or times out,
it will enter a 15s fast fallback state (upgraded to `hybrid`),
and exit immediately if recovers.
For fallback, when preferred interfaces fails or times out,
it will enter a 15s fast fallback state (Connect to all preferred and fallback networks concurrently),
and exit immediately if preferred networks recover.
Conflicts with `bind_interface`, `inet4_bind_address` and `inet6_bind_address`.
#### network_type
!!! question "Since sing-box 1.11.0"
!!! quote ""
Only supported in graphical clients on Android and Apple platforms with `auto_detect_interface` enabled.
Network types to use when using `default` or `hybrid` network strategy or
preferred network types to use when using `fallback` network strategy.
Available values: `wifi`, `cellular`, `ethernet`, `other`.
Device's default network is used by default.
#### fallback_network_type
!!! question "Since sing-box 1.11.0"
!!! quote ""
Only supported in graphical clients on Android and Apple platforms with `auto_detect_interface` enabled.
Fallback network types when preferred networks are unavailable or timeout when using `fallback` network strategy.
All other networks expect preferred are used by default.
#### fallback_delay
!!! question "Since sing-box 1.11.0"
!!! quote ""
Only supported in graphical clients on Android and Apple platforms with `auto_detect_interface` enabled.
The length of time to wait before spawning a RFC 6555 Fast Fallback connection.
For `domain_strategy`, is the amount of time to wait for connection to succeed before assuming

View File

@@ -5,7 +5,9 @@ icon: material/new-box
!!! quote "sing-box 1.11.0 中的更改"
:material-plus: [network_strategy](#network_strategy)
:material-alert: [fallback_delay](#fallback_delay)
:material-alert: [fallback_delay](#fallback_delay)
:material-alert: [network_type](#network_type)
:material-alert: [fallback_network_type](#fallback_network_type)
### 结构
@@ -23,10 +25,16 @@ icon: material/new-box
"udp_fragment": false,
"domain_strategy": "prefer_ipv6",
"network_strategy": "",
"network_type": [],
"fallback_network_type": [],
"fallback_delay": "300ms"
}
```
!!! note ""
当内容只有一项时,可以忽略 JSON 数组 [] 标签
### 字段
#### detour
@@ -99,26 +107,48 @@ icon: material/new-box
!!! quote ""
仅在 Android 与 iOS 平台图形客户端中支持。
仅在 Android 与 iOS 平台图形客户端中支持,并且需要 `route.auto_detect_interface`
用于选择网络接口的策略。
可用值:
- `default` (默认): 连接默认接口,
- `fallback`: 如果超时,尝试所有剩余接口
- `hybrid`: 同时尝试所有接口,选择最快的一个
- `wifi`: 优先使用 WIFI但在不可用或超时时尝试所有其他接口。
- `cellular`: 优先使用蜂窝数据,但在不可用或超时时尝试所有其他接口。
- `ethernet`: 优先使用以太网,但在不可用或超时时尝试所有其他接口。
- `wifi_only`: 仅连接到 WIFI。
- `cellular_only`: 仅连接到蜂窝数据。
- `ethernet_only`: 仅连接到以太网。
- `default`(默认值):按顺序连接默认网络或 `network_type` 中指定的网络。
- `hybrid`:同时连接所有网络或 `network_type` 中指定的网络
- `fallback`:同时连接默认网络或 `network_type` 中指定的首选网络,当不可用或超时时尝试回退网络
对于回退策略, 当优先使用的接口发生故障或超时时, 将进入 15 秒的快速回退状态(升级为 `hybrid` 且恢复后立即退出。
对于回退模式,当首选接口失败或超时时,
将进入15秒的快速回退状态同时连接所有首选和回退网络
如果首选网络恢复,则立即退出。
`bind_interface`, `bind_inet4_address``bind_inet6_address` 冲突。
#### network_type
!!! question "自 sing-box 1.11.0 起"
!!! quote ""
仅在 Android 与 iOS 平台图形客户端中支持,并且需要 `route.auto_detect_interface`
当使用 `default``hybrid` 网络策略时要使用的网络类型,或当使用 `fallback` 网络策略时要使用的首选网络类型。
可用值:`wifi`, `cellular`, `ethernet`, `other`
默认使用设备默认网络。
#### fallback_network_type
!!! question "自 sing-box 1.11.0 起"
!!! quote ""
仅在 Android 与 iOS 平台图形客户端中支持,并且需要 `route.auto_detect_interface`
当使用 `fallback` 网络策略时,在首选网络不可用或超时的情况下要使用的回退网络类型。
默认使用除首选网络外的所有其他网络。
#### fallback_delay
在生成 RFC 6555 快速回退连接之前等待的时间长度。