Skip to content

Commit

Permalink
Prevents app updates from stopping the VPN. (#3608)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/1207603085593419/1208865941226621/f

BSK PR: duckduckgo/BrowserServicesKit#1102
iOS PR: duckduckgo/iOS#3639

## Description

Changes how the tunnel is restarted on app update so that it won't fail
to start again..
  • Loading branch information
diegoreymendez authored Nov 28, 2024
1 parent 79f07a8 commit 03e2c6c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15263,7 +15263,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 212.1.0;
version = 212.1.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" : "a3d5a2fc45ce000515b04666aa2fa7ad2d30e288",
"version" : "212.1.0"
"revision" : "db9c29a429896138fab29da987981a5f4a8d6712",
"version" : "212.1.1"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,16 +665,23 @@ final class NetworkProtectionTunnelController: TunnelController, TunnelSessionPr
///
@MainActor
func stop() async {
await stop(disableOnDemand: true)
}

@MainActor
func stop(disableOnDemand: Bool) async {
guard let manager = await manager else {
return
}

await stop(tunnelManager: manager)
await stop(tunnelManager: manager, disableOnDemand: disableOnDemand)
}

@MainActor
private func stop(tunnelManager: NETunnelProviderManager) async {
try? await self.disableOnDemand(tunnelManager: tunnelManager)
private func stop(tunnelManager: NETunnelProviderManager, disableOnDemand: Bool) async {
if disableOnDemand {
try? await self.disableOnDemand(tunnelManager: tunnelManager)
}

switch tunnelManager.connection.status {
case .connected, .connecting, .reasserting:
Expand All @@ -692,15 +699,7 @@ final class NetworkProtectionTunnelController: TunnelController, TunnelSessionPr
///
@MainActor
func restart() async {
guard let manager = await manager else {
return
}

await stop(tunnelManager: manager)
await start()

// When restarting the tunnel we enable on-demand optimistically
try? await enableOnDemand(tunnelManager: manager)
await stop(disableOnDemand: false)
}

// MARK: - On Demand & Kill Switch
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: "212.1.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "212.1.1"),
.package(path: "../SwiftUIExtensions"),
.package(path: "../AppKitExtensions"),
.package(path: "../XPCHelper"),
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/FeatureFlags/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let package = Package(
targets: ["FeatureFlags"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "212.1.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "212.1.1"),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
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: "212.1.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "212.1.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: "212.1.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "212.1.1"),
.package(path: "../SwiftUIExtensions")
],
targets: [
Expand Down

0 comments on commit 03e2c6c

Please sign in to comment.