WireguardApp: Add async variant of modify tunnel function
Signed-off-by: Alessio Nossa <alessio.nossa@gmail.com>
This commit is contained in:
@@ -206,6 +206,7 @@ class TunnelsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@available(*, renamed: "modify(tunnel:tunnelConfiguration:onDemandOption:shouldEnsureOnDemandEnabled:)")
|
||||||
func modify(tunnel: TunnelContainer, tunnelConfiguration: TunnelConfiguration,
|
func modify(tunnel: TunnelContainer, tunnelConfiguration: TunnelConfiguration,
|
||||||
onDemandOption: ActivateOnDemandOption,
|
onDemandOption: ActivateOnDemandOption,
|
||||||
shouldEnsureOnDemandEnabled: Bool = false,
|
shouldEnsureOnDemandEnabled: Bool = false,
|
||||||
@@ -299,6 +300,22 @@ class TunnelsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@available(iOS 13.0, macOS 10.15.0, *)
|
||||||
|
func modify(tunnel: TunnelContainer, tunnelConfiguration: TunnelConfiguration,
|
||||||
|
onDemandOption: ActivateOnDemandOption,
|
||||||
|
shouldEnsureOnDemandEnabled: Bool = false) async throws {
|
||||||
|
return try await withCheckedThrowingContinuation { continuation in
|
||||||
|
modify(tunnel: tunnel, tunnelConfiguration: tunnelConfiguration, onDemandOption: onDemandOption, shouldEnsureOnDemandEnabled: shouldEnsureOnDemandEnabled) { error in
|
||||||
|
if let error = error {
|
||||||
|
continuation.resume(throwing: error)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
continuation.resume(returning: ())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func remove(tunnel: TunnelContainer, completionHandler: @escaping (TunnelsManagerError?) -> Void) {
|
func remove(tunnel: TunnelContainer, completionHandler: @escaping (TunnelsManagerError?) -> Void) {
|
||||||
let tunnelProviderManager = tunnel.tunnelProvider
|
let tunnelProviderManager = tunnel.tunnelProvider
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
|
|||||||
Reference in New Issue
Block a user