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 configuration removal to stop the tunnel #2991

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13404,7 +13404,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 172.0.0;
version = 172.0.1;
};
};
9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "f8e381771a33287e317da84d5676a5e2a271bca3",
"version" : "172.0.0"
"revision" : "3274feb8d84fda5f27541c13f2ab428b4e77a5e2",
"version" : "172.0.1"
}
},
{
Expand Down
10 changes: 10 additions & 0 deletions DuckDuckGo/Common/Extensions/NSAlertExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ extension NSAlert {
return alert
}

static func removeVPNConfigurationAlert() -> NSAlert {
let alert = NSAlert()
alert.messageText = "Remove VPN Configuration?"
alert.informativeText = "This will remove the VPN configuration from System Settings > VPN."
alert.alertStyle = .warning
alert.addButton(withTitle: "Remove")
alert.addButton(withTitle: UserText.cancel)
return alert
}

static func removeAllDBPStateAndDataAlert() -> NSAlert {
let alert = NSAlert()
alert.messageText = "Uninstall Personal Information Removal Login Item?"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ final class NetworkProtectionDebugMenu: NSMenu {

buildItems {
NSMenuItem(title: "Reset") {

NSMenuItem(title: "Reset All State Keeping Invite", action: #selector(NetworkProtectionDebugMenu.resetAllKeepingInvite))
.targetting(self)

Expand All @@ -73,8 +74,13 @@ final class NetworkProtectionDebugMenu: NSMenu {
resetToDefaults
.targetting(self)

NSMenuItem.separator()

NSMenuItem(title: "Remove Network Extension and Login Items", action: #selector(NetworkProtectionDebugMenu.removeSystemExtensionAndAgents))
.targetting(self)

NSMenuItem(title: "Remove VPN configuration", action: #selector(NetworkProtectionDebugMenu.removeVPNConfiguration(_:)))
.targetting(self)
}

NSMenuItem.separator()
Expand Down Expand Up @@ -219,6 +225,20 @@ final class NetworkProtectionDebugMenu: NSMenu {
}
}

/// Removes the system extension and agents for DuckDuckGo VPN.
///
@objc func removeVPNConfiguration(_ sender: Any?) {
Task { @MainActor in
guard case .alertFirstButtonReturn = await NSAlert.removeVPNConfigurationAlert().runModal() else { return }

do {
try await debugUtilities.removeVPNConfiguration()
} catch {
await NSAlert(error: error).runModal()
}
}
}

/// Sends a test user notification.
///
@objc func sendTestNotification(_ sender: Any?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ final class NetworkProtectionDebugUtilities {
vpnUninstaller.removeAgents()
}

func removeVPNConfiguration() async throws {
try await vpnUninstaller.removeVPNConfiguration()
}

func sendTestNotificationRequest() async throws {
try await ipcClient.command(.sendTestNotification)
}
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Waitlist/VPNUninstaller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ final class VPNUninstaller: VPNUninstalling {
pinningManager.unpin(.networkProtection)
}

private func removeVPNConfiguration() async throws {
func removeVPNConfiguration() async throws {
// Remove the agent VPN configuration
do {
try await ipcClient.uninstall(.configuration)
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DataBrokerProtection/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let package = Package(
targets: ["DataBrokerProtection"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "172.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "172.0.1"),
.package(path: "../SwiftUIExtensions"),
.package(path: "../XPCHelper"),
],
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/NetworkProtectionMac/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let package = Package(
.library(name: "VPNAppLauncher", targets: ["VPNAppLauncher"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "172.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "172.0.1"),
.package(url: "https://github.com/airbnb/lottie-spm", exact: "4.4.3"),
.package(path: "../AppLauncher"),
.package(path: "../UDSHelper"),
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SubscriptionUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let package = Package(
targets: ["SubscriptionUI"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "172.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "172.0.1"),
.package(path: "../SwiftUIExtensions")
],
targets: [
Expand Down
Loading