From 7eb666ecc4e3728f6b001064bdeae6e3895b07fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 8 May 2024 11:06:18 +0800 Subject: [PATCH] Pass `includeAllNetworks` to TUN --- ApplicationLibrary/Views/Setting/PacketTunnelView.swift | 2 ++ Library/Network/ExtensionPlatformInterface.swift | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/ApplicationLibrary/Views/Setting/PacketTunnelView.swift b/ApplicationLibrary/Views/Setting/PacketTunnelView.swift index cf5e5dd..4be49ae 100644 --- a/ApplicationLibrary/Views/Setting/PacketTunnelView.swift +++ b/ApplicationLibrary/Views/Setting/PacketTunnelView.swift @@ -47,6 +47,8 @@ struct PacketTunnelView: View { Text(""" If this property is true, the system routes network traffic through the tunnel except traffic for designated system services necessary for maintaining expected device functionality. You can exclude some types of traffic using the **excludeAPNs**, **excludeLocalNetworks**, and **excludeCellularServices** properties in combination with this property. + when enabled, the default TUN stack is changed to `gvisor`, and the `system` and `mixed` stacks are not available. + [Apple Documentation](https://developer.apple.com/documentation/networkextension/nevpnprotocol/3131931-includeallnetworks) """) .multilineTextAlignment(.leading) diff --git a/Library/Network/ExtensionPlatformInterface.swift b/Library/Network/ExtensionPlatformInterface.swift index 800467b..f29705e 100644 --- a/Library/Network/ExtensionPlatformInterface.swift +++ b/Library/Network/ExtensionPlatformInterface.swift @@ -239,6 +239,14 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc true } + public func includeAllNetworks() -> Bool { + #if !os(tvOS) + return SharedPreferences.includeAllNetworks.getBlocking() + #else + return false + #endif + } + public func clearDNSCache() { guard let networkSettings else { return