Skip to content

Commit

Permalink
Avoids handling VPN wake events when disconnected (#860)
Browse files Browse the repository at this point in the history
## Description

We're emoving known noise from wake pixels, and tunnel update pixels, plus potentially removing unnecessary calls to backend and other code handling that shouldn't happen when the VPN is disconnected.
  • Loading branch information
diegoreymendez authored Jun 26, 2024
1 parent 28687a8 commit 27b2330
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Sources/NetworkProtection/PacketTunnelProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1516,19 +1516,25 @@ open class PacketTunnelProvider: NEPacketTunnelProvider {

// MARK: - Computer sleeping

@MainActor
public override func sleep() async {
os_log("Sleep", log: .networkProtectionSleepLog, type: .info)

await connectionTester.stop()
await tunnelFailureMonitor.stop()
await latencyMonitor.stop()
await entitlementMonitor.stop()
await serverStatusMonitor.stop()
await stopMonitors()
}

@MainActor
public override func wake() {
os_log("Wake up", log: .networkProtectionSleepLog, type: .info)

// macOS can launch the extension due to calls to `sendProviderMessage`, so there's
// a chance this is being called when the VPN isn't really meant to be connected or
// running. We want to avoid firing pixels or handling adapter changes when this is
// the case.
guard connectionStatus != .disconnected else {
return
}

Task {
providerEvents.fire(.tunnelWakeAttempt(.begin))

Expand Down

0 comments on commit 27b2330

Please sign in to comment.