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