Fix service error permission
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import Libbox
|
||||||
import Library
|
import Library
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
@@ -101,11 +102,13 @@ public struct DashboardView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private nonisolated func checkServiceError() async {
|
private nonisolated func checkServiceError() async {
|
||||||
if let serviceError = try? String(contentsOf: ExtensionProvider.errorFile) {
|
var error: NSError?
|
||||||
|
let message = LibboxReadServiceError(&error)
|
||||||
|
if error != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
alert = Alert(title: Text("Service Error"), message: Text(serviceError))
|
alert = Alert(title: Text("Service Error"), message: Text(message))
|
||||||
}
|
|
||||||
try? FileManager.default.removeItem(at: ExtensionProvider.errorFile)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ import Libbox
|
|||||||
import NetworkExtension
|
import NetworkExtension
|
||||||
|
|
||||||
open class ExtensionProvider: NEPacketTunnelProvider {
|
open class ExtensionProvider: NEPacketTunnelProvider {
|
||||||
public static let errorFile = FilePath.workingDirectory.appendingPathComponent("network_extension_error")
|
|
||||||
|
|
||||||
public var username: String? = nil
|
public var username: String? = nil
|
||||||
private var commandServer: LibboxCommandServer!
|
private var commandServer: LibboxCommandServer!
|
||||||
private var boxService: LibboxBoxService!
|
private var boxService: LibboxBoxService!
|
||||||
@@ -13,14 +11,7 @@ open class ExtensionProvider: NEPacketTunnelProvider {
|
|||||||
private var platformInterface: ExtensionPlatformInterface!
|
private var platformInterface: ExtensionPlatformInterface!
|
||||||
|
|
||||||
override open func startTunnel(options _: [String: NSObject]?) async throws {
|
override open func startTunnel(options _: [String: NSObject]?) async throws {
|
||||||
try? FileManager.default.removeItem(at: ExtensionProvider.errorFile)
|
LibboxClearServiceError()
|
||||||
|
|
||||||
do {
|
|
||||||
try FileManager.default.createDirectory(at: FilePath.workingDirectory, withIntermediateDirectories: true)
|
|
||||||
} catch {
|
|
||||||
writeFatalError("(packet-tunnel) error: create working directory: \(error.localizedDescription)")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if let username {
|
if let username {
|
||||||
var error: NSError?
|
var error: NSError?
|
||||||
@@ -43,7 +34,7 @@ open class ExtensionProvider: NEPacketTunnelProvider {
|
|||||||
writeError("(packet-tunnel) redirect stderr error: \(error.localizedDescription)")
|
writeError("(packet-tunnel) redirect stderr error: \(error.localizedDescription)")
|
||||||
}
|
}
|
||||||
|
|
||||||
try await LibboxSetMemoryLimit(!SharedPreferences.disableMemoryLimit.get())
|
await LibboxSetMemoryLimit(!SharedPreferences.disableMemoryLimit.get())
|
||||||
|
|
||||||
if platformInterface == nil {
|
if platformInterface == nil {
|
||||||
platformInterface = ExtensionPlatformInterface(self)
|
platformInterface = ExtensionPlatformInterface(self)
|
||||||
@@ -69,7 +60,8 @@ open class ExtensionProvider: NEPacketTunnelProvider {
|
|||||||
|
|
||||||
func writeError(_ message: String) {
|
func writeError(_ message: String) {
|
||||||
writeMessage(message)
|
writeMessage(message)
|
||||||
try? message.write(to: ExtensionProvider.errorFile, atomically: true, encoding: .utf8)
|
var error: NSError?
|
||||||
|
LibboxWriteServiceError(message, &error)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func writeFatalError(_ message: String) {
|
public func writeFatalError(_ message: String) {
|
||||||
|
|||||||
@@ -1974,7 +1974,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.8.2;
|
MARKETING_VERSION = 1.8.4;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
||||||
PRODUCT_NAME = "sing-box";
|
PRODUCT_NAME = "sing-box";
|
||||||
SDKROOT = appletvos;
|
SDKROOT = appletvos;
|
||||||
@@ -2008,7 +2008,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.8.2;
|
MARKETING_VERSION = 1.8.4;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
||||||
PRODUCT_NAME = "sing-box";
|
PRODUCT_NAME = "sing-box";
|
||||||
SDKROOT = appletvos;
|
SDKROOT = appletvos;
|
||||||
@@ -2246,7 +2246,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.8.2;
|
MARKETING_VERSION = 1.8.4;
|
||||||
OTHER_CODE_SIGN_FLAGS = "--deep";
|
OTHER_CODE_SIGN_FLAGS = "--deep";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
||||||
PRODUCT_NAME = "sing-box";
|
PRODUCT_NAME = "sing-box";
|
||||||
@@ -2286,7 +2286,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.8.2;
|
MARKETING_VERSION = 1.8.4;
|
||||||
OTHER_CODE_SIGN_FLAGS = "--deep";
|
OTHER_CODE_SIGN_FLAGS = "--deep";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
||||||
PRODUCT_NAME = "sing-box";
|
PRODUCT_NAME = "sing-box";
|
||||||
@@ -2309,7 +2309,7 @@
|
|||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 188;
|
CURRENT_PROJECT_VERSION = 192;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEVELOPMENT_TEAM = Z56Z6NYZN2;
|
DEVELOPMENT_TEAM = Z56Z6NYZN2;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
@@ -2325,7 +2325,7 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||||
MARKETING_VERSION = 1.8.2;
|
MARKETING_VERSION = 1.8.4;
|
||||||
OTHER_CODE_SIGN_FLAGS = "";
|
OTHER_CODE_SIGN_FLAGS = "";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
||||||
PRODUCT_NAME = "sing-box";
|
PRODUCT_NAME = "sing-box";
|
||||||
@@ -2347,7 +2347,7 @@
|
|||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 188;
|
CURRENT_PROJECT_VERSION = 192;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEVELOPMENT_TEAM = Z56Z6NYZN2;
|
DEVELOPMENT_TEAM = Z56Z6NYZN2;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
@@ -2363,7 +2363,7 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||||
MARKETING_VERSION = 1.8.2;
|
MARKETING_VERSION = 1.8.4;
|
||||||
OTHER_CODE_SIGN_FLAGS = "";
|
OTHER_CODE_SIGN_FLAGS = "";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
||||||
PRODUCT_NAME = "sing-box";
|
PRODUCT_NAME = "sing-box";
|
||||||
@@ -2505,7 +2505,7 @@
|
|||||||
"@executable_path/../../../../Frameworks",
|
"@executable_path/../../../../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||||
MARKETING_VERSION = 1.8.2;
|
MARKETING_VERSION = 1.8.4;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.system;
|
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.system;
|
||||||
PRODUCT_NAME = "$(inherited)";
|
PRODUCT_NAME = "$(inherited)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
@@ -2541,7 +2541,7 @@
|
|||||||
"@executable_path/../../../../Frameworks",
|
"@executable_path/../../../../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||||
MARKETING_VERSION = 1.8.2;
|
MARKETING_VERSION = 1.8.4;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.system;
|
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.system;
|
||||||
PRODUCT_NAME = "$(inherited)";
|
PRODUCT_NAME = "$(inherited)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
@@ -2581,7 +2581,7 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||||
MARKETING_VERSION = 1.8.2;
|
MARKETING_VERSION = 1.8.4;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.independent;
|
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.independent;
|
||||||
PRODUCT_NAME = SFM;
|
PRODUCT_NAME = SFM;
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
@@ -2620,7 +2620,7 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||||
MARKETING_VERSION = 1.8.2;
|
MARKETING_VERSION = 1.8.4;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.independent;
|
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.independent;
|
||||||
PRODUCT_NAME = SFM;
|
PRODUCT_NAME = SFM;
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user