Skip to content

Commit

Permalink
Merge branch 'release/7.118.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
brindy committed May 1, 2024
2 parents 985efac + ef173b3 commit 90bcdb2
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 96 deletions.
56 changes: 28 additions & 28 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7914,7 +7914,7 @@
CODE_SIGN_ENTITLEMENTS = PacketTunnelProvider/PacketTunnelProvider.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = HKE973VLUW;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -7951,7 +7951,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = HKE973VLUW;
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand Down Expand Up @@ -8043,7 +8043,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = ShareExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
Expand Down Expand Up @@ -8071,7 +8071,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = HKE973VLUW;
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand Down Expand Up @@ -8221,7 +8221,7 @@
CODE_SIGN_ENTITLEMENTS = DuckDuckGo/DuckDuckGo.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = HKE973VLUW;
Expand All @@ -8247,7 +8247,7 @@
CODE_SIGN_ENTITLEMENTS = DuckDuckGo/DuckDuckGo.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = HKE973VLUW;
INFOPLIST_FILE = DuckDuckGo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
Expand Down Expand Up @@ -8313,7 +8313,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = Widgets/Info.plist;
Expand Down Expand Up @@ -8348,7 +8348,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = HKE973VLUW;
Expand Down Expand Up @@ -8382,7 +8382,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = OpenAction/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
Expand Down Expand Up @@ -8413,7 +8413,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = HKE973VLUW;
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand Down Expand Up @@ -8728,7 +8728,7 @@
CODE_SIGN_ENTITLEMENTS = DuckDuckGo/DuckDuckGoAlpha.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = HKE973VLUW;
Expand Down Expand Up @@ -8760,7 +8760,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = ShareExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
Expand Down Expand Up @@ -8789,7 +8789,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = OpenAction/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
Expand Down Expand Up @@ -8823,7 +8823,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = Widgets/Info.plist;
Expand Down Expand Up @@ -8854,7 +8854,7 @@
CODE_SIGN_ENTITLEMENTS = PacketTunnelProvider/PacketTunnelProviderAlpha.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = HKE973VLUW;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -8887,11 +8887,11 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 0;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Core/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down Expand Up @@ -9125,7 +9125,7 @@
CODE_SIGN_ENTITLEMENTS = DuckDuckGo/DuckDuckGoAlpha.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = HKE973VLUW;
Expand Down Expand Up @@ -9153,7 +9153,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = HKE973VLUW;
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand Down Expand Up @@ -9186,7 +9186,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = HKE973VLUW;
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand Down Expand Up @@ -9224,7 +9224,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = HKE973VLUW;
Expand Down Expand Up @@ -9260,7 +9260,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = HKE973VLUW;
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand Down Expand Up @@ -9295,11 +9295,11 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 0;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Core/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down Expand Up @@ -9473,11 +9473,11 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 0;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Core/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down Expand Up @@ -9506,10 +9506,10 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 0;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Core/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

autoClear = AutoClear(worker: main)
Task {
await autoClear?.clearDataIfEnabled()
await autoClear?.clearDataIfEnabled(launching: true)
}

AppDependencyProvider.shared.voiceSearchHelper.migrateSettingsFlagIfNecessary()
Expand Down
6 changes: 4 additions & 2 deletions DuckDuckGo/AutoClear.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AutoClear {
}

@MainActor
func clearDataIfEnabled() async {
func clearDataIfEnabled(launching: Bool = false) async {
guard let settings = AutoClearSettingsModel(settings: appSettings) else { return }

if settings.action.contains(.clearTabs) {
Expand All @@ -56,7 +56,9 @@ class AutoClear {
await worker.forgetData()
}

worker.clearDataFinished(self)
if !launching {
worker.clearDataFinished(self)
}
}

/// Note: function is parametrised because of tests.
Expand Down
82 changes: 39 additions & 43 deletions DuckDuckGo/Feedback/VPNMetadataCollector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ struct VPNMetadata: Encodable {

struct VPNState: Encodable {
let connectionState: String
let lastDisconnectError: String
let lastDisconnectError: LastDisconnectError?
let underlyingErrors: [LastDisconnectError]?
let connectedServer: String
let connectedServerIP: String
}
Expand Down Expand Up @@ -77,6 +78,12 @@ struct VPNMetadata: Encodable {
let subscriptionActive: Bool
}

struct LastDisconnectError: Encodable {
let domain: String
let code: Int
let description: String
}

let appInfo: AppInfo
let deviceInfo: DeviceInfo
let networkInfo: NetworkInfo
Expand Down Expand Up @@ -220,61 +227,30 @@ final class DefaultVPNMetadataCollector: VPNMetadataCollector {
let connectionState = String(describing: statusObserver.recentValue)
let connectedServer = serverInfoObserver.recentValue.serverLocation?.serverLocation ?? "none"
let connectedServerIP = serverInfoObserver.recentValue.serverAddress ?? "none"
let lastDisconnectError = await lastDisconnectError()

return .init(connectionState: connectionState,
lastDisconnectError: await lastDisconnectError(),
lastDisconnectError: lastDisconnectError?.error,
underlyingErrors: lastDisconnectError?.underlyingErrors,
connectedServer: connectedServer,
connectedServerIP: connectedServerIP)
}

public func lastDisconnectError() async -> String {
public func lastDisconnectError() async -> (error: VPNMetadata.LastDisconnectError, underlyingErrors: [VPNMetadata.LastDisconnectError])? {
if #available(iOS 16, *) {
guard let tunnelManager = try? await NETunnelProviderManager.loadAllFromPreferences().first else {
return "none"
return nil
}

return await withCheckedContinuation { continuation in
tunnelManager.connection.fetchLastDisconnectError { error in
let message = {
if let error = error as? NSError {
if error.domain == NEVPNConnectionErrorDomain,
let code = NEVPNConnectionError(rawValue: error.code) {
switch code {
case .overslept: return "overslept"
case .noNetworkAvailable: return "noNetworkAvailable"
case .unrecoverableNetworkChange: return "unrecoverableNetworkChange"
case .configurationFailed: return "configurationFailed"
case .serverAddressResolutionFailed: return "serverAddressResolutionFailed"
case .serverNotResponding: return "serverNotResponding"
case .serverDead: return "serverDead"
case .authenticationFailed: return "authenticationFailed"
case .clientCertificateInvalid: return "clientCertificateInvalid"
case .clientCertificateNotYetValid: return "clientCertificateNotYetValid"
case .clientCertificateExpired: return "clientCertificateExpired"
case .pluginFailed: return "pluginFailed"
case .configurationNotFound: return "configurationNotFound"
case .pluginDisabled: return "pluginDisabled"
case .negotiationFailed: return "negotiationFailed"
case .serverDisconnected: return "serverDisconnected"
case .serverCertificateInvalid: return "serverCertificateInvalid"
case .serverCertificateNotYetValid: return "serverCertificateNotYetValid"
case .serverCertificateExpired: return "serverCertificateExpired"
default: return error.localizedDescription
}
} else {
return error.localizedDescription
}
}

return "none"
}()

continuation.resume(returning: message)
}
do {
try await tunnelManager.connection.fetchLastDisconnectError()
return nil
} catch {
return (error as NSError).toMetadataError()
}
}

return "none"
return nil
}

func collectVPNSettingsState() -> VPNMetadata.VPNSettingsState {
Expand Down Expand Up @@ -319,3 +295,23 @@ extension VPNMetadata.PrivacyProInfo.Source {
}
}
}

private extension NSError {

@available(iOS 16.0, *)
func toMetadataError() -> (error: VPNMetadata.LastDisconnectError, underlyingErrors: [VPNMetadata.LastDisconnectError]) {
let metadataError = VPNMetadata.LastDisconnectError(domain: self.domain, code: self.code, description: self.localizedDescription)

let underlyingErrors = self.underlyingErrors.compactMap { underlyingError in
let underlyingNSError = underlyingError as NSError
return VPNMetadata.LastDisconnectError(
domain: underlyingNSError.domain,
code: underlyingNSError.code,
description: underlyingNSError.localizedDescription
)
}

return (metadataError, underlyingErrors)
}

}
Loading

0 comments on commit 90bcdb2

Please sign in to comment.