diff --git a/Library/Network/ExtensionPlatformInterface.swift b/Library/Network/ExtensionPlatformInterface.swift index c66cc6d..b9bcde9 100644 --- a/Library/Network/ExtensionPlatformInterface.swift +++ b/Library/Network/ExtensionPlatformInterface.swift @@ -39,7 +39,7 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc throw NSError(domain: "missing file descriptor", code: 0) } } - + public func updateRouteOptions(_ options: (any LibboxTunOptionsProtocol)?) throws { try runBlocking { [self] in try await updateRouteOptions0(options) @@ -53,7 +53,7 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc let autoRouteUseSubRangesByDefault = await SharedPreferences.autoRouteUseSubRangesByDefault.get() let excludeAPNs = await SharedPreferences.excludeAPNsRoute.get() - + let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1") if options.getAutoRoute() { settings.mtu = NSNumber(value: options.getMTU()) @@ -200,7 +200,7 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc networkSettings = settings try await tunnel.setTunnelNetworkSettings(settings) } - + public func usePlatformAutoDetectControl() -> Bool { false } diff --git a/Library/Network/ExtensionProvider.swift b/Library/Network/ExtensionProvider.swift index 5936a10..387cacf 100644 --- a/Library/Network/ExtensionProvider.swift +++ b/Library/Network/ExtensionProvider.swift @@ -16,22 +16,24 @@ open class ExtensionProvider: NEPacketTunnelProvider { override open func startTunnel(options _: [String: NSObject]?) async throws { LibboxClearServiceError() + let options = LibboxSetupOptions() + options.basePath = FilePath.sharedDirectory.relativePath + options.workingPath = FilePath.workingDirectory.relativePath + options.tempPath = FilePath.cacheDirectory.relativePath + var error: NSError? + LibboxSetup(options, &error) + #if os(tvOS) + options.isTVOS = true + #endif if let username { - var error: NSError? - LibboxSetupWithUsername(FilePath.sharedDirectory.relativePath, FilePath.workingDirectory.relativePath, FilePath.cacheDirectory.relativePath, username, &error) - if let error { - writeFatalError("(packet-tunnel) error: setup service: \(error.localizedDescription)") - return - } - } else { - var isTVOS = false - #if os(tvOS) - isTVOS = true - #endif - LibboxSetup(FilePath.sharedDirectory.relativePath, FilePath.workingDirectory.relativePath, FilePath.cacheDirectory.relativePath, isTVOS) + options.username = username + } + LibboxSetup(options, &error) + if let error { + writeFatalError("(packet-tunnel) error: setup service: \(error.localizedDescription)") + return } - var error: NSError? LibboxRedirectStderr(FilePath.cacheDirectory.appendingPathComponent("stderr.log").relativePath, &error) if let error { writeFatalError("(packet-tunnel) redirect stderr error: \(error.localizedDescription)") diff --git a/MacLibrary/ApplicationDelegate.swift b/MacLibrary/ApplicationDelegate.swift index 208ee6f..0bb5e77 100644 --- a/MacLibrary/ApplicationDelegate.swift +++ b/MacLibrary/ApplicationDelegate.swift @@ -8,7 +8,12 @@ import UserNotifications open class ApplicationDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate { public func applicationDidFinishLaunching(_: Notification) { NSLog("Here I stand") - LibboxSetup(FilePath.sharedDirectory.relativePath, FilePath.workingDirectory.relativePath, FilePath.cacheDirectory.relativePath, false) + let options = LibboxSetupOptions() + options.basePath = FilePath.sharedDirectory.relativePath + options.workingPath = FilePath.workingDirectory.relativePath + options.tempPath = FilePath.cacheDirectory.relativePath + var error: NSError? + LibboxSetup(options, &error) LibboxSetLocale(Locale.current.identifier) let notificationCenter = UNUserNotificationCenter.current() notificationCenter.setNotificationCategories([ diff --git a/SFI/ApplicationDelegate.swift b/SFI/ApplicationDelegate.swift index b5582ab..7eda312 100644 --- a/SFI/ApplicationDelegate.swift +++ b/SFI/ApplicationDelegate.swift @@ -11,7 +11,12 @@ class ApplicationDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCe func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { NSLog("Here I stand") - LibboxSetup(FilePath.sharedDirectory.relativePath, FilePath.workingDirectory.relativePath, FilePath.cacheDirectory.relativePath, false) + let options = LibboxSetupOptions() + options.basePath = FilePath.sharedDirectory.relativePath + options.workingPath = FilePath.workingDirectory.relativePath + options.tempPath = FilePath.cacheDirectory.relativePath + var error: NSError? + LibboxSetup(options, &error) LibboxSetLocale(Locale.current.identifier) let notificationCenter = UNUserNotificationCenter.current() notificationCenter.setNotificationCategories([ diff --git a/SFT/ApplicationDelegate.swift b/SFT/ApplicationDelegate.swift index 3075a8f..d5844a4 100644 --- a/SFT/ApplicationDelegate.swift +++ b/SFT/ApplicationDelegate.swift @@ -7,7 +7,13 @@ import UIKit class ApplicationDelegate: NSObject, UIApplicationDelegate { func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { NSLog("Here I stand") - LibboxSetup(FilePath.sharedDirectory.relativePath, FilePath.workingDirectory.relativePath, FilePath.cacheDirectory.relativePath, true) + let options = LibboxSetupOptions() + options.basePath = FilePath.sharedDirectory.relativePath + options.workingPath = FilePath.workingDirectory.relativePath + options.tempPath = FilePath.cacheDirectory.relativePath + options.isTVOS = true + var error: NSError? + LibboxSetup(options, &error) LibboxSetLocale(Locale.current.identifier) setup() return true