From 1cb06536f19e06aad6bc490bbcc99cccfc0469c4 Mon Sep 17 00:00:00 2001 From: Alessio Nossa Date: Tue, 11 Apr 2023 18:46:35 +0200 Subject: [PATCH] WireguardApp: Add async variant of modify tunnel function Signed-off-by: Alessio Nossa --- .../WireGuardApp/Tunnel/TunnelsManager.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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) -- 2.47.2