Rearrange a tiny bit
This commit is contained in:
parent
e317cb5aec
commit
d25834d69d
|
@ -32,25 +32,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
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 {
|
||||
var manager: NETunnelProviderManager?
|
||||
var config: Data
|
||||
|
@ -133,6 +114,25 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
// 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() {
|
||||
networkMonitor = NWPathMonitor()
|
||||
networkMonitor!.pathUpdateHandler = self.pathUpdate
|
||||
|
|
Loading…
Reference in New Issue