aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-12-14 17:33:52 +0530
committerRoopesh Chander <roop@roopc.net>2018-12-14 17:33:56 +0530
commitc4263da23121e3dd2bf0dcc58b6df9c6249eb080 (patch)
treededdb39b96ab360126b0b8a5fb8ae6fc81e36324
parentFix status switch weird state after an error occurs (diff)
downloadwireguard-apple-c4263da23121e3dd2bf0dcc58b6df9c6249eb080.tar.xz
wireguard-apple-c4263da23121e3dd2bf0dcc58b6df9c6249eb080.zip
Fix tunnel remaining in 'Activating' state
It uses to remain in 'Activating' state when we don't get a status update notification, for example, when turning on the tunnel repeatedly without Internet connectivity. Signed-off-by: Roopesh Chander <roop@roopc.net>
-rw-r--r--WireGuard/WireGuard/Tunnel/TunnelsManager.swift20
1 files changed, 19 insertions, 1 deletions
diff --git a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
index 4abc3c05..6f932676 100644
--- a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
+++ b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
@@ -358,8 +358,26 @@ class TunnelContainer: NSObject {
@objc dynamic var isActivateOnDemandEnabled: Bool
- var isAttemptingActivation = false
+ var isAttemptingActivation = false {
+ didSet {
+ if isAttemptingActivation {
+ let activationTimer = Timer(timeInterval: 5 /* seconds */, repeats: true) { [weak self] _ in
+ guard let self = self else { return }
+ self.refreshStatus()
+ if self.status == .inactive || self.status == .active {
+ self.isAttemptingActivation = false // This also invalidates the timer
+ }
+ }
+ self.activationTimer = activationTimer
+ RunLoop.main.add(activationTimer, forMode: .default)
+ } else {
+ self.activationTimer?.invalidate()
+ self.activationTimer = nil
+ }
+ }
+ }
var activationAttemptId: String?
+ var activationTimer: Timer?
fileprivate let tunnelProvider: NETunnelProviderManager
private var lastTunnelConnectionStatus: NEVPNStatus?