mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
Retry 60 times to reconnect (#2846)
* Reconnect 60 times to reconnect, every second * Fix "in limbo" animation to occur during reconnecting, disconnecting, and reasserting states (up to 60 seconds)
This commit is contained in:
@@ -59,7 +59,9 @@ final class AuthStore: ObservableObject {
|
||||
|
||||
private var status: NEVPNStatus = .invalid
|
||||
|
||||
private static let maxReconnectionAttemptCount = 3
|
||||
// Try to automatically reconnect on network changes
|
||||
private static let maxReconnectionAttemptCount = 60
|
||||
private let reconnectDelaySecs = 1
|
||||
private var reconnectionAttemptsRemaining = maxReconnectionAttemptCount
|
||||
|
||||
private init(tunnelStore: TunnelStore) {
|
||||
@@ -214,9 +216,9 @@ final class AuthStore: ObservableObject {
|
||||
self.reconnectionAttemptsRemaining = self.reconnectionAttemptsRemaining - 1
|
||||
if shouldReconnect {
|
||||
self.logger.log(
|
||||
"\(#function): Will try to reconnect after 1 second (\(self.reconnectionAttemptsRemaining) attempts after this)"
|
||||
"\(#function): Will try every second to reconnect (\(self.reconnectionAttemptsRemaining) attempts after this)"
|
||||
)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(self.reconnectDelaySecs)) {
|
||||
self.logger.log("\(#function): Trying to reconnect")
|
||||
self.startTunnel()
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
}
|
||||
private lazy var signedOutIcon = NSImage(named: "MenuBarIconSignedOut")
|
||||
private lazy var signedInConnectedIcon = NSImage(named: "MenuBarIconSignedInConnected")
|
||||
private lazy var signedInNotConnectedIcon = NSImage(named: "MenuBarIconSignedInNotConnected")
|
||||
|
||||
private lazy var connectingAnimationImages = [
|
||||
NSImage(named: "MenuBarIconConnecting1"),
|
||||
@@ -260,22 +259,20 @@
|
||||
return self.signedOutIcon
|
||||
case .signedIn:
|
||||
switch self.tunnelStatus {
|
||||
case .invalid, .disconnected, .reasserting:
|
||||
return self.signedInNotConnectedIcon
|
||||
case .connected:
|
||||
self.stopConnectingAnimation()
|
||||
return self.signedInConnectedIcon
|
||||
case .connecting, .disconnecting:
|
||||
case .connecting, .disconnecting, .reasserting:
|
||||
self.startConnectingAnimation()
|
||||
return self.connectingAnimationImages.last!
|
||||
case .invalid, .disconnected:
|
||||
self.stopConnectingAnimation()
|
||||
return self.signedOutIcon
|
||||
@unknown default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}()
|
||||
if self.tunnelStatus == .connecting || self.tunnelStatus == .disconnecting {
|
||||
self.startConnectingAnimation()
|
||||
} else {
|
||||
self.stopConnectingAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
private func startConnectingAnimation() {
|
||||
|
||||
Reference in New Issue
Block a user