Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix VPN denial prompt loop #2728

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions DuckDuckGo/NetworkProtectionTunnelController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ final class NetworkProtectionTunnelController: TunnelController {
case saveToPreferencesFailed(Error)
case startVPNFailed(Error)
case fetchAuthTokenFailed(Error)
case configSystemPermissionsDenied(Error)

public var errorCode: Int {
switch self {
Expand All @@ -51,6 +52,7 @@ final class NetworkProtectionTunnelController: TunnelController {
case .saveToPreferencesFailed: 2
case .startVPNFailed: 3
case .fetchAuthTokenFailed: 4
case .configSystemPermissionsDenied: 5
}
}

Expand All @@ -63,7 +65,8 @@ final class NetworkProtectionTunnelController: TunnelController {
.loadFromPreferencesFailed(let error),
.saveToPreferencesFailed(let error),
.startVPNFailed(let error),
.fetchAuthTokenFailed(let error):
.fetchAuthTokenFailed(let error),
.configSystemPermissionsDenied(let error):
return [NSUnderlyingErrorKey: error]
}
}
Expand All @@ -82,6 +85,9 @@ final class NetworkProtectionTunnelController: TunnelController {
try await startWithError()
Pixel.fire(pixel: .networkProtectionControllerStartSuccess)
} catch {
if case StartError.configSystemPermissionsDenied = error {
return
}
Pixel.fire(pixel: .networkProtectionControllerStartFailure, error: error)

#if DEBUG
Expand Down Expand Up @@ -249,7 +255,7 @@ final class NetworkProtectionTunnelController: TunnelController {
// This is a user denying the system permissions prompt to add the config
// Maybe we should fire another pixel here, but not a start failure as this is an imaginable scenario
// The code could be caused by a number of problems so I'm using the localizedDescription to catch that case
return
throw StartError.configSystemPermissionsDenied(error)
}
throw StartError.saveToPreferencesFailed(error)
}
Expand Down
Loading