diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2022-02-24 12:11:07 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2022-03-11 16:28:35 +0100 |
| commit | cb16c46f66a32653a8932551071d4d35f6a00c07 (patch) | |
| tree | 9e1725f167d375cfb5fde45d624a450dcba66c2c | |
| parent | 6192643aa7ff4e2477016689c7651a9b3f53d3c7 (diff) | |
| download | mullvadvpn-cb16c46f66a32653a8932551071d4d35f6a00c07.tar.xz mullvadvpn-cb16c46f66a32653a8932551071d4d35f6a00c07.zip | |
VPNConnectionProtocol: implement connectedDate
| -rw-r--r-- | ios/MullvadVPN/SimulatorTunnelProvider.swift | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ios/MullvadVPN/SimulatorTunnelProvider.swift b/ios/MullvadVPN/SimulatorTunnelProvider.swift index 4fc86de631..d08eb2ca18 100644 --- a/ios/MullvadVPN/SimulatorTunnelProvider.swift +++ b/ios/MullvadVPN/SimulatorTunnelProvider.swift @@ -13,6 +13,7 @@ import NetworkExtension protocol VPNConnectionProtocol: NSObject { var status: NEVPNStatus { get } + var connectedDate: Date? { get } func startVPNTunnel() throws func startVPNTunnel(options: [String: NSObject]?) throws @@ -165,6 +166,21 @@ class SimulatorVPNConnection: NSObject, VPNConnectionProtocol { } } + private var _connectedDate: Date? + private(set) var connectedDate: Date? { + get { + lock.lock() + defer { lock.unlock() } + + return _connectedDate + } + set { + lock.lock() + _connectedDate = newValue + lock.unlock() + } + } + func startVPNTunnel() throws { try startVPNTunnel(options: nil) } @@ -177,8 +193,10 @@ class SimulatorVPNConnection: NSObject, VPNConnectionProtocol { SimulatorTunnelProvider.shared.delegate.startTunnel(options: options) { (error) in if error == nil { self.status = .connected + self.connectedDate = Date() } else { self.status = .disconnected + self.connectedDate = nil } } } @@ -188,6 +206,7 @@ class SimulatorVPNConnection: NSObject, VPNConnectionProtocol { SimulatorTunnelProvider.shared.delegate.stopTunnel(with: .userInitiated) { self.status = .disconnected + self.connectedDate = nil } } |
