From eb0106ff80d07329db2297aacb02128d87841d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 13 Nov 2024 21:42:00 +0800 Subject: [PATCH] documentation: Refactor multi networks strategy --- docs/configuration/route/index.md | 37 ++++++++----- docs/configuration/route/index.zh.md | 39 ++++++++++---- docs/configuration/route/rule_action.md | 24 +++++---- docs/configuration/route/rule_action.zh.md | 24 +++++---- docs/configuration/shared/dial.md | 63 +++++++++++++++++----- docs/configuration/shared/dial.zh.md | 54 ++++++++++++++----- 6 files changed, 172 insertions(+), 69 deletions(-) diff --git a/docs/configuration/route/index.md b/docs/configuration/route/index.md index 2b035eb4..58f73352 100644 --- a/docs/configuration/route/index.md +++ b/docs/configuration/route/index.md @@ -7,6 +7,8 @@ icon: material/new-box !!! quote "Changes in sing-box 1.11.0" :material-plus: [default_network_strategy](#default_network_strategy) + :material-plus: [default_network_type](#default_network_type) + :material-plus: [default_fallback_network_type](#default_fallback_network_type) :material-alert: [default_fallback_delay](#default_fallback_delay) !!! quote "Changes in sing-box 1.8.0" @@ -30,17 +32,18 @@ icon: material/new-box "default_interface": "", "default_mark": 0, "default_network_strategy": "", + "default_network_type": [], + "default_fallback_network_type": [], "default_fallback_delay": "" } } ``` -### Fields +!!! note "" -| Key | Format | -|-----------|-----------------------| -| `geoip` | [GeoIP](./geoip/) | -| `geosite` | [Geosite](./geosite/) | + You can ignore the JSON Array [] tag when the content is only one item + +### Fields #### rules @@ -96,11 +99,9 @@ Takes no effect if `outbound.routing_mark` is set. #### default_network_strategy -!!! quote "" +!!! question "Since sing-box 1.11.0" - Only supported in graphical clients on Android and iOS with `auto_detect_interface` enabled. - -Strategy for selecting network interfaces. +See [Dial Fields](/configuration/shared/dial/#network_strategy) for details. Takes no effect if `outbound.bind_interface`, `outbound.inet4_bind_address` or `outbound.inet6_bind_address` is set. @@ -108,12 +109,20 @@ Can be overrides by `outbound.network_strategy`. Conflicts with `default_interface`. -See [Dial Fields](/configuration/shared/dial/#network_strategy) for available values. +#### default_network_type + +!!! question "Since sing-box 1.11.0" + +See [Dial Fields](/configuration/shared/dial/#network_type) for details. + +#### default_fallback_network_type + +!!! question "Since sing-box 1.11.0" + +See [Dial Fields](/configuration/shared/dial/#fallback_network_type) for details. #### default_fallback_delay -!!! quote "" +!!! question "Since sing-box 1.11.0" - Only supported in graphical clients on Android and iOS with `auto_detect_interface` enabled and `network_strategy` set. - -See [Dial Fields](/configuration/shared/dial/#fallback_delay) for details. \ No newline at end of file +See [Dial Fields](/configuration/shared/dial/#fallback_delay) for details. diff --git a/docs/configuration/route/index.zh.md b/docs/configuration/route/index.zh.md index b00237c4..9550b4ac 100644 --- a/docs/configuration/route/index.zh.md +++ b/docs/configuration/route/index.zh.md @@ -1,5 +1,16 @@ +--- +icon: material/new-box +--- + # 路由 +!!! quote "sing-box 1.11.0 中的更改" + + :material-plus: [network_strategy](#network_strategy) + :material-plus: [default_network_type](#default_network_type) + :material-plus: [default_fallback_network_type](#default_fallback_network_type) + :material-alert: [default_fallback_delay](#default_fallback_delay) + !!! quote "sing-box 1.8.0 中的更改" :material-plus: [rule_set](#rule_set) @@ -26,6 +37,10 @@ } ``` +!!! note "" + + 当内容只有一项时,可以忽略 JSON 数组 [] 标签 + ### 字段 | 键 | 格式 | @@ -87,11 +102,9 @@ #### network_strategy -!!! quote "" +!!! question "自 sing-box 1.11.0 起" - 仅在 Android 与 Apple 平台图形客户端中支持,并且需要 `auto_detect_interface`。 - -选择网络接口的策略。 +详情参阅 [拨号字段](/configuration/shared/dial/#network_strategy)。 当 `outbound.bind_interface`, `outbound.inet4_bind_address` 或 `outbound.inet6_bind_address` 已设置时不生效。 @@ -99,12 +112,20 @@ 与 `default_interface` 冲突。 -可用值请参阅 [拨号字段](/configuration/shared/dial/#network_strategy)。 +#### default_network_type -#### fallback_delay +!!! question "自 sing-box 1.11.0 起" -!!! quote "" +详情参阅 [拨号字段](/configuration/shared/dial/#default_network_type)。 - 仅在 Android 与 Apple 平台图形客户端中支持,并且需要 `auto_detect_interface` 且 `network_strategy` 已设置。 +#### default_fallback_network_type -详情请参阅 [拨号字段](/configuration/shared/dial/#fallback_delay)。 +!!! question "自 sing-box 1.11.0 起" + +详情参阅 [拨号字段](/configuration/shared/dial/#default_fallback_network_type)。 + +#### default_fallback_delay + +!!! question "自 sing-box 1.11.0 起" + +详情参阅 [拨号字段](/configuration/shared/dial/#fallback_delay)。 diff --git a/docs/configuration/route/rule_action.md b/docs/configuration/route/rule_action.md index 5e9cfbc2..6462c848 100644 --- a/docs/configuration/route/rule_action.md +++ b/docs/configuration/route/rule_action.md @@ -11,12 +11,18 @@ icon: material/new-box "action": "route", // default "outbound": "", "network_strategy": "", + "network_type": [], + "fallback_network_type": [], "fallback_delay": "", "udp_disable_domain_unmapping": false, "udp_connect": false } ``` +!!! note "" + + You can ignore the JSON Array [] tag when the content is only one item + `route` inherits the classic rule behavior of routing connection to the specified outbound. #### outbound @@ -27,23 +33,21 @@ Tag of target outbound. #### network_strategy -!!! quote "" - - Only supported in graphical clients on Android and iOS with `auto_detect_interface` enabled. - -Strategy for selecting network interfaces. +See [Dial Fields](/configuration/shared/dial/#network_strategy) for details. Only take effect if outbound is direct without `outbound.bind_interface`, `outbound.inet4_bind_address` and `outbound.inet6_bind_address` set. -See [Dial Fields](/configuration/shared/dial/#network_strategy) for available values. +#### network_type + +See [Dial Fields](/configuration/shared/dial/#network_type) for details. + +#### fallback_network_type + +See [Dial Fields](/configuration/shared/dial/#fallback_network_type) for details. #### fallback_delay -!!! quote "" - - Only supported in graphical clients on Android and iOS with `auto_detect_interface` enabled and `network_strategy` set. - See [Dial Fields](/configuration/shared/dial/#fallback_delay) for details. #### udp_disable_domain_unmapping diff --git a/docs/configuration/route/rule_action.zh.md b/docs/configuration/route/rule_action.zh.md index 52965fd2..acadb66d 100644 --- a/docs/configuration/route/rule_action.zh.md +++ b/docs/configuration/route/rule_action.zh.md @@ -12,6 +12,8 @@ icon: material/new-box "outbound": "", "network_strategy": "", "fallback_delay": "", + "network_type": [], + "fallback_network_type": [], "udp_disable_domain_unmapping": false, "udp_connect": false } @@ -27,23 +29,21 @@ icon: material/new-box #### network_strategy -!!! quote "" - - 仅在 Android 与 Apple 平台图形客户端中支持,并且需要 `auto_detect_interface`。 - -选择网络接口的策略。 +详情参阅 [拨号字段](/configuration/shared/dial/#network_strategy)。 仅当出站为 `direct` 且 `outbound.bind_interface`, `outbound.inet4_bind_address` 且 `outbound.inet6_bind_address` 未设置时生效。 -可用值参阅 [拨号字段](/configuration/shared/dial/#network_strategy)。 +#### network_type + +详情参阅 [拨号字段](/configuration/shared/dial/#network_type)。 + +#### fallback_network_type + +详情参阅 [拨号字段](/configuration/shared/dial/#fallback_network_type)。 #### fallback_delay -!!! quote "" - - 仅在 Android 与 Apple 平台图形客户端中支持,并且需要 `auto_detect_interface` 且 `network_strategy` 已设置。 - 详情参阅 [拨号字段](/configuration/shared/dial/#fallback_delay)。 #### udp_disable_domain_unmapping @@ -68,6 +68,10 @@ icon: material/new-box } ``` +!!! note "" + + 当内容只有一项时,可以忽略 JSON 数组 [] 标签 + `route-options` 为路由设置选项。 ### reject diff --git a/docs/configuration/shared/dial.md b/docs/configuration/shared/dial.md index e67bf616..5f654ae2 100644 --- a/docs/configuration/shared/dial.md +++ b/docs/configuration/shared/dial.md @@ -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 diff --git a/docs/configuration/shared/dial.zh.md b/docs/configuration/shared/dial.zh.md index 4e20f106..ab83c44c 100644 --- a/docs/configuration/shared/dial.zh.md +++ b/docs/configuration/shared/dial.zh.md @@ -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 快速回退连接之前等待的时间长度。