Skip to content

Commit

Permalink
documentation: Refactor multi networks strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Nov 13, 2024
1 parent 55b2e11 commit 61f8920
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 67 deletions.
37 changes: 23 additions & 14 deletions docs/configuration/route/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 ""

You can ignore the JSON Array [] tag when the content is only one item

| Key | Format |
|-----------|-----------------------|
| `geoip` | [GeoIP](./geoip/) |
| `geosite` | [Geosite](./geosite/) |
### Fields

#### rules

Expand Down Expand Up @@ -96,24 +99,30 @@ Takes no effect if `outbound.routing_mark` is set.

#### default_network_strategy

!!! quote ""

Only supported in graphical clients on Android and iOS with `auto_detect_interface` enabled.
!!! question "Since sing-box 1.11.0"

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.

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

#### default_fallback_delay
!!! question "Since sing-box 1.11.0"

!!! quote ""
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

Only supported in graphical clients on Android and iOS with `auto_detect_interface` enabled and `network_strategy` set.
!!! question "Since sing-box 1.11.0"

See [Dial Fields](/configuration/shared/dial/#fallback_delay) for details.
See [Dial Fields](/configuration/shared/dial/#fallback_delay) for details.
39 changes: 30 additions & 9 deletions docs/configuration/route/index.zh.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -26,6 +37,10 @@
}
```

!!! note ""

当内容只有一项时,可以忽略 JSON 数组 [] 标签

### 字段

|| 格式 |
Expand Down Expand Up @@ -87,24 +102,30 @@

#### network_strategy

!!! quote ""

仅在 Android 与 Apple 平台图形客户端中支持,并且需要 `auto_detect_interface`。
!!! question "自 sing-box 1.11.0 起"

选择网络接口的策略
详情参阅 [拨号字段](/configuration/shared/dial/#network_strategy)

`outbound.bind_interface`, `outbound.inet4_bind_address``outbound.inet6_bind_address` 已设置时不生效。

可以被 `outbound.network_strategy` 覆盖。

`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)

#### default_fallback_network_type

!!! question "自 sing-box 1.11.0 起"

详情参阅 [拨号字段](/configuration/shared/dial/#default_fallback_network_type)

#### default_fallback_delay

仅在 Android 与 Apple 平台图形客户端中支持,并且需要 `auto_detect_interface` 且 `network_strategy` 已设置。
!!! question "自 sing-box 1.11.0 起"

详情请参阅 [拨号字段](/configuration/shared/dial/#fallback_delay)
详情参阅 [拨号字段](/configuration/shared/dial/#fallback_delay)
22 changes: 13 additions & 9 deletions docs/configuration/route/rule_action.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,22 +33,20 @@ 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

#### fallback_delay
See [Dial Fields](/configuration/shared/dial/#network_type) for details.

#### fallback_network_type

!!! quote ""
See [Dial Fields](/configuration/shared/dial/#fallback_network_type) for details.

Only supported in graphical clients on Android and iOS with `auto_detect_interface` enabled and `network_strategy` set.
#### fallback_delay

See [Dial Fields](/configuration/shared/dial/#fallback_delay) for details.

Expand Down
22 changes: 13 additions & 9 deletions docs/configuration/route/rule_action.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -27,22 +29,20 @@ 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

#### fallback_delay
详情参阅 [拨号字段](/configuration/shared/dial/#network_type)

!!! quote ""
#### fallback_network_type

仅在 Android 与 Apple 平台图形客户端中支持,并且需要 `auto_detect_interface` 且 `network_strategy` 已设置。
详情参阅 [拨号字段](/configuration/shared/dial/#fallback_network_type)

#### fallback_delay

详情参阅 [拨号字段](/configuration/shared/dial/#fallback_delay)

Expand All @@ -68,6 +68,10 @@ icon: material/new-box
}
```

!!! note ""

当内容只有一项时,可以忽略 JSON 数组 [] 标签

`route-options` 为路由设置选项。

### reject
Expand Down
63 changes: 49 additions & 14 deletions docs/configuration/shared/dial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 61f8920

Please sign in to comment.