diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2020-07-29 14:45:30 +0300 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2020-07-30 09:50:25 +0300 |
| commit | 3abddf418d2878095c971dd726154dad99dd5ce2 (patch) | |
| tree | 00d1230a9b06d28b0bcd869d4b668cd2f2f226bf /ios | |
| parent | 94dc68b785bdd2505c13940423c15203672866a9 (diff) | |
| download | mullvadvpn-3abddf418d2878095c971dd726154dad99dd5ce2.tar.xz mullvadvpn-3abddf418d2878095c971dd726154dad99dd5ce2.zip | |
Add method to reconnect the tunnel
Diffstat (limited to 'ios')
| -rw-r--r-- | ios/MullvadVPN/TunnelManager.swift | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ios/MullvadVPN/TunnelManager.swift b/ios/MullvadVPN/TunnelManager.swift index ec234a348f..e21ad3a16f 100644 --- a/ios/MullvadVPN/TunnelManager.swift +++ b/ios/MullvadVPN/TunnelManager.swift @@ -435,6 +435,28 @@ class TunnelManager { exclusityController.addOperation(operation, categories: [.tunnelControl]) } + func reconnectTunnel(completionHandler: @escaping () -> Void) { + let operation = AsyncBlockOperation { (finish) in + guard let tunnelIpc = self.tunnelIpc else { + finish() + return + } + + tunnelIpc.reloadTunnelSettings { (result) in + if case .failure(let error) = result { + error.logChain(message: "Failed to reconnect the tunnel") + } + finish() + } + } + + operation.addDidFinishBlockObserver { (operation) in + completionHandler() + } + + exclusityController.addOperation(operation, categories: [.tunnelControl]) + } + func setAccount(accountToken: String, completionHandler: @escaping (Result<(), TunnelManager.Error>) -> Void) { let operation = ResultOperation<(), TunnelManager.Error> { (finish) in let result = Self.makeTunnelSettings(accountToken: accountToken) |
