Skip to content

Commit

Permalink
Some additional changes to improve clarity in connection tester events
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoreymendez committed Jul 5, 2024
1 parent f22ca61 commit 2da7466
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Sources/NetworkProtection/PacketTunnelProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ open class PacketTunnelProvider: NEPacketTunnelProvider {
}

public enum ConnectionTesterStatus {
case failed(kind: Kind)
case recovered(kind: Kind, failureCount: Int)
case failed(duration: Duration)
case recovered(duration: Duration, failureCount: Int)

public enum Kind: String {
public enum Duration: String {
case immediate
case extended
}
Expand Down Expand Up @@ -333,20 +333,20 @@ open class PacketTunnelProvider: NEPacketTunnelProvider {
self.updateBandwidthAnalyzerAndRekeyIfExpired()

case .reconnected(let failureCount):
providerEvents.fire(.connectionTesterStatusChange(.recovered(kind: .immediate, failureCount: failureCount)))
providerEvents.fire(.connectionTesterStatusChange(.recovered(duration: .immediate, failureCount: failureCount)))

if failureCount >= 8 {
providerEvents.fire(.connectionTesterStatusChange(.recovered(kind: .extended, failureCount: failureCount)))
providerEvents.fire(.connectionTesterStatusChange(.recovered(duration: .extended, failureCount: failureCount)))
}

self.tunnelHealth.isHavingConnectivityIssues = false
self.updateBandwidthAnalyzerAndRekeyIfExpired()

case .disconnected(let failureCount):
if failureCount == 1 {
providerEvents.fire(.connectionTesterStatusChange(.failed(kind: .immediate)))
providerEvents.fire(.connectionTesterStatusChange(.failed(duration: .immediate)))
} else if failureCount == 8 {
providerEvents.fire(.connectionTesterStatusChange(.failed(kind: .extended)))
providerEvents.fire(.connectionTesterStatusChange(.failed(duration: .extended)))
}

self.tunnelHealth.isHavingConnectivityIssues = true
Expand Down

0 comments on commit 2da7466

Please sign in to comment.