mirror of
https://github.com/passepartoutvpn/passepartout-apple.git
synced 2025-02-12 19:02:05 +00:00
Do not show "Activating" when the tunnel is actually idle (#1105)
E.g. in airplane mode, the status shows as "Activating", but the tunnel is not actively establishing any connection. It's just idle. Reported here: https://www.reddit.com/r/passepartout/comments/1i957zj/when_phone_going_into_airplane_mode_passepartout/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
This commit is contained in:
parent
9145e81092
commit
c6b1c03fcb
@ -219,10 +219,15 @@ extension TunnelStatus {
|
|||||||
func withEnvironment(_ environment: TunnelEnvironment) -> TunnelStatus {
|
func withEnvironment(_ environment: TunnelEnvironment) -> TunnelStatus {
|
||||||
var status = self
|
var status = self
|
||||||
if status == .active, let connectionStatus = environment.environmentValue(forKey: TunnelEnvironmentKeys.connectionStatus) {
|
if status == .active, let connectionStatus = environment.environmentValue(forKey: TunnelEnvironmentKeys.connectionStatus) {
|
||||||
if connectionStatus == .connected {
|
switch connectionStatus {
|
||||||
status = .active
|
case .connecting:
|
||||||
} else {
|
|
||||||
status = .activating
|
status = .activating
|
||||||
|
case .connected:
|
||||||
|
status = .active
|
||||||
|
case .disconnecting:
|
||||||
|
status = .deactivating
|
||||||
|
case .disconnected:
|
||||||
|
status = .inactive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return status
|
return status
|
||||||
|
@ -151,12 +151,19 @@ extension ExtendedTunnelTests {
|
|||||||
env.setEnvironmentValue(ConnectionStatus.connected, forKey: key)
|
env.setEnvironmentValue(ConnectionStatus.connected, forKey: key)
|
||||||
XCTAssertEqual(tunnelActive.withEnvironment(env), .active)
|
XCTAssertEqual(tunnelActive.withEnvironment(env), .active)
|
||||||
allConnectionStatuses
|
allConnectionStatuses
|
||||||
.filter {
|
|
||||||
$0 != .connected
|
|
||||||
}
|
|
||||||
.forEach {
|
.forEach {
|
||||||
env.setEnvironmentValue($0, forKey: key)
|
env.setEnvironmentValue($0, forKey: key)
|
||||||
XCTAssertEqual(tunnelActive.withEnvironment(env), .activating)
|
let statusWithEnv = tunnelActive.withEnvironment(env)
|
||||||
|
switch $0 {
|
||||||
|
case .connecting:
|
||||||
|
XCTAssertEqual(statusWithEnv, .activating)
|
||||||
|
case .connected:
|
||||||
|
XCTAssertEqual(statusWithEnv, .active)
|
||||||
|
case .disconnecting:
|
||||||
|
XCTAssertEqual(statusWithEnv, .deactivating)
|
||||||
|
case .disconnected:
|
||||||
|
XCTAssertEqual(statusWithEnv, .inactive)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// unaffected otherwise
|
// unaffected otherwise
|
||||||
|
Loading…
Reference in New Issue
Block a user