Rearrange a tiny bit

This commit is contained in:
Ian VanSchooten 2024-10-18 11:20:30 -04:00
parent e317cb5aec
commit d25834d69d
1 changed files with 19 additions and 19 deletions

View File

@ -32,25 +32,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
try await start() try await start()
} }
private func findManager() async throws -> NETunnelProviderManager {
let targetProtoConfig = self.protocolConfiguration as? NETunnelProviderProtocol;
let targetID = targetProtoConfig?.providerConfiguration!["id"] as? String;
// Load vpn configs from system, and find the manager matching the one being started
let managers = try await NETunnelProviderManager.loadAllFromPreferences()
for manager in managers {
let mgrProtoConfig = manager.protocolConfiguration as? NETunnelProviderProtocol;
let id = mgrProtoConfig?.providerConfiguration!["id"] as? String;
if (id == targetID) {
return manager
}
}
// If we didn't find anything, throw an error
throw VPNStartError.noManagers
}
private func start() async throws { private func start() async throws {
var manager: NETunnelProviderManager? var manager: NETunnelProviderManager?
var config: Data var config: Data
@ -133,6 +114,25 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
// completionHandler() // completionHandler()
// } // }
private func findManager() async throws -> NETunnelProviderManager {
let targetProtoConfig = self.protocolConfiguration as? NETunnelProviderProtocol;
let targetID = targetProtoConfig?.providerConfiguration!["id"] as? String;
// Load vpn configs from system, and find the manager matching the one being started
let managers = try await NETunnelProviderManager.loadAllFromPreferences()
for manager in managers {
let mgrProtoConfig = manager.protocolConfiguration as? NETunnelProviderProtocol;
let id = mgrProtoConfig?.providerConfiguration!["id"] as? String;
if (id == targetID) {
return manager
}
}
// If we didn't find anything, throw an error
throw VPNStartError.noManagers
}
private func startNetworkMonitor() { private func startNetworkMonitor() {
networkMonitor = NWPathMonitor() networkMonitor = NWPathMonitor()
networkMonitor!.pathUpdateHandler = self.pathUpdate networkMonitor!.pathUpdateHandler = self.pathUpdate