Skip to content

Commit

Permalink
Mergeback from 1.94.0
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoreymendez committed Jun 27, 2024
2 parents 69d55d2 + 957c266 commit e869a5e
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13042,7 +13042,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 161.1.2;
version = 161.1.3;
};
};
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" : "cde956dec771bb7196ab3f4b07e00254e433d58d",
"version" : "161.1.2"
"revision" : "d44d7dcc1f267d78b8d1ad54e276c156040d42e0",
"version" : "161.1.3"
}
},
{
Expand Down
25 changes: 18 additions & 7 deletions DuckDuckGo/Waitlist/VPNUninstaller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,14 @@ final class VPNUninstaller: VPNUninstalling {
//
VPNControllerXPCClient.shared.forceStatusToDisconnected()

// While it may seem like a duplication of code, it's one thing to disable the IPC service
// and it's nother one to "uninstall" our login items. The uninstaller wants both things
// to happen.
//
// As an example of why this is important, we want all agents to be disabled even if the IPC
// service is not based on login items.
try await ipcServiceLauncher.disable()
// When the agent is registered as a login item, we want to unregister it
// and stop it from running, which is achieved by the next call.
removeAgents()

// When the agent was started directly (not as a login item) we want to stop it,
// as the above call won't do anything for it.
try await stopAgents()

notifyVPNUninstalled()
isDisabling = false

Expand All @@ -244,6 +243,18 @@ final class VPNUninstaller: VPNUninstalling {
}
}

// Stop the VPN agents.
//
// There's some intentional redundancy here, as we really want to make sure the
// agent stops running, so we'll first ask politely through IPC and then try to just
// kill it if still running.
//
func stopAgents() async throws {
try await ipcClient.quit()
try? await Task.sleep(interval: 0.1)
try await ipcServiceLauncher.disable()
}

func removeAgents() {
loginItemsManager.disableLoginItems(LoginItemsManager.networkProtectionLoginItems)
}
Expand Down
9 changes: 9 additions & 0 deletions DuckDuckGoVPN/TunnelControllerIPCService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ final class TunnelControllerIPCService {
case .uninstall(let component):
try await uninstall(component)
return nil
case .quit:
quitAgent()
return nil
}
}
} catch {
Expand Down Expand Up @@ -245,6 +248,8 @@ extension TunnelControllerIPCService: XPCServerInterface {
case .disableConnectOnDemandAndShutDown:
// Not implemented on macOS yet
break
case .quitAgent:
quitAgent()
}
}

Expand All @@ -258,6 +263,10 @@ extension TunnelControllerIPCService: XPCServerInterface {
try await uninstaller.removeSystemExtension()
}
}

private func quitAgent() {
exit(EXIT_SUCCESS)
}
}

// MARK: - Error Handling
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: "161.1.2"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "161.1.3"),
.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: "161.1.2"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "161.1.3"),
.package(url: "https://github.com/airbnb/lottie-spm", exact: "4.4.1"),
.package(path: "../AppLauncher"),
.package(path: "../UDSHelper"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ import NetworkProtection
public protocol VPNControllerIPCClient {

func uninstall(_ component: VPNUninstallComponent) async throws
func quit() async throws
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ extension VPNControllerUDSClient: VPNControllerIPCClient {
let payload = try encoder.encode(VPNIPCClientCommand.uninstall(component))
try await udsClient.send(payload)
}

public func quit() async throws {
let payload = try encoder.encode(VPNIPCClientCommand.quit)
try await udsClient.send(payload)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ extension VPNControllerXPCClient: VPNControllerIPCClient {
case .systemExtension:
try await self.command(.removeSystemExtension)
}
}

public func quit() async throws {
try await self.command(.removeSystemExtension)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ public enum VPNUninstallComponent: Codable {

public enum VPNIPCClientCommand: Codable {
case uninstall(_ component: VPNUninstallComponent)
case quit
}
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: "161.1.2"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "161.1.3"),
.package(path: "../SwiftUIExtensions")
],
targets: [
Expand Down

0 comments on commit e869a5e

Please sign in to comment.