Skip to content

Commit 801b8f5

Browse files
committed
Update setup usages
1 parent 1e400f1 commit 801b8f5

File tree

5 files changed

+37
-19
lines changed

5 files changed

+37
-19
lines changed

Library/Network/ExtensionPlatformInterface.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
3939
throw NSError(domain: "missing file descriptor", code: 0)
4040
}
4141
}
42-
42+
4343
public func updateRouteOptions(_ options: (any LibboxTunOptionsProtocol)?) throws {
4444
try runBlocking { [self] in
4545
try await updateRouteOptions0(options)
@@ -53,7 +53,7 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
5353

5454
let autoRouteUseSubRangesByDefault = await SharedPreferences.autoRouteUseSubRangesByDefault.get()
5555
let excludeAPNs = await SharedPreferences.excludeAPNsRoute.get()
56-
56+
5757
let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1")
5858
if options.getAutoRoute() {
5959
settings.mtu = NSNumber(value: options.getMTU())
@@ -200,7 +200,7 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
200200
networkSettings = settings
201201
try await tunnel.setTunnelNetworkSettings(settings)
202202
}
203-
203+
204204
public func usePlatformAutoDetectControl() -> Bool {
205205
false
206206
}

Library/Network/ExtensionProvider.swift

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,24 @@ open class ExtensionProvider: NEPacketTunnelProvider {
1616
override open func startTunnel(options _: [String: NSObject]?) async throws {
1717
LibboxClearServiceError()
1818

19+
let options = LibboxSetupOptions()
20+
options.basePath = FilePath.sharedDirectory.relativePath
21+
options.workingPath = FilePath.workingDirectory.relativePath
22+
options.tempPath = FilePath.cacheDirectory.relativePath
23+
var error: NSError?
24+
LibboxSetup(options, &error)
25+
#if os(tvOS)
26+
options.isTVOS = true
27+
#endif
1928
if let username {
20-
var error: NSError?
21-
LibboxSetupWithUsername(FilePath.sharedDirectory.relativePath, FilePath.workingDirectory.relativePath, FilePath.cacheDirectory.relativePath, username, &error)
22-
if let error {
23-
writeFatalError("(packet-tunnel) error: setup service: \(error.localizedDescription)")
24-
return
25-
}
26-
} else {
27-
var isTVOS = false
28-
#if os(tvOS)
29-
isTVOS = true
30-
#endif
31-
LibboxSetup(FilePath.sharedDirectory.relativePath, FilePath.workingDirectory.relativePath, FilePath.cacheDirectory.relativePath, isTVOS)
29+
options.username = username
30+
}
31+
LibboxSetup(options, &error)
32+
if let error {
33+
writeFatalError("(packet-tunnel) error: setup service: \(error.localizedDescription)")
34+
return
3235
}
3336

34-
var error: NSError?
3537
LibboxRedirectStderr(FilePath.cacheDirectory.appendingPathComponent("stderr.log").relativePath, &error)
3638
if let error {
3739
writeFatalError("(packet-tunnel) redirect stderr error: \(error.localizedDescription)")

MacLibrary/ApplicationDelegate.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ import UserNotifications
88
open class ApplicationDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate {
99
public func applicationDidFinishLaunching(_: Notification) {
1010
NSLog("Here I stand")
11-
LibboxSetup(FilePath.sharedDirectory.relativePath, FilePath.workingDirectory.relativePath, FilePath.cacheDirectory.relativePath, false)
11+
let options = LibboxSetupOptions()
12+
options.basePath = FilePath.sharedDirectory.relativePath
13+
options.workingPath = FilePath.workingDirectory.relativePath
14+
options.tempPath = FilePath.cacheDirectory.relativePath
15+
var error: NSError?
16+
LibboxSetup(options, &error)
1217
LibboxSetLocale(Locale.current.identifier)
1318
let notificationCenter = UNUserNotificationCenter.current()
1419
notificationCenter.setNotificationCategories([

SFI/ApplicationDelegate.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ class ApplicationDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCe
1111

1212
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
1313
NSLog("Here I stand")
14-
LibboxSetup(FilePath.sharedDirectory.relativePath, FilePath.workingDirectory.relativePath, FilePath.cacheDirectory.relativePath, false)
14+
let options = LibboxSetupOptions()
15+
options.basePath = FilePath.sharedDirectory.relativePath
16+
options.workingPath = FilePath.workingDirectory.relativePath
17+
options.tempPath = FilePath.cacheDirectory.relativePath
18+
var error: NSError?
19+
LibboxSetup(options, &error)
1520
LibboxSetLocale(Locale.current.identifier)
1621
let notificationCenter = UNUserNotificationCenter.current()
1722
notificationCenter.setNotificationCategories([

SFT/ApplicationDelegate.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import UIKit
77
class ApplicationDelegate: NSObject, UIApplicationDelegate {
88
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
99
NSLog("Here I stand")
10-
LibboxSetup(FilePath.sharedDirectory.relativePath, FilePath.workingDirectory.relativePath, FilePath.cacheDirectory.relativePath, true)
10+
let options = LibboxSetupOptions()
11+
options.basePath = FilePath.sharedDirectory.relativePath
12+
options.workingPath = FilePath.workingDirectory.relativePath
13+
options.tempPath = FilePath.cacheDirectory.relativePath
14+
options.isTVOS = true
15+
var error: NSError?
16+
LibboxSetup(options, &error)
1117
LibboxSetLocale(Locale.current.identifier)
1218
setup()
1319
return true

0 commit comments

Comments
 (0)