From: Alessio Nossa Date: Tue, 11 Apr 2023 16:46:35 +0000 (+0200) Subject: WireguardApp: Add async variant of modify tunnel function X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1cb06536f19e06aad6bc490bbcc99cccfc0469c4;p=thirdparty%2Fwireguard-apple.git WireguardApp: Add async variant of modify tunnel function Signed-off-by: Alessio Nossa --- diff --git a/Sources/WireGuardApp/Tunnel/TunnelsManager.swift b/Sources/WireGuardApp/Tunnel/TunnelsManager.swift index 7751e54..4471859 100644 --- a/Sources/WireGuardApp/Tunnel/TunnelsManager.swift +++ b/Sources/WireGuardApp/Tunnel/TunnelsManager.swift @@ -206,6 +206,7 @@ class TunnelsManager { } } + @available(*, renamed: "modify(tunnel:tunnelConfiguration:onDemandOption:shouldEnsureOnDemandEnabled:)") func modify(tunnel: TunnelContainer, tunnelConfiguration: TunnelConfiguration, onDemandOption: ActivateOnDemandOption, 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) { let tunnelProviderManager = tunnel.tunnelProvider #if os(macOS)