Skip to content

Commit

Permalink
Do not show "Activating" when the tunnel is actually idle (#1105)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
keeshux authored Jan 27, 2025
1 parent 9145e81 commit c6b1c03
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
11 changes: 8 additions & 3 deletions Packages/App/Sources/CommonLibrary/Business/ExtendedTunnel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,15 @@ extension TunnelStatus {
func withEnvironment(_ environment: TunnelEnvironment) -> TunnelStatus {
var status = self
if status == .active, let connectionStatus = environment.environmentValue(forKey: TunnelEnvironmentKeys.connectionStatus) {
if connectionStatus == .connected {
status = .active
} else {
switch connectionStatus {
case .connecting:
status = .activating
case .connected:
status = .active
case .disconnecting:
status = .deactivating
case .disconnected:
status = .inactive
}
}
return status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,19 @@ extension ExtendedTunnelTests {
env.setEnvironmentValue(ConnectionStatus.connected, forKey: key)
XCTAssertEqual(tunnelActive.withEnvironment(env), .active)
allConnectionStatuses
.filter {
$0 != .connected
}
.forEach {
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
Expand Down

0 comments on commit c6b1c03

Please sign in to comment.