Remove memory limit settings on macOS
This commit is contained in:
@@ -6,7 +6,9 @@ struct PacketTunnelView: View {
|
||||
@State private var isLoading = true
|
||||
@State private var alert: AlertState?
|
||||
|
||||
@State private var ignoreMemoryLimit = false
|
||||
#if !os(macOS)
|
||||
@State private var ignoreMemoryLimit = false
|
||||
#endif
|
||||
|
||||
@State private var includeAllNetworks = false
|
||||
@State private var excludeAPNs = false
|
||||
@@ -25,12 +27,14 @@ struct PacketTunnelView: View {
|
||||
}
|
||||
} else {
|
||||
FormView {
|
||||
FormToggle("Ignore Memory Limit", """
|
||||
Do not enforce memory limits on sing-box. Will cause OOM on non-jailbroken iOS and tvOS devices.
|
||||
""", $ignoreMemoryLimit) { newValue in
|
||||
await SharedPreferences.ignoreMemoryLimit.set(newValue)
|
||||
await restartService()
|
||||
}
|
||||
#if !os(macOS)
|
||||
FormToggle("Ignore Memory Limit", """
|
||||
Do not enforce memory limits on sing-box. Will cause OOM on non-jailbroken devices.
|
||||
""", $ignoreMemoryLimit) { newValue in
|
||||
await SharedPreferences.ignoreMemoryLimit.set(newValue)
|
||||
await restartService()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !os(tvOS)
|
||||
FormToggle("includeAllNetworks", """
|
||||
@@ -117,7 +121,9 @@ struct PacketTunnelView: View {
|
||||
|
||||
@MainActor
|
||||
private func loadSettings() async {
|
||||
ignoreMemoryLimit = await SharedPreferences.ignoreMemoryLimit.get()
|
||||
#if !os(macOS)
|
||||
ignoreMemoryLimit = await SharedPreferences.ignoreMemoryLimit.get()
|
||||
#endif
|
||||
#if !os(tvOS)
|
||||
includeAllNetworks = await SharedPreferences.includeAllNetworks.get()
|
||||
excludeAPNs = await SharedPreferences.excludeAPNs.get()
|
||||
|
||||
@@ -22,14 +22,10 @@ import Foundation
|
||||
public enum SharedPreferences {
|
||||
public static let selectedProfileID = Preference<Int64>("selected_profile_id", defaultValue: -1)
|
||||
|
||||
#if os(macOS)
|
||||
private static let ignoreMemoryLimitByDefault = true
|
||||
#else
|
||||
private static let ignoreMemoryLimitByDefault = false
|
||||
#if !os(macOS)
|
||||
public static let ignoreMemoryLimit = Preference<Bool>("ignore_memory_limit", defaultValue: false)
|
||||
#endif
|
||||
|
||||
public static let ignoreMemoryLimit = Preference<Bool>("ignore_memory_limit", defaultValue: ignoreMemoryLimitByDefault)
|
||||
|
||||
#if os(iOS)
|
||||
private static let excludeLocalNetworksByDefault = true
|
||||
#elseif os(macOS)
|
||||
@@ -46,7 +42,17 @@ public enum SharedPreferences {
|
||||
#endif
|
||||
|
||||
public static func resetPacketTunnel() async {
|
||||
#if !os(tvOS)
|
||||
#if os(macOS)
|
||||
let names = [
|
||||
includeAllNetworks.name,
|
||||
excludeAPNs.name,
|
||||
excludeLocalNetworks.name,
|
||||
excludeCellularServices.name,
|
||||
enforceRoutes.name,
|
||||
]
|
||||
#elseif os(tvOS)
|
||||
let names = [ignoreMemoryLimit.name]
|
||||
#else
|
||||
let names = [
|
||||
ignoreMemoryLimit.name,
|
||||
includeAllNetworks.name,
|
||||
@@ -55,8 +61,6 @@ public enum SharedPreferences {
|
||||
excludeCellularServices.name,
|
||||
enforceRoutes.name,
|
||||
]
|
||||
#else
|
||||
let names = [ignoreMemoryLimit.name]
|
||||
#endif
|
||||
try? await batchDelete(names)
|
||||
}
|
||||
|
||||
@@ -196,7 +196,9 @@ public class ExtensionProfile: ObservableObject {
|
||||
let configContent = try await profile.readAsync()
|
||||
options["configContent"] = NSString(string: configContent)
|
||||
|
||||
options["ignoreMemoryLimit"] = await NSNumber(value: SharedPreferences.ignoreMemoryLimit.get())
|
||||
#if !os(macOS)
|
||||
options["ignoreMemoryLimit"] = await NSNumber(value: SharedPreferences.ignoreMemoryLimit.get())
|
||||
#endif
|
||||
options["systemProxyEnabled"] = await NSNumber(value: SharedPreferences.systemProxyEnabled.get())
|
||||
options["excludeDefaultRoute"] = await NSNumber(value: SharedPreferences.excludeDefaultRoute.get())
|
||||
options["autoRouteUseSubRangesByDefault"] = await NSNumber(value: SharedPreferences.autoRouteUseSubRangesByDefault.get())
|
||||
|
||||
@@ -155,8 +155,10 @@ open class ExtensionProvider: NEPacketTunnelProvider {
|
||||
throw ExtensionStartupError("(packet-tunnel) redirect stderr error: \(stderrError.localizedDescription)")
|
||||
}
|
||||
|
||||
let ignoreMemoryLimit = (effectiveOptions["ignoreMemoryLimit"] as? NSNumber)?.boolValue ?? false
|
||||
LibboxSetMemoryLimit(!ignoreMemoryLimit)
|
||||
#if !os(macOS)
|
||||
let ignoreMemoryLimit = (effectiveOptions["ignoreMemoryLimit"] as? NSNumber)?.boolValue ?? false
|
||||
LibboxSetMemoryLimit(!ignoreMemoryLimit)
|
||||
#endif
|
||||
|
||||
var error: NSError?
|
||||
commandServer = LibboxNewCommandServer(platformInterface, platformInterface, &error)
|
||||
|
||||
+3543
-3543
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user