Make GSO adaptive

This commit is contained in:
世界 2024-11-22 17:17:01 +08:00
parent df8a3e912e
commit 255e591ef7
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
23 changed files with 177 additions and 124 deletions

View File

@ -379,7 +379,7 @@ Available values: `wifi`, `cellular`, `ethernet` and `other`.
!!! failure "已在 sing-box 1.10.0 废弃" !!! failure "已在 sing-box 1.10.0 废弃"
`rule_set_ipcidr_match_source` 已重命名为 `rule_set_ip_cidr_match_source` 且将在 sing-box 1.11.0 移除。 `rule_set_ipcidr_match_source` 已重命名为 `rule_set_ip_cidr_match_source` 且将在 sing-box 1.11.0 中被移除。
使规则集中的 `ip_cidr` 规则匹配源 IP。 使规则集中的 `ip_cidr` 规则匹配源 IP。

View File

@ -14,7 +14,6 @@ icon: material/new-box
"system": false, "system": false,
"name": "", "name": "",
"mtu": 1408, "mtu": 1408,
"gso": false,
"address": [], "address": [],
"private_key": "", "private_key": "",
"listen_port": 10000, "listen_port": 10000,
@ -36,6 +35,10 @@ icon: material/new-box
} }
``` ```
!!! note ""
You can ignore the JSON Array [] tag when the content is only one item
### Fields ### Fields
#### system #### system
@ -54,14 +57,6 @@ WireGuard MTU.
`1408` will be used by default. `1408` will be used by default.
#### gso
!!! quote ""
Only supported on Linux.
Try to enable generic segmentation offload.
#### address #### address
==Required== ==Required==

View File

@ -14,7 +14,6 @@ icon: material/new-box
"system": false, "system": false,
"name": "", "name": "",
"mtu": 1408, "mtu": 1408,
"gso": false,
"address": [], "address": [],
"private_key": "", "private_key": "",
"listen_port": 10000, "listen_port": 10000,
@ -36,6 +35,10 @@ icon: material/new-box
} }
``` ```
!!! note ""
当内容只有一项时,可以忽略 JSON 数组 [] 标签
### 字段 ### 字段
#### system_interface #### system_interface
@ -54,14 +57,6 @@ WireGuard MTU。
默认使用 1408。 默认使用 1408。
#### gso
!!! quote ""
仅支持 Linux。
尝试启用通用分段卸载。
#### address #### address
==必填== ==必填==

View File

@ -1,7 +1,11 @@
--- ---
icon: material/new-box icon: material/alert-decagram
--- ---
!!! quote "Changes in sing-box 1.11.0"
:material-delete-alert: [gso](#gso)
!!! quote "Changes in sing-box 1.10.0" !!! quote "Changes in sing-box 1.10.0"
:material-plus: [address](#address) :material-plus: [address](#address)
@ -46,16 +50,7 @@ icon: material/new-box
"172.18.0.1/30", "172.18.0.1/30",
"fdfe:dcba:9876::1/126" "fdfe:dcba:9876::1/126"
], ],
// deprecated
"inet4_address": [
"172.19.0.1/30"
],
// deprecated
"inet6_address": [
"fdfe:dcba:9876::1/126"
],
"mtu": 9000, "mtu": 9000,
"gso": false,
"auto_route": true, "auto_route": true,
"iproute2_table_index": 2022, "iproute2_table_index": 2022,
"iproute2_rule_index": 9000, "iproute2_rule_index": 9000,
@ -69,28 +64,11 @@ icon: material/new-box
"::/1", "::/1",
"8000::/1" "8000::/1"
], ],
// deprecated
"inet4_route_address": [
"0.0.0.0/1",
"128.0.0.0/1"
],
// deprecated
"inet6_route_address": [
"::/1",
"8000::/1"
],
"route_exclude_address": [ "route_exclude_address": [
"192.168.0.0/16", "192.168.0.0/16",
"fc00::/7" "fc00::/7"
], ],
// deprecated
"inet4_route_exclude_address": [
"192.168.0.0/16"
],
// deprecated
"inet6_route_exclude_address": [
"fc00::/7"
],
"route_address_set": [ "route_address_set": [
"geoip-cloudflare" "geoip-cloudflare"
], ],
@ -137,8 +115,31 @@ icon: material/new-box
"match_domain": [] "match_domain": []
} }
}, },
...
// Listen Fields // Deprecated
"gso": false,
"inet4_address": [
"172.19.0.1/30"
],
"inet6_address": [
"fdfe:dcba:9876::1/126"
],
"inet4_route_address": [
"0.0.0.0/1",
"128.0.0.0/1"
],
"inet6_route_address": [
"::/1",
"8000::/1"
],
"inet4_route_exclude_address": [
"192.168.0.0/16"
],
"inet6_route_exclude_address": [
"fc00::/7"
],
... // Listen Fields
} }
``` ```
@ -166,7 +167,7 @@ IPv4 and IPv6 prefix for the tun interface.
!!! failure "Deprecated in sing-box 1.10.0" !!! failure "Deprecated in sing-box 1.10.0"
`inet4_address` is merged to `address` and will be removed in sing-box 1.11.0. `inet4_address` is merged to `address` and will be removed in sing-box 1.12.0.
IPv4 prefix for the tun interface. IPv4 prefix for the tun interface.
@ -174,7 +175,7 @@ IPv4 prefix for the tun interface.
!!! failure "Deprecated in sing-box 1.10.0" !!! failure "Deprecated in sing-box 1.10.0"
`inet6_address` is merged to `address` and will be removed in sing-box 1.11.0. `inet6_address` is merged to `address` and will be removed in sing-box 1.12.0.
IPv6 prefix for the tun interface. IPv6 prefix for the tun interface.
@ -184,6 +185,10 @@ The maximum transmission unit.
#### gso #### gso
!!! failure "Deprecated in sing-box 1.11.0"
GSO has no advantages for transparent proxy scenarios, is deprecated and no longer works, and will be removed in sing-box 1.12.0.
!!! question "Since sing-box 1.8.0" !!! question "Since sing-box 1.8.0"
!!! quote "" !!! quote ""
@ -284,7 +289,7 @@ Use custom routes instead of default when `auto_route` is enabled.
!!! failure "Deprecated in sing-box 1.10.0" !!! failure "Deprecated in sing-box 1.10.0"
`inet4_route_address` is deprecated and will be removed in sing-box 1.11.0, please use [route_address](#route_address) `inet4_route_address` is deprecated and will be removed in sing-box 1.12.0, please use [route_address](#route_address)
instead. instead.
Use custom routes instead of default when `auto_route` is enabled. Use custom routes instead of default when `auto_route` is enabled.
@ -293,7 +298,7 @@ Use custom routes instead of default when `auto_route` is enabled.
!!! failure "Deprecated in sing-box 1.10.0" !!! failure "Deprecated in sing-box 1.10.0"
`inet6_route_address` is deprecated and will be removed in sing-box 1.11.0, please use [route_address](#route_address) `inet6_route_address` is deprecated and will be removed in sing-box 1.12.0, please use [route_address](#route_address)
instead. instead.
Use custom routes instead of default when `auto_route` is enabled. Use custom routes instead of default when `auto_route` is enabled.
@ -308,7 +313,7 @@ Exclude custom routes when `auto_route` is enabled.
!!! failure "Deprecated in sing-box 1.10.0" !!! failure "Deprecated in sing-box 1.10.0"
`inet4_route_exclude_address` is deprecated and will be removed in sing-box 1.11.0, please `inet4_route_exclude_address` is deprecated and will be removed in sing-box 1.12.0, please
use [route_exclude_address](#route_exclude_address) instead. use [route_exclude_address](#route_exclude_address) instead.
Exclude custom routes when `auto_route` is enabled. Exclude custom routes when `auto_route` is enabled.
@ -317,7 +322,7 @@ Exclude custom routes when `auto_route` is enabled.
!!! failure "Deprecated in sing-box 1.10.0" !!! failure "Deprecated in sing-box 1.10.0"
`inet6_route_exclude_address` is deprecated and will be removed in sing-box 1.11.0, please `inet6_route_exclude_address` is deprecated and will be removed in sing-box 1.12.0, please
use [route_exclude_address](#route_exclude_address) instead. use [route_exclude_address](#route_exclude_address) instead.
Exclude custom routes when `auto_route` is enabled. Exclude custom routes when `auto_route` is enabled.

View File

@ -1,8 +1,12 @@
--- ---
icon: material/new-box icon: material/alert-decagram
--- ---
!!! quote "Changes in sing-box 1.10.0" !!! quote "sing-box 1.11.0 中的更改"
:material-delete-alert: [gso](#gso)
!!! quote "sing-box 1.10.0 中的更改"
:material-plus: [address](#address) :material-plus: [address](#address)
:material-delete-clock: [inet4_address](#inet4_address) :material-delete-clock: [inet4_address](#inet4_address)
@ -46,16 +50,7 @@ icon: material/new-box
"172.18.0.1/30", "172.18.0.1/30",
"fdfe:dcba:9876::1/126" "fdfe:dcba:9876::1/126"
], ],
// 已弃用
"inet4_address": [
"172.19.0.1/30"
],
// 已弃用
"inet6_address": [
"fdfe:dcba:9876::1/126"
],
"mtu": 9000, "mtu": 9000,
"gso": false,
"auto_route": true, "auto_route": true,
"iproute2_table_index": 2022, "iproute2_table_index": 2022,
"iproute2_rule_index": 9000, "iproute2_rule_index": 9000,
@ -69,28 +64,11 @@ icon: material/new-box
"::/1", "::/1",
"8000::/1" "8000::/1"
], ],
// 已弃用
"inet4_route_address": [
"0.0.0.0/1",
"128.0.0.0/1"
],
// 已弃用
"inet6_route_address": [
"::/1",
"8000::/1"
],
"route_exclude_address": [ "route_exclude_address": [
"192.168.0.0/16", "192.168.0.0/16",
"fc00::/7" "fc00::/7"
], ],
// 已弃用
"inet4_route_exclude_address": [
"192.168.0.0/16"
],
// 已弃用
"inet6_route_exclude_address": [
"fc00::/7"
],
"route_address_set": [ "route_address_set": [
"geoip-cloudflare" "geoip-cloudflare"
], ],
@ -138,6 +116,29 @@ icon: material/new-box
} }
}, },
// 已弃用
"gso": false,
"inet4_address": [
"172.19.0.1/30"
],
"inet6_address": [
"fdfe:dcba:9876::1/126"
],
"inet4_route_address": [
"0.0.0.0/1",
"128.0.0.0/1"
],
"inet6_route_address": [
"::/1",
"8000::/1"
],
"inet4_route_exclude_address": [
"192.168.0.0/16"
],
"inet6_route_exclude_address": [
"fc00::/7"
],
... // 监听字段 ... // 监听字段
} }
``` ```
@ -168,7 +169,7 @@ tun 接口的 IPv4 和 IPv6 前缀。
!!! failure "已在 sing-box 1.10.0 废弃" !!! failure "已在 sing-box 1.10.0 废弃"
`inet4_address` 已合并到 `address` 且将在 sing-box 1.11.0 移除。 `inet4_address` 已合并到 `address` 且将在 sing-box 1.12.0 中被移除。
==必填== ==必填==
@ -178,7 +179,7 @@ tun 接口的 IPv4 前缀。
!!! failure "已在 sing-box 1.10.0 废弃" !!! failure "已在 sing-box 1.10.0 废弃"
`inet6_address` 已合并到 `address` 且将在 sing-box 1.11.0 移除。 `inet6_address` 已合并到 `address` 且将在 sing-box 1.12.0 中被移除。
tun 接口的 IPv6 前缀。 tun 接口的 IPv6 前缀。
@ -188,6 +189,10 @@ tun 接口的 IPv6 前缀。
#### gso #### gso
!!! failure "已在 sing-box 1.11.0 废弃"
GSO 对于透明代理场景没有优势,已废弃和不再生效,且将在 sing-box 1.12.0 中被移除。
!!! question "自 sing-box 1.8.0 起" !!! question "自 sing-box 1.8.0 起"
!!! quote "" !!! quote ""
@ -288,7 +293,7 @@ tun 接口的 IPv6 前缀。
!!! failure "已在 sing-box 1.10.0 废弃" !!! failure "已在 sing-box 1.10.0 废弃"
`inet4_route_address` 已合并到 `route_address` 且将在 sing-box 1.11.0 移除。 `inet4_route_address` 已合并到 `route_address` 且将在 sing-box 1.12.0 中被移除。
启用 `auto_route` 时使用自定义路由而不是默认路由。 启用 `auto_route` 时使用自定义路由而不是默认路由。
@ -296,7 +301,7 @@ tun 接口的 IPv6 前缀。
!!! failure "已在 sing-box 1.10.0 废弃" !!! failure "已在 sing-box 1.10.0 废弃"
`inet6_route_address` 已合并到 `route_address` 且将在 sing-box 1.11.0 移除。 `inet6_route_address` 已合并到 `route_address` 且将在 sing-box 1.12.0 中被移除。
启用 `auto_route` 时使用自定义路由而不是默认路由。 启用 `auto_route` 时使用自定义路由而不是默认路由。
@ -310,7 +315,7 @@ tun 接口的 IPv6 前缀。
!!! failure "已在 sing-box 1.10.0 废弃" !!! failure "已在 sing-box 1.10.0 废弃"
`inet4_route_exclude_address` 已合并到 `route_exclude_address` 且将在 sing-box 1.11.0 移除。 `inet4_route_exclude_address` 已合并到 `route_exclude_address` 且将在 sing-box 1.12.0 中被移除。
启用 `auto_route` 时排除自定义路由。 启用 `auto_route` 时排除自定义路由。
@ -318,7 +323,7 @@ tun 接口的 IPv6 前缀。
!!! failure "已在 sing-box 1.10.0 废弃" !!! failure "已在 sing-box 1.10.0 废弃"
`inet6_route_exclude_address` 已合并到 `route_exclude_address` 且将在 sing-box 1.11.0 移除。 `inet6_route_exclude_address` 已合并到 `route_exclude_address` 且将在 sing-box 1.12.0 中被移除。
启用 `auto_route` 时排除自定义路由。 启用 `auto_route` 时排除自定义路由。

View File

@ -6,6 +6,10 @@ icon: material/delete-clock
WireGuard outbound is deprecated and will be removed in sing-box 1.13.0, check [Migration](/migration/#migrate-wireguard-outbound-to-endpoint). WireGuard outbound is deprecated and will be removed in sing-box 1.13.0, check [Migration](/migration/#migrate-wireguard-outbound-to-endpoint).
!!! quote "Changes in sing-box 1.11.0"
:material-delete-alert: [gso](#gso)
!!! quote "Changes in sing-box 1.8.0" !!! quote "Changes in sing-box 1.8.0"
:material-plus: [gso](#gso) :material-plus: [gso](#gso)
@ -20,7 +24,6 @@ icon: material/delete-clock
"server": "127.0.0.1", "server": "127.0.0.1",
"server_port": 1080, "server_port": 1080,
"system_interface": false, "system_interface": false,
"gso": false,
"interface_name": "wg0", "interface_name": "wg0",
"local_address": [ "local_address": [
"10.0.0.1/32" "10.0.0.1/32"
@ -45,6 +48,10 @@ icon: material/delete-clock
"mtu": 1408, "mtu": 1408,
"network": "tcp", "network": "tcp",
// Deprecated
"gso": false,
... // Dial Fields ... // Dial Fields
} }
``` ```
@ -77,6 +84,10 @@ Custom interface name for system interface.
#### gso #### gso
!!! failure "Deprecated in sing-box 1.11.0"
GSO will be automatically enabled when available since sing-box 1.11.0.
!!! question "Since sing-box 1.8.0" !!! question "Since sing-box 1.8.0"
!!! quote "" !!! quote ""

View File

@ -6,6 +6,10 @@ icon: material/delete-clock
WireGuard 出站已被启用,且将在 sing-box 1.13.0 中被移除,参阅 [迁移指南](/migration/#migrate-wireguard-outbound-to-endpoint)。 WireGuard 出站已被启用,且将在 sing-box 1.13.0 中被移除,参阅 [迁移指南](/migration/#migrate-wireguard-outbound-to-endpoint)。
!!! quote "sing-box 1.11.0 中的更改"
:material-delete-alert: [gso](#gso)
!!! quote "sing-box 1.8.0 中的更改" !!! quote "sing-box 1.8.0 中的更改"
:material-plus: [gso](#gso) :material-plus: [gso](#gso)
@ -20,7 +24,6 @@ icon: material/delete-clock
"server": "127.0.0.1", "server": "127.0.0.1",
"server_port": 1080, "server_port": 1080,
"system_interface": false, "system_interface": false,
"gso": false,
"interface_name": "wg0", "interface_name": "wg0",
"local_address": [ "local_address": [
"10.0.0.1/32" "10.0.0.1/32"
@ -33,6 +36,10 @@ icon: material/delete-clock
"mtu": 1408, "mtu": 1408,
"network": "tcp", "network": "tcp",
// 废弃的
"gso": false,
... // 拨号字段 ... // 拨号字段
} }
``` ```
@ -65,6 +72,10 @@ icon: material/delete-clock
#### gso #### gso
!!! failure "已在 sing-box 1.11.0 废弃"
自 sing-box 1.11.0 起GSO 将可用时自动启用。
!!! question "自 sing-box 1.8.0 起" !!! question "自 sing-box 1.8.0 起"
!!! quote "" !!! quote ""

View File

@ -388,7 +388,7 @@ Available values: `wifi`, `cellular`, `ethernet` and `other`.
!!! failure "已在 sing-box 1.10.0 废弃" !!! failure "已在 sing-box 1.10.0 废弃"
`rule_set_ipcidr_match_source` 已重命名为 `rule_set_ip_cidr_match_source` 且将在 sing-box 1.11.0 移除。 `rule_set_ipcidr_match_source` 已重命名为 `rule_set_ip_cidr_match_source` 且将在 sing-box 1.11.0 中被移除。
使规则集中的 `ip_cidr` 规则匹配源 IP。 使规则集中的 `ip_cidr` 规则匹配源 IP。

View File

@ -35,6 +35,12 @@ check [Migration](../migration/#migrate-wireguard-outbound-to-endpoint).
Old outbound will be removed in sing-box 1.13.0. Old outbound will be removed in sing-box 1.13.0.
#### GSO option in TUN
GSO has no advantages for transparent proxy scenarios, is deprecated and no longer works in TUN.
Old fields will be removed in sing-box 1.13.0.
## 1.10.0 ## 1.10.0
#### TUN address fields are merged #### TUN address fields are merged

View File

@ -34,6 +34,12 @@ WireGuard 出站已废弃且可以通过端点替代,
旧出站将在 sing-box 1.13.0 中被移除。 旧出站将在 sing-box 1.13.0 中被移除。
#### TUN 的 GSO 字段
GSO 对透明代理场景没有优势,已废弃且在 TUN 中不再起作用。
旧字段将在 sing-box 1.13.0 中被移除。
## 1.10.0 ## 1.10.0
#### Match source 规则项已重命名 #### Match source 规则项已重命名

View File

@ -242,7 +242,6 @@ WireGuard outbound is deprecated and can be replaced by endpoint.
"system": true, "system": true,
"name": "wg0", "name": "wg0",
"mtu": 1408, "mtu": 1408,
"gso": true,
"address": [ "address": [
"10.0.0.2/32" "10.0.0.2/32"
], ],

View File

@ -243,7 +243,6 @@ WireGuard 出站已被弃用,且可以被端点替代。
"system": true, "system": true,
"name": "wg0", "name": "wg0",
"mtu": 1408, "mtu": 1408,
"gso": true,
"address": [ "address": [
"10.0.0.2/32" "10.0.0.2/32"
], ],

View File

@ -44,10 +44,17 @@ func (n Note) Message() string {
} }
func (n Note) MessageWithLink() string { func (n Note) MessageWithLink() string {
if n.MigrationLink != "" {
return F.ToString( return F.ToString(
n.Description, " is deprecated in sing-box ", n.DeprecatedVersion, n.Description, " is deprecated in sing-box ", n.DeprecatedVersion,
" and will be removed in sing-box ", n.ScheduledVersion, ", checkout documentation for migration: ", n.MigrationLink, " and will be removed in sing-box ", n.ScheduledVersion, ", checkout documentation for migration: ", n.MigrationLink,
) )
} else {
return F.ToString(
n.Description, " is deprecated in sing-box ", n.DeprecatedVersion,
" and will be removed in sing-box ", n.ScheduledVersion, ".",
)
}
} }
var OptionBadMatchSource = Note{ var OptionBadMatchSource = Note{
@ -122,6 +129,23 @@ var OptionWireGuardOutbound = Note{
MigrationLink: "https://sing-box.sagernet.org/migration/#migrate-wireguard-outbound-to-endpoint", MigrationLink: "https://sing-box.sagernet.org/migration/#migrate-wireguard-outbound-to-endpoint",
} }
var OptionWireGuardGSO = Note{
Name: "wireguard-gso",
Description: "GSO option in wireguard outbound",
DeprecatedVersion: "1.11.0",
ScheduledVersion: "1.13.0",
EnvName: "WIREGUARD_GSO",
MigrationLink: "https://sing-box.sagernet.org/migration/#migrate-wireguard-outbound-to-endpoint",
}
var OptionTUNGSO = Note{
Name: "tun-gso",
Description: "GSO option in tun",
DeprecatedVersion: "1.11.0",
ScheduledVersion: "1.12.0",
EnvName: "TUN_GSO",
}
var Options = []Note{ var Options = []Note{
OptionBadMatchSource, OptionBadMatchSource,
OptionGEOIP, OptionGEOIP,
@ -131,4 +155,6 @@ var Options = []Note{
OptionInboundOptions, OptionInboundOptions,
OptionDestinationOverrideFields, OptionDestinationOverrideFields,
OptionWireGuardOutbound, OptionWireGuardOutbound,
OptionWireGuardGSO,
OptionTUNGSO,
} }

View File

@ -34,5 +34,5 @@ func (f *stderrManager) ReportDeprecated(feature Note) {
return return
} }
f.logger.Error(feature.MessageWithLink()) f.logger.Error(feature.MessageWithLink())
f.logger.Fatal("to continuing using this feature, set ENABLE_DEPRECATED_" + feature.EnvName + "=true") f.logger.Fatal("to continuing using this feature, set environment variable ENABLE_DEPRECATED_" + feature.EnvName + "=true")
} }

View File

@ -13,7 +13,6 @@ import (
type TunInboundOptions struct { type TunInboundOptions struct {
InterfaceName string `json:"interface_name,omitempty"` InterfaceName string `json:"interface_name,omitempty"`
MTU uint32 `json:"mtu,omitempty"` MTU uint32 `json:"mtu,omitempty"`
GSO bool `json:"gso,omitempty"`
Address badoption.Listable[netip.Prefix] `json:"address,omitempty"` Address badoption.Listable[netip.Prefix] `json:"address,omitempty"`
AutoRoute bool `json:"auto_route,omitempty"` AutoRoute bool `json:"auto_route,omitempty"`
IPRoute2TableIndex int `json:"iproute2_table_index,omitempty"` IPRoute2TableIndex int `json:"iproute2_table_index,omitempty"`
@ -40,6 +39,8 @@ type TunInboundOptions struct {
Platform *TunPlatformOptions `json:"platform,omitempty"` Platform *TunPlatformOptions `json:"platform,omitempty"`
InboundOptions InboundOptions
// Deprecated: removed
GSO bool `json:"gso,omitempty"`
// Deprecated: merged to Address // Deprecated: merged to Address
Inet4Address badoption.Listable[netip.Prefix] `json:"inet4_address,omitempty"` Inet4Address badoption.Listable[netip.Prefix] `json:"inet4_address,omitempty"`
// Deprecated: merged to Address // Deprecated: merged to Address

View File

@ -10,7 +10,6 @@ type WireGuardEndpointOptions struct {
System bool `json:"system,omitempty"` System bool `json:"system,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
MTU uint32 `json:"mtu,omitempty"` MTU uint32 `json:"mtu,omitempty"`
GSO bool `json:"gso,omitempty"`
Address badoption.Listable[netip.Prefix] `json:"address"` Address badoption.Listable[netip.Prefix] `json:"address"`
PrivateKey string `json:"private_key"` PrivateKey string `json:"private_key"`
ListenPort uint16 `json:"listen_port,omitempty"` ListenPort uint16 `json:"listen_port,omitempty"`

View File

@ -62,14 +62,14 @@ type Inbound struct {
func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.TunInboundOptions) (adapter.Inbound, error) { func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.TunInboundOptions) (adapter.Inbound, error) {
address := options.Address address := options.Address
var deprecatedAddressUsed bool var deprecatedAddressUsed bool
//nolint:staticcheck //nolint:staticcheck
//goland:noinspection GoDeprecation
if len(options.Inet4Address) > 0 { if len(options.Inet4Address) > 0 {
address = append(address, options.Inet4Address...) address = append(address, options.Inet4Address...)
deprecatedAddressUsed = true deprecatedAddressUsed = true
} }
//nolint:staticcheck //nolint:staticcheck
//goland:noinspection GoDeprecation
if len(options.Inet6Address) > 0 { if len(options.Inet6Address) > 0 {
address = append(address, options.Inet6Address...) address = append(address, options.Inet6Address...)
deprecatedAddressUsed = true deprecatedAddressUsed = true
@ -82,14 +82,14 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
}) })
routeAddress := options.RouteAddress routeAddress := options.RouteAddress
//nolint:staticcheck //nolint:staticcheck
//goland:noinspection GoDeprecation
if len(options.Inet4RouteAddress) > 0 { if len(options.Inet4RouteAddress) > 0 {
routeAddress = append(routeAddress, options.Inet4RouteAddress...) routeAddress = append(routeAddress, options.Inet4RouteAddress...)
deprecatedAddressUsed = true deprecatedAddressUsed = true
} }
//nolint:staticcheck //nolint:staticcheck
//goland:noinspection GoDeprecation
if len(options.Inet6RouteAddress) > 0 { if len(options.Inet6RouteAddress) > 0 {
routeAddress = append(routeAddress, options.Inet6RouteAddress...) routeAddress = append(routeAddress, options.Inet6RouteAddress...)
deprecatedAddressUsed = true deprecatedAddressUsed = true
@ -102,14 +102,14 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
}) })
routeExcludeAddress := options.RouteExcludeAddress routeExcludeAddress := options.RouteExcludeAddress
//nolint:staticcheck //nolint:staticcheck
//goland:noinspection GoDeprecation
if len(options.Inet4RouteExcludeAddress) > 0 { if len(options.Inet4RouteExcludeAddress) > 0 {
routeExcludeAddress = append(routeExcludeAddress, options.Inet4RouteExcludeAddress...) routeExcludeAddress = append(routeExcludeAddress, options.Inet4RouteExcludeAddress...)
deprecatedAddressUsed = true deprecatedAddressUsed = true
} }
//nolint:staticcheck //nolint:staticcheck
//goland:noinspection GoDeprecation
if len(options.Inet6RouteExcludeAddress) > 0 { if len(options.Inet6RouteExcludeAddress) > 0 {
routeExcludeAddress = append(routeExcludeAddress, options.Inet6RouteExcludeAddress...) routeExcludeAddress = append(routeExcludeAddress, options.Inet6RouteExcludeAddress...)
deprecatedAddressUsed = true deprecatedAddressUsed = true
@ -125,6 +125,11 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
deprecated.Report(ctx, deprecated.OptionTUNAddressX) deprecated.Report(ctx, deprecated.OptionTUNAddressX)
} }
//nolint:staticcheck
if options.GSO {
deprecated.Report(ctx, deprecated.OptionTUNGSO)
}
tunMTU := options.MTU tunMTU := options.MTU
if tunMTU == 0 { if tunMTU == 0 {
tunMTU = 9000 tunMTU = 9000
@ -178,7 +183,6 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
tunOptions: tun.Options{ tunOptions: tun.Options{
Name: options.InterfaceName, Name: options.InterfaceName,
MTU: tunMTU, MTU: tunMTU,
GSO: options.GSO,
Inet4Address: inet4Address, Inet4Address: inet4Address,
Inet6Address: inet6Address, Inet6Address: inet6Address,
AutoRoute: options.AutoRoute, AutoRoute: options.AutoRoute,

View File

@ -51,8 +51,6 @@ func NewEndpoint(ctx context.Context, router adapter.Router, logger log.ContextL
} }
if options.Detour == "" { if options.Detour == "" {
options.IsWireGuardListener = true options.IsWireGuardListener = true
} else if options.GSO {
return nil, E.New("gso is conflict with detour")
} }
outboundDialer, err := dialer.New(ctx, options.DialerOptions) outboundDialer, err := dialer.New(ctx, options.DialerOptions)
if err != nil { if err != nil {
@ -72,7 +70,6 @@ func NewEndpoint(ctx context.Context, router adapter.Router, logger log.ContextL
}, },
Name: options.Name, Name: options.Name,
MTU: options.MTU, MTU: options.MTU,
GSO: options.GSO,
Address: options.Address, Address: options.Address,
PrivateKey: options.PrivateKey, PrivateKey: options.PrivateKey,
ListenPort: options.ListenPort, ListenPort: options.ListenPort,

View File

@ -42,6 +42,9 @@ type Outbound struct {
func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.LegacyWireGuardOutboundOptions) (adapter.Outbound, error) { func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.LegacyWireGuardOutboundOptions) (adapter.Outbound, error) {
deprecated.Report(ctx, deprecated.OptionWireGuardOutbound) deprecated.Report(ctx, deprecated.OptionWireGuardOutbound)
if options.GSO {
deprecated.Report(ctx, deprecated.OptionWireGuardGSO)
}
outbound := &Outbound{ outbound := &Outbound{
Adapter: outbound.NewAdapterWithDialerOptions(C.TypeWireGuard, tag, []string{N.NetworkTCP, N.NetworkUDP}, options.DialerOptions), Adapter: outbound.NewAdapterWithDialerOptions(C.TypeWireGuard, tag, []string{N.NetworkTCP, N.NetworkUDP}, options.DialerOptions),
ctx: ctx, ctx: ctx,
@ -89,7 +92,6 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
}, },
Name: options.InterfaceName, Name: options.InterfaceName,
MTU: options.MTU, MTU: options.MTU,
GSO: options.GSO,
Address: options.LocalAddress, Address: options.LocalAddress,
PrivateKey: options.PrivateKey, PrivateKey: options.PrivateKey,
ResolvePeer: func(domain string) (netip.Addr, error) { ResolvePeer: func(domain string) (netip.Addr, error) {

View File

@ -28,7 +28,6 @@ type DeviceOptions struct {
CreateDialer func(interfaceName string) N.Dialer CreateDialer func(interfaceName string) N.Dialer
Name string Name string
MTU uint32 MTU uint32
GSO bool
Address []netip.Prefix Address []netip.Prefix
AllowedAddress []netip.Prefix AllowedAddress []netip.Prefix
} }

View File

@ -12,7 +12,6 @@ import (
"github.com/sagernet/sing-box/adapter" "github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-tun" "github.com/sagernet/sing-tun"
"github.com/sagernet/sing/common" "github.com/sagernet/sing/common"
E "github.com/sagernet/sing/common/exceptions"
M "github.com/sagernet/sing/common/metadata" M "github.com/sagernet/sing/common/metadata"
N "github.com/sagernet/sing/common/network" N "github.com/sagernet/sing/common/network"
"github.com/sagernet/sing/service" "github.com/sagernet/sing/service"
@ -64,7 +63,7 @@ func (w *systemDevice) Start() error {
return it.Addr().Is6() return it.Addr().Is6()
}), }),
MTU: w.options.MTU, MTU: w.options.MTU,
GSO: w.options.GSO, GSO: true,
InterfaceScope: true, InterfaceScope: true,
Inet4RouteAddress: common.Filter(w.options.AllowedAddress, func(it netip.Prefix) bool { Inet4RouteAddress: common.Filter(w.options.AllowedAddress, func(it netip.Prefix) bool {
return it.Addr().Is4() return it.Addr().Is4()
@ -88,12 +87,8 @@ func (w *systemDevice) Start() error {
} }
w.options.Logger.Info("started at ", w.options.Name) w.options.Logger.Info("started at ", w.options.Name)
w.device = tunInterface w.device = tunInterface
if w.options.GSO {
batchTUN, isBatchTUN := tunInterface.(tun.LinuxTUN) batchTUN, isBatchTUN := tunInterface.(tun.LinuxTUN)
if !isBatchTUN { if isBatchTUN {
tunInterface.Close()
return E.New("GSO is not supported on current platform")
}
w.batchDevice = batchTUN w.batchDevice = batchTUN
} }
w.events <- wgTun.EventUp w.events <- wgTun.EventUp

View File

@ -104,7 +104,6 @@ func NewEndpoint(options EndpointOptions) (*Endpoint, error) {
CreateDialer: options.CreateDialer, CreateDialer: options.CreateDialer,
Name: options.Name, Name: options.Name,
MTU: options.MTU, MTU: options.MTU,
GSO: options.GSO,
Address: options.Address, Address: options.Address,
AllowedAddress: allowedAddresses, AllowedAddress: allowedAddresses,
} }

View File

@ -21,7 +21,6 @@ type EndpointOptions struct {
CreateDialer func(interfaceName string) N.Dialer CreateDialer func(interfaceName string) N.Dialer
Name string Name string
MTU uint32 MTU uint32
GSO bool
Address []netip.Prefix Address []netip.Prefix
PrivateKey string PrivateKey string
ListenPort uint16 ListenPort uint16