From 099309c4983fc75cefb222055989c5753058164f Mon Sep 17 00:00:00 2001 From: Sergey Abramchuk Date: Mon, 1 May 2017 12:26:09 +0300 Subject: [PATCH] Pause vpn client --- OpenVPN Adapter/OpenVPNAdapter+Public.h | 8 ++++++++ OpenVPN Adapter/OpenVPNAdapter.mm | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/OpenVPN Adapter/OpenVPNAdapter+Public.h b/OpenVPN Adapter/OpenVPNAdapter+Public.h index 70f0066..e801f34 100644 --- a/OpenVPN Adapter/OpenVPNAdapter+Public.h +++ b/OpenVPN Adapter/OpenVPNAdapter+Public.h @@ -161,6 +161,14 @@ NS_SWIFT_NAME(provide(credentials:)); */ - (void)connect; +/** + Pause the client –- useful to avoid continuous reconnection attempts + when network is down + + @param pauseReason <#reason description#> + */ +- (void)pauseWithReason:(nullable NSString *)pauseReason; + /** Close connection with the VPN server */ diff --git a/OpenVPN Adapter/OpenVPNAdapter.mm b/OpenVPN Adapter/OpenVPNAdapter.mm index c81d30b..acb4fc5 100644 --- a/OpenVPN Adapter/OpenVPNAdapter.mm +++ b/OpenVPN Adapter/OpenVPNAdapter.mm @@ -227,6 +227,11 @@ NSString * const OpenVPNAdapterErrorEventKey = @"me.ss-abramchuk.openvpn-adapter }); } +- (void)pauseWithReason:(NSString *)pauseReason { + std::string reason = pauseReason ? std::string([pauseReason UTF8String]) : ""; + self.vpnClient->pause(reason); +} + - (void)disconnect { self.vpnClient->stop(); }