Add options to exclude APNs route
This commit is contained in:
@@ -5,6 +5,7 @@ public struct ProfileOverrideView: View {
|
|||||||
@State private var isLoading = true
|
@State private var isLoading = true
|
||||||
@State private var excludeDefaultRoute = false
|
@State private var excludeDefaultRoute = false
|
||||||
@State private var autoRouteUseSubRangesByDefault = false
|
@State private var autoRouteUseSubRangesByDefault = false
|
||||||
|
@State private var excludeAPNsRoute = false
|
||||||
|
|
||||||
public init() {}
|
public init() {}
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
@@ -39,6 +40,17 @@ public struct ProfileOverrideView: View {
|
|||||||
Text("By default, segment routing is used in `auto_route` instead of global routing. If `*_<route_address/route_exclude_address>` exists in the configuration, this item will not take effect on the corresponding network. (commonly used to resolve HomeKit compatibility issues)")
|
Text("By default, segment routing is used in `auto_route` instead of global routing. If `*_<route_address/route_exclude_address>` exists in the configuration, this item will not take effect on the corresponding network. (commonly used to resolve HomeKit compatibility issues)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FormSection {
|
||||||
|
Toggle("Exclude APNs Route", isOn: $excludeAPNsRoute)
|
||||||
|
.onChangeCompat(of: excludeAPNsRoute) { newValue in
|
||||||
|
Task {
|
||||||
|
await SharedPreferences.excludeAPNsRoute.set(newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} footer: {
|
||||||
|
Text("Append `push.apple.com` to `bypass_domain`, and `17.0.0.0/8` to `inet4_route_exclude_address`.")
|
||||||
|
}
|
||||||
|
|
||||||
FormButton {
|
FormButton {
|
||||||
Task {
|
Task {
|
||||||
await SharedPreferences.resetProfileOverride()
|
await SharedPreferences.resetProfileOverride()
|
||||||
@@ -60,6 +72,7 @@ public struct ProfileOverrideView: View {
|
|||||||
private func loadSettings() async {
|
private func loadSettings() async {
|
||||||
excludeDefaultRoute = await SharedPreferences.excludeDefaultRoute.get()
|
excludeDefaultRoute = await SharedPreferences.excludeDefaultRoute.get()
|
||||||
autoRouteUseSubRangesByDefault = await SharedPreferences.autoRouteUseSubRangesByDefault.get()
|
autoRouteUseSubRangesByDefault = await SharedPreferences.autoRouteUseSubRangesByDefault.get()
|
||||||
|
excludeAPNsRoute = await SharedPreferences.excludeAPNsRoute.get()
|
||||||
isLoading = false
|
isLoading = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,10 +62,12 @@ public enum SharedPreferences {
|
|||||||
|
|
||||||
public static let excludeDefaultRoute = Preference<Bool>("exclude_default_route", defaultValue: false)
|
public static let excludeDefaultRoute = Preference<Bool>("exclude_default_route", defaultValue: false)
|
||||||
public static let autoRouteUseSubRangesByDefault = Preference<Bool>("auto_route_use_sub_ranges_by_default", defaultValue: false)
|
public static let autoRouteUseSubRangesByDefault = Preference<Bool>("auto_route_use_sub_ranges_by_default", defaultValue: false)
|
||||||
|
public static let excludeAPNsRoute = Preference<Bool>("exclude_apple_push_notification_services", defaultValue: false)
|
||||||
|
|
||||||
public static func resetProfileOverride() async {
|
public static func resetProfileOverride() async {
|
||||||
await excludeDefaultRoute.set(nil)
|
await excludeDefaultRoute.set(nil)
|
||||||
await autoRouteUseSubRangesByDefault.set(nil)
|
await autoRouteUseSubRangesByDefault.set(nil)
|
||||||
|
await excludeAPNsRoute.set(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
|
|||||||
}
|
}
|
||||||
|
|
||||||
let autoRouteUseSubRangesByDefault = await SharedPreferences.autoRouteUseSubRangesByDefault.get()
|
let autoRouteUseSubRangesByDefault = await SharedPreferences.autoRouteUseSubRangesByDefault.get()
|
||||||
|
let excludeAPNs = await SharedPreferences.excludeAPNsRoute.get()
|
||||||
|
|
||||||
let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1")
|
let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1")
|
||||||
if options.getAutoRoute() {
|
if options.getAutoRoute() {
|
||||||
@@ -84,6 +85,13 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
|
|||||||
ipv4ExcludeRoutes.append(NEIPv4Route(destinationAddress: "0.0.0.0", subnetMask: "255.255.255.254"))
|
ipv4ExcludeRoutes.append(NEIPv4Route(destinationAddress: "0.0.0.0", subnetMask: "255.255.255.254"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if excludeAPNs, !ipv4Routes.isEmpty {
|
||||||
|
if !ipv4ExcludeRoutes.contains(where: { it in
|
||||||
|
it.destinationAddress == "17.0.0.0" && it.destinationSubnetMask == "255.0.0.0"
|
||||||
|
}) {
|
||||||
|
ipv4ExcludeRoutes.append(NEIPv4Route(destinationAddress: "17.0.0.0", subnetMask: "255.0.0.0"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ipv4Settings.includedRoutes = ipv4Routes
|
ipv4Settings.includedRoutes = ipv4Routes
|
||||||
ipv4Settings.excludedRoutes = ipv4ExcludeRoutes
|
ipv4Settings.excludedRoutes = ipv4ExcludeRoutes
|
||||||
@@ -140,6 +148,9 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
|
|||||||
proxySettings.httpEnabled = true
|
proxySettings.httpEnabled = true
|
||||||
proxySettings.httpsEnabled = true
|
proxySettings.httpsEnabled = true
|
||||||
}
|
}
|
||||||
|
if excludeAPNs {
|
||||||
|
proxySettings.exceptionList = ["push.apple.com"]
|
||||||
|
}
|
||||||
settings.proxySettings = proxySettings
|
settings.proxySettings = proxySettings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user