From 6f6f976834ea42fe9b4011a695a99e318ff3c535 Mon Sep 17 00:00:00 2001 From: Diego Rey Mendez Date: Tue, 17 Oct 2023 11:43:06 +0200 Subject: [PATCH 1/5] swiftlint --fix --- DuckDuckGo.xcodeproj/project.pbxproj | 2 ++ .../xcshareddata/swiftpm/Package.resolved | 9 -------- .../NetworkProtectionDebugUtilities.swift | 6 +++--- .../NetworkProtectionTunnelController.swift | 21 +++++++++++++++++++ 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 0f645d1aea..d5968fec5e 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -1297,6 +1297,7 @@ 6AC98418288055C1005FA9CA /* BarsAnimatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarsAnimatorTests.swift; sourceTree = ""; }; 6FB030C7234331B400A10DB9 /* Configuration.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Configuration.xcconfig; path = Configuration/Configuration.xcconfig; sourceTree = ""; }; 7B5E1F9D2AB9E1E900DA1172 /* NetworkProtectionDebugFeatures.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionDebugFeatures.swift; sourceTree = ""; }; + 7BD09C632ADE7EF00081C699 /* BrowserServicesKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = BrowserServicesKit; path = ../../BrowserServicesKit; sourceTree = ""; }; 83004E7F2193BB8200DA013C /* WKNavigationExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WKNavigationExtension.swift; sourceTree = ""; }; 83004E832193E14C00DA013C /* UIAlertControllerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = UIAlertControllerExtension.swift; path = ../Core/UIAlertControllerExtension.swift; sourceTree = ""; }; 83004E852193E5ED00DA013C /* TabViewControllerBrowsingMenuExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabViewControllerBrowsingMenuExtension.swift; sourceTree = ""; }; @@ -3283,6 +3284,7 @@ 31E69A60280F4BAD00478327 /* LocalPackages */ = { isa = PBXGroup; children = ( + 7BD09C632ADE7EF00081C699 /* BrowserServicesKit */, 85875B5F29912A2D00115F05 /* SyncUI */, 37FCAACB2993149A000E420A /* Waitlist */, 31794BFF2821DFB600F18633 /* DuckUI */, diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 6b534cc924..5e415849fa 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -10,15 +10,6 @@ "version": "3.0.0" } }, - { - "package": "BrowserServicesKit", - "repositoryURL": "https://github.com/DuckDuckGo/BrowserServicesKit", - "state": { - "branch": null, - "revision": "89cd93fe9e394f518131bc26d4a3d02c96ee07e6", - "version": "81.3.1" - } - }, { "package": "CocoaAsyncSocket", "repositoryURL": "https://github.com/robbiehanson/CocoaAsyncSocket", diff --git a/DuckDuckGo/NetworkProtectionDebugUtilities.swift b/DuckDuckGo/NetworkProtectionDebugUtilities.swift index a3d47161b9..822d261b61 100644 --- a/DuckDuckGo/NetworkProtectionDebugUtilities.swift +++ b/DuckDuckGo/NetworkProtectionDebugUtilities.swift @@ -35,7 +35,7 @@ final class NetworkProtectionDebugUtilities { return } - try? activeSession.sendProviderMessage(.expireRegistrationKey) + try? await activeSession.sendProviderMessage(.expireRegistrationKey) } // MARK: - Notifications @@ -45,7 +45,7 @@ final class NetworkProtectionDebugUtilities { return } - try? activeSession.sendProviderMessage(.triggerTestNotification) + try? await activeSession.sendProviderMessage(.triggerTestNotification) } // MARK: - Failure Simulation @@ -58,7 +58,7 @@ final class NetworkProtectionDebugUtilities { guard let message = option.extensionMessage else { return } - try? activeSession.sendProviderMessage(message) + try? await activeSession.sendProviderMessage(message) } } diff --git a/DuckDuckGo/NetworkProtectionTunnelController.swift b/DuckDuckGo/NetworkProtectionTunnelController.swift index 6a5bef318b..96e53f989e 100644 --- a/DuckDuckGo/NetworkProtectionTunnelController.swift +++ b/DuckDuckGo/NetworkProtectionTunnelController.swift @@ -67,6 +67,27 @@ final class NetworkProtectionTunnelController: TunnelController { tunnelManager.connection.stopVPNTunnel() } + // MARK: - Connection Status Querying + + /// Queries Network Protection to know if its VPN is connected. + /// + /// - Returns: `true` if the VPN is connected, connecting or reasserting, and `false` otherwise. + /// + var isConnected: Bool { + get async { + guard let tunnelManager = await loadTunnelManager() else { + return false + } + + switch tunnelManager.connection.status { + case .connected, .connecting, .reasserting: + return true + default: + return false + } + } + } + private func startWithError() async throws { let tunnelManager: NETunnelProviderManager From f7e7cab8387f4177849103f1b0d58f662bf3ef94 Mon Sep 17 00:00:00 2001 From: Diego Rey Mendez Date: Tue, 17 Oct 2023 11:44:47 +0200 Subject: [PATCH 2/5] Updates BSK --- DuckDuckGo.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index d5968fec5e..8527327655 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -8967,8 +8967,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { - kind = exactVersion; - version = 81.3.1; + kind = revision; + revision = b0829a7469231d6dcf8d2894679278a03a8f0e33; }; }; C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = { From 9fecd225e9913fc391fef59eded9ac85a6e2562a Mon Sep 17 00:00:00 2001 From: Diego Rey Mendez Date: Tue, 17 Oct 2023 11:45:10 +0200 Subject: [PATCH 3/5] Updates BSK --- DuckDuckGo.xcodeproj/project.pbxproj | 2 -- .../xcshareddata/swiftpm/Package.resolved | 9 +++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 8527327655..ae04e56ef0 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -1297,7 +1297,6 @@ 6AC98418288055C1005FA9CA /* BarsAnimatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarsAnimatorTests.swift; sourceTree = ""; }; 6FB030C7234331B400A10DB9 /* Configuration.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Configuration.xcconfig; path = Configuration/Configuration.xcconfig; sourceTree = ""; }; 7B5E1F9D2AB9E1E900DA1172 /* NetworkProtectionDebugFeatures.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionDebugFeatures.swift; sourceTree = ""; }; - 7BD09C632ADE7EF00081C699 /* BrowserServicesKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = BrowserServicesKit; path = ../../BrowserServicesKit; sourceTree = ""; }; 83004E7F2193BB8200DA013C /* WKNavigationExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WKNavigationExtension.swift; sourceTree = ""; }; 83004E832193E14C00DA013C /* UIAlertControllerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = UIAlertControllerExtension.swift; path = ../Core/UIAlertControllerExtension.swift; sourceTree = ""; }; 83004E852193E5ED00DA013C /* TabViewControllerBrowsingMenuExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabViewControllerBrowsingMenuExtension.swift; sourceTree = ""; }; @@ -3284,7 +3283,6 @@ 31E69A60280F4BAD00478327 /* LocalPackages */ = { isa = PBXGroup; children = ( - 7BD09C632ADE7EF00081C699 /* BrowserServicesKit */, 85875B5F29912A2D00115F05 /* SyncUI */, 37FCAACB2993149A000E420A /* Waitlist */, 31794BFF2821DFB600F18633 /* DuckUI */, diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 5e415849fa..7b6a931e5e 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -10,6 +10,15 @@ "version": "3.0.0" } }, + { + "package": "BrowserServicesKit", + "repositoryURL": "https://github.com/DuckDuckGo/BrowserServicesKit", + "state": { + "branch": null, + "revision": "b0829a7469231d6dcf8d2894679278a03a8f0e33", + "version": null + } + }, { "package": "CocoaAsyncSocket", "repositoryURL": "https://github.com/robbiehanson/CocoaAsyncSocket", From 52787fb00090e541764671284746df9736c14c96 Mon Sep 17 00:00:00 2001 From: Diego Rey Mendez Date: Tue, 17 Oct 2023 11:51:14 +0200 Subject: [PATCH 4/5] Updates BSK --- DuckDuckGo.xcodeproj/project.pbxproj | 2 +- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index ae04e56ef0..f585aaeabd 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -8966,7 +8966,7 @@ repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { kind = revision; - revision = b0829a7469231d6dcf8d2894679278a03a8f0e33; + revision = 81afb3a181eff78f8a1f7bb8496ea609b1ebbb8c; }; }; C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 7b6a931e5e..a68e6c68a5 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -15,7 +15,7 @@ "repositoryURL": "https://github.com/DuckDuckGo/BrowserServicesKit", "state": { "branch": null, - "revision": "b0829a7469231d6dcf8d2894679278a03a8f0e33", + "revision": "81afb3a181eff78f8a1f7bb8496ea609b1ebbb8c", "version": null } }, From af0b206d0fbd9cabcc2be8c0d990462708ae4890 Mon Sep 17 00:00:00 2001 From: Diego Rey Mendez Date: Tue, 17 Oct 2023 12:03:06 +0200 Subject: [PATCH 5/5] Updates BSK --- DuckDuckGo.xcodeproj/project.pbxproj | 2 +- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index f585aaeabd..30f4c19446 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -8966,7 +8966,7 @@ repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { kind = revision; - revision = 81afb3a181eff78f8a1f7bb8496ea609b1ebbb8c; + revision = f1e7e1cde0fd4a07c2c7b142a10641d618f26b5a; }; }; C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index a68e6c68a5..673bb6913c 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -15,7 +15,7 @@ "repositoryURL": "https://github.com/DuckDuckGo/BrowserServicesKit", "state": { "branch": null, - "revision": "81afb3a181eff78f8a1f7bb8496ea609b1ebbb8c", + "revision": "f1e7e1cde0fd4a07c2c7b142a10641d618f26b5a", "version": null } },