summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBug Magnet <marco.nikic@mullvad.net>2023-08-08 09:25:00 +0200
committerBug Magnet <marco.nikic@mullvad.net>2023-08-08 09:25:00 +0200
commitcde82f554d14516a5f812d4175864e0c38d4418d (patch)
tree1e98683f1ee064b5a471fb7f7f0a817d20e6ae9b
parent5fd82651239b862660498d6790ead9ea62424737 (diff)
parente3bbb09dd22ce70c3aaab794c14f75a8f3ad7220 (diff)
downloadmullvadvpn-cde82f554d14516a5f812d4175864e0c38d4418d.tar.xz
mullvadvpn-cde82f554d14516a5f812d4175864e0c38d4418d.zip
Merge branch 'generic-tunnelsettings-ios-235'
-rw-r--r--ios/MullvadVPN.xcodeproj/project.pbxproj32
-rw-r--r--ios/MullvadVPN/SettingsManager/DeviceState.swift47
-rw-r--r--ios/MullvadVPN/SettingsManager/SettingsManager.swift6
-rw-r--r--ios/MullvadVPN/SettingsManager/StoredAccountData.swift42
-rw-r--r--ios/MullvadVPN/SettingsManager/StoredDeviceData.swift49
-rw-r--r--ios/MullvadVPN/SettingsManager/TunnelSettings.swift12
-rw-r--r--ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift109
-rw-r--r--ios/MullvadVPN/TunnelManager/LoadTunnelConfigurationOperation.swift4
-rw-r--r--ios/MullvadVPN/TunnelManager/SetAccountOperation.swift2
-rw-r--r--ios/MullvadVPN/TunnelManager/TunnelBlockObserver.swift4
-rw-r--r--ios/MullvadVPN/TunnelManager/TunnelInteractor.swift4
-rw-r--r--ios/MullvadVPN/TunnelManager/TunnelManager.swift12
-rw-r--r--ios/MullvadVPN/TunnelManager/TunnelObserver.swift2
-rw-r--r--ios/MullvadVPN/View controllers/Preferences/PreferencesDataSource.swift2
-rw-r--r--ios/MullvadVPN/View controllers/Preferences/PreferencesInteractor.swift4
-rw-r--r--ios/MullvadVPN/View controllers/Preferences/PreferencesViewModel.swift2
-rw-r--r--ios/PacketTunnel/PacketTunnelConfiguration.swift2
17 files changed, 203 insertions, 132 deletions
diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj
index dd0e8795f9..636a8f8969 100644
--- a/ios/MullvadVPN.xcodeproj/project.pbxproj
+++ b/ios/MullvadVPN.xcodeproj/project.pbxproj
@@ -400,6 +400,17 @@
7AF0419E29E957EB00D492DD /* AccountCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF0419D29E957EB00D492DD /* AccountCoordinator.swift */; };
A917351F29FAA9C400D5DCFD /* RESTTransportStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = A917351E29FAA9C400D5DCFD /* RESTTransportStrategy.swift */; };
A917352129FAAA5200D5DCFD /* TransportStrategyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A917352029FAAA5200D5DCFD /* TransportStrategyTests.swift */; };
+ A92ECC212A77FFAF0052F1B1 /* TunnelSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92ECC202A77FFAF0052F1B1 /* TunnelSettings.swift */; };
+ A92ECC222A77FFAF0052F1B1 /* TunnelSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92ECC202A77FFAF0052F1B1 /* TunnelSettings.swift */; };
+ A92ECC242A7802520052F1B1 /* StoredAccountData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92ECC232A7802520052F1B1 /* StoredAccountData.swift */; };
+ A92ECC252A7802520052F1B1 /* StoredAccountData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92ECC232A7802520052F1B1 /* StoredAccountData.swift */; };
+ A92ECC262A7802520052F1B1 /* StoredAccountData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92ECC232A7802520052F1B1 /* StoredAccountData.swift */; };
+ A92ECC282A7802AB0052F1B1 /* StoredDeviceData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92ECC272A7802AB0052F1B1 /* StoredDeviceData.swift */; };
+ A92ECC292A7802AB0052F1B1 /* StoredDeviceData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92ECC272A7802AB0052F1B1 /* StoredDeviceData.swift */; };
+ A92ECC2A2A7802AB0052F1B1 /* StoredDeviceData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92ECC272A7802AB0052F1B1 /* StoredDeviceData.swift */; };
+ A92ECC2C2A7803A50052F1B1 /* DeviceState.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92ECC2B2A7803A50052F1B1 /* DeviceState.swift */; };
+ A92ECC2D2A7803A50052F1B1 /* DeviceState.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92ECC2B2A7803A50052F1B1 /* DeviceState.swift */; };
+ A92ECC2E2A7803A60052F1B1 /* DeviceState.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92ECC2B2A7803A50052F1B1 /* DeviceState.swift */; };
A93D13782A1F60A6001EB0B1 /* shadowsocks.h in Headers */ = {isa = PBXBuildFile; fileRef = 586F2BE129F6916F009E6924 /* shadowsocks.h */; settings = {ATTRIBUTES = (Private, ); }; };
A9467E7F2A29DEFE000DC21F /* RelayCacheTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9467E7E2A29DEFE000DC21F /* RelayCacheTests.swift */; };
A9467E802A29E0A6000DC21F /* AddressCacheTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9CF11FC2A0518E7001D9565 /* AddressCacheTests.swift */; };
@@ -1190,6 +1201,10 @@
7AF0419D29E957EB00D492DD /* AccountCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountCoordinator.swift; sourceTree = "<group>"; };
A917351E29FAA9C400D5DCFD /* RESTTransportStrategy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RESTTransportStrategy.swift; sourceTree = "<group>"; };
A917352029FAAA5200D5DCFD /* TransportStrategyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransportStrategyTests.swift; sourceTree = "<group>"; };
+ A92ECC202A77FFAF0052F1B1 /* TunnelSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelSettings.swift; sourceTree = "<group>"; };
+ A92ECC232A7802520052F1B1 /* StoredAccountData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoredAccountData.swift; sourceTree = "<group>"; };
+ A92ECC272A7802AB0052F1B1 /* StoredDeviceData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoredDeviceData.swift; sourceTree = "<group>"; };
+ A92ECC2B2A7803A50052F1B1 /* DeviceState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceState.swift; sourceTree = "<group>"; };
A9467E7E2A29DEFE000DC21F /* RelayCacheTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayCacheTests.swift; sourceTree = "<group>"; };
A9467E872A2DCD57000DC21F /* ShadowsocksConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShadowsocksConfiguration.swift; sourceTree = "<group>"; };
A9467E8A2A2E0317000DC21F /* ShadowsocksConfigurationCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShadowsocksConfigurationCache.swift; sourceTree = "<group>"; };
@@ -1465,14 +1480,18 @@
isa = PBXGroup;
children = (
068CE57129278F5F00A068BB /* Migrations */,
+ 580F8B8528197958002E0998 /* DNSSettings.swift */,
06410DFD292CE18F00AFC18C /* KeychainSettingsStore.swift */,
068CE5732927B7A400A068BB /* Migration.swift */,
58FF2C02281BDE02009EF542 /* SettingsManager.swift */,
06410E03292D0F7100AFC18C /* SettingsParser.swift */,
06410E06292D108E00AFC18C /* SettingsStore.swift */,
- 580F8B8528197958002E0998 /* DNSSettings.swift */,
+ A92ECC232A7802520052F1B1 /* StoredAccountData.swift */,
+ A92ECC272A7802AB0052F1B1 /* StoredDeviceData.swift */,
587AD7C523421D7000E93A53 /* TunnelSettingsV1.swift */,
580F8B8228197881002E0998 /* TunnelSettingsV2.swift */,
+ A92ECC202A77FFAF0052F1B1 /* TunnelSettings.swift */,
+ A92ECC2B2A7803A50052F1B1 /* DeviceState.swift */,
);
path = SettingsManager;
sourceTree = "<group>";
@@ -3182,7 +3201,10 @@
files = (
A9AD31D72A6AB68B00141BE8 /* InputTextFormatter.swift in Sources */,
58915D6A2A26031B0066445B /* DNSSettings.swift in Sources */,
+ A92ECC262A7802520052F1B1 /* StoredAccountData.swift in Sources */,
58915D692A2601FB0066445B /* WgKeyRotation.swift in Sources */,
+ A92ECC2A2A7802AB0052F1B1 /* StoredDeviceData.swift in Sources */,
+ A92ECC2E2A7803A60052F1B1 /* DeviceState.swift in Sources */,
580810E62A30E13D00B74552 /* DeviceStateAccessorProtocol.swift in Sources */,
58C3FA662A38549D006A450A /* MockFileCache.swift in Sources */,
58915D642A25F8B30066445B /* DeviceCheckOperation.swift in Sources */,
@@ -3231,6 +3253,7 @@
587EB672271451E300123C75 /* PreferencesViewModel.swift in Sources */,
586A950C290125EE007BAF2B /* AlertPresenter.swift in Sources */,
58C3F4F92964B08300D72515 /* MapViewController.swift in Sources */,
+ A92ECC2C2A7803A50052F1B1 /* DeviceState.swift in Sources */,
584D26C6270C8741004EA533 /* SettingsDNSTextCell.swift in Sources */,
58F2E148276A307400A79513 /* MapConnectionStatusOperation.swift in Sources */,
58BA693123EADA6A009DC256 /* SimulatorTunnelProvider.swift in Sources */,
@@ -3252,6 +3275,7 @@
5878A27129091CF20096FC88 /* AccountInteractor.swift in Sources */,
5878F4FC29CDA2E4003D4BE2 /* ChangeLogViewController.swift in Sources */,
068CE5742927B7A400A068BB /* Migration.swift in Sources */,
+ A92ECC282A7802AB0052F1B1 /* StoredDeviceData.swift in Sources */,
58CCA010224249A1004F3011 /* TunnelViewController.swift in Sources */,
58B26E22294351EA00D5980C /* InAppNotificationProvider.swift in Sources */,
5893716A28817A45004EE76C /* DeviceManagementViewController.swift in Sources */,
@@ -3294,6 +3318,7 @@
58EF581125D69DB400AEBA94 /* StatusImageView.swift in Sources */,
58907D9524D17B4E00CFC3F5 /* DisconnectSplitButton.swift in Sources */,
58EE2E3B272FF814003BFF93 /* SettingsDataSourceDelegate.swift in Sources */,
+ A92ECC242A7802520052F1B1 /* StoredAccountData.swift in Sources */,
5823FA5426CE49F700283BF8 /* TunnelObserver.swift in Sources */,
5888AD87227B17950051EB06 /* SelectLocationViewController.swift in Sources */,
583FE00C29C0C7FD006E85F9 /* ModalPresentationConfiguration.swift in Sources */,
@@ -3326,6 +3351,7 @@
585B4B8726D9098900555C4C /* TunnelStatusNotificationProvider.swift in Sources */,
063F026628FFE11C001FA09F /* RESTCreateApplePaymentResponse+Localization.swift in Sources */,
58DF28A52417CB4B00E836B0 /* StorePaymentManager.swift in Sources */,
+ A92ECC212A77FFAF0052F1B1 /* TunnelSettings.swift in Sources */,
583DA21425FA4B5C00318683 /* LocationDataSource.swift in Sources */,
587EB6742714520600123C75 /* PreferencesDataSourceDelegate.swift in Sources */,
582BB1AF229566420055B6EF /* SettingsCell.swift in Sources */,
@@ -3447,10 +3473,12 @@
58FC040A27B3EE03001C21F0 /* TunnelMonitor.swift in Sources */,
5838318B27C40A3900000571 /* Pinger.swift in Sources */,
06410E05292D0FC000AFC18C /* SettingsParser.swift in Sources */,
+ A92ECC292A7802AB0052F1B1 /* StoredDeviceData.swift in Sources */,
58E0729D28814AAE008902F8 /* PacketTunnelConfiguration.swift in Sources */,
58E0729F28814ACC008902F8 /* WireGuardLogLevel+Logging.swift in Sources */,
580F8B8428197884002E0998 /* TunnelSettingsV2.swift in Sources */,
06410E08292D117800AFC18C /* SettingsStore.swift in Sources */,
+ A92ECC222A77FFAF0052F1B1 /* TunnelSettings.swift in Sources */,
58C76A092A33850E00100D75 /* ApplicationTarget.swift in Sources */,
583D86482A2678DC0060D63B /* DeviceStateAccessor.swift in Sources */,
58906DE02445C7A5002F0673 /* NEProviderStopReason+Debug.swift in Sources */,
@@ -3458,6 +3486,8 @@
06410DFF292CF16C00AFC18C /* KeychainSettingsStore.swift in Sources */,
58E072A128814B0E008902F8 /* MullvadEndpoint+WgEndpoint.swift in Sources */,
06AC116228F94C450037AF9A /* ApplicationConfiguration.swift in Sources */,
+ A92ECC252A7802520052F1B1 /* StoredAccountData.swift in Sources */,
+ A92ECC2D2A7803A50052F1B1 /* DeviceState.swift in Sources */,
58A3BDB028A1821A00C8C2C6 /* WgStats.swift in Sources */,
583FE02429C1ACB3006E85F9 /* RESTCreateApplePaymentResponse+Localization.swift in Sources */,
5877D70F282137E8002FCFC7 /* SettingsManager.swift in Sources */,
diff --git a/ios/MullvadVPN/SettingsManager/DeviceState.swift b/ios/MullvadVPN/SettingsManager/DeviceState.swift
new file mode 100644
index 0000000000..f3563480aa
--- /dev/null
+++ b/ios/MullvadVPN/SettingsManager/DeviceState.swift
@@ -0,0 +1,47 @@
+//
+// DeviceState.swift
+// MullvadVPN
+//
+// Created by Marco Nikic on 2023-07-31.
+// Copyright © 2023 Mullvad VPN AB. All rights reserved.
+//
+
+import Foundation
+
+enum DeviceState: Codable, Equatable {
+ case loggedIn(StoredAccountData, StoredDeviceData)
+ case loggedOut
+ case revoked
+
+ private enum LoggedInCodableKeys: String, CodingKey {
+ case _0 = "account"
+ case _1 = "device"
+ }
+
+ var isLoggedIn: Bool {
+ switch self {
+ case .loggedIn:
+ return true
+ case .loggedOut, .revoked:
+ return false
+ }
+ }
+
+ var accountData: StoredAccountData? {
+ switch self {
+ case let .loggedIn(accountData, _):
+ return accountData
+ case .loggedOut, .revoked:
+ return nil
+ }
+ }
+
+ var deviceData: StoredDeviceData? {
+ switch self {
+ case let .loggedIn(_, deviceData):
+ return deviceData
+ case .loggedOut, .revoked:
+ return nil
+ }
+ }
+}
diff --git a/ios/MullvadVPN/SettingsManager/SettingsManager.swift b/ios/MullvadVPN/SettingsManager/SettingsManager.swift
index 90adf20d68..d5db37ff69 100644
--- a/ios/MullvadVPN/SettingsManager/SettingsManager.swift
+++ b/ios/MullvadVPN/SettingsManager/SettingsManager.swift
@@ -87,7 +87,7 @@ enum SettingsManager {
// MARK: - Settings
- static func readSettings() throws -> TunnelSettingsV2 {
+ static func readSettings() throws -> LatestTunnelSettings {
let storedVersion: Int
let data: Data
let parser = makeParser()
@@ -102,7 +102,7 @@ enum SettingsManager {
let currentVersion = SchemaVersion.current
if storedVersion == currentVersion.rawValue {
- return try parser.parsePayload(as: TunnelSettingsV2.self, from: data)
+ return try parser.parsePayload(as: LatestTunnelSettings.self, from: data)
} else {
throw UnsupportedSettingsVersionError(
storedVersion: storedVersion,
@@ -111,7 +111,7 @@ enum SettingsManager {
}
}
- static func writeSettings(_ settings: TunnelSettingsV2) throws {
+ static func writeSettings(_ settings: LatestTunnelSettings) throws {
let parser = makeParser()
let data = try parser.producePayload(settings, version: SchemaVersion.current.rawValue)
diff --git a/ios/MullvadVPN/SettingsManager/StoredAccountData.swift b/ios/MullvadVPN/SettingsManager/StoredAccountData.swift
new file mode 100644
index 0000000000..fac43b6ec2
--- /dev/null
+++ b/ios/MullvadVPN/SettingsManager/StoredAccountData.swift
@@ -0,0 +1,42 @@
+//
+// StoredAccountData.swift
+// MullvadVPN
+//
+// Created by Marco Nikic on 2023-07-31.
+// Copyright © 2023 Mullvad VPN AB. All rights reserved.
+//
+
+import Foundation
+
+struct StoredAccountData: Codable, Equatable {
+ /// Account identifier.
+ var identifier: String
+
+ /// Account number.
+ var number: String
+
+ /// Account expiry.
+ var expiry: Date
+
+ /// Set to `true` when the account is created and flipped to `false` when the user adds more credit.
+ var isNew = false
+
+ /// Returns `true` if account has expired.
+ var isExpired: Bool {
+ expiry <= Date()
+ }
+}
+
+extension StoredAccountData {
+ init(from decoder: Decoder) throws {
+ let container = try decoder.container(keyedBy: CodingKeys.self)
+ self.identifier = try container.decode(String.self, forKey: .identifier)
+ self.number = try container.decode(String.self, forKey: .number)
+ self.expiry = try container.decode(Date.self, forKey: .expiry)
+
+ // When the app is upgraded from 2023.3 or below, this field won't exist, and the auto synthesized init will fail.
+ // This leads to a reset of the settings. If the key isn't present, consider the account not new to avoid the issue.
+ let isNewAccount = try? container.decode(Bool.self, forKey: .isNew)
+ self.isNew = isNewAccount ?? false
+ }
+}
diff --git a/ios/MullvadVPN/SettingsManager/StoredDeviceData.swift b/ios/MullvadVPN/SettingsManager/StoredDeviceData.swift
new file mode 100644
index 0000000000..cd971d5c7d
--- /dev/null
+++ b/ios/MullvadVPN/SettingsManager/StoredDeviceData.swift
@@ -0,0 +1,49 @@
+//
+// StoredDeviceData.swift
+// MullvadVPN
+//
+// Created by Marco Nikic on 2023-07-31.
+// Copyright © 2023 Mullvad VPN AB. All rights reserved.
+//
+
+import Foundation
+import MullvadTypes
+import WireGuardKitTypes
+
+struct StoredDeviceData: Codable, Equatable {
+ /// Device creation date.
+ var creationDate: Date
+
+ /// Device identifier.
+ var identifier: String
+
+ /// Device name.
+ var name: String
+
+ /// Whether relay hijacks DNS from this device.
+ var hijackDNS: Bool
+
+ /// IPv4 address + mask assigned to device.
+ var ipv4Address: IPAddressRange
+
+ /// IPv6 address + mask assigned to device.
+ var ipv6Address: IPAddressRange
+
+ /// WireGuard key data.
+ var wgKeyData: StoredWgKeyData
+
+ /// Returns capitalized device name.
+ var capitalizedName: String {
+ name.capitalized
+ }
+
+ /// Fill in part of the structure that contains device related properties from `Device` struct.
+ mutating func update(from device: Device) {
+ identifier = device.id
+ name = device.name
+ creationDate = device.created
+ hijackDNS = device.hijackDNS
+ ipv4Address = device.ipv4Address
+ ipv6Address = device.ipv6Address
+ }
+}
diff --git a/ios/MullvadVPN/SettingsManager/TunnelSettings.swift b/ios/MullvadVPN/SettingsManager/TunnelSettings.swift
new file mode 100644
index 0000000000..a95eaf5802
--- /dev/null
+++ b/ios/MullvadVPN/SettingsManager/TunnelSettings.swift
@@ -0,0 +1,12 @@
+//
+// TunnelSettings.swift
+// MullvadVPN
+//
+// Created by Marco Nikic on 2023-07-31.
+// Copyright © 2023 Mullvad VPN AB. All rights reserved.
+//
+
+import Foundation
+
+/// Alias to the latest version of the `TunnelSettings`.
+typealias LatestTunnelSettings = TunnelSettingsV2
diff --git a/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift b/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift
index fd5b8a5c55..a530cfb03f 100644
--- a/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift
+++ b/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift
@@ -33,115 +33,6 @@ struct TunnelSettingsV2: Codable, Equatable {
var dnsSettings = DNSSettings()
}
-struct StoredAccountData: Codable, Equatable {
- /// Account identifier.
- var identifier: String
-
- /// Account number.
- var number: String
-
- /// Account expiry.
- var expiry: Date
-
- /// Set to `true` when the account is created and flipped to `false` when the user adds more credit.
- var isNew = false
-
- /// Returns `true` if account has expired.
- var isExpired: Bool {
- expiry <= Date()
- }
-}
-
-extension StoredAccountData {
- init(from decoder: Decoder) throws {
- let container = try decoder.container(keyedBy: CodingKeys.self)
- self.identifier = try container.decode(String.self, forKey: .identifier)
- self.number = try container.decode(String.self, forKey: .number)
- self.expiry = try container.decode(Date.self, forKey: .expiry)
-
- // When the app is upgraded from 2023.3 or below, this field won't exist, and the auto synthesized init will fail.
- // This leads to a reset of the settings. If the key isn't present, consider the account not new to avoid the issue.
- let isNewAccount = try? container.decode(Bool.self, forKey: .isNew)
- self.isNew = isNewAccount ?? false
- }
-}
-
-enum DeviceState: Codable, Equatable {
- case loggedIn(StoredAccountData, StoredDeviceData)
- case loggedOut
- case revoked
-
- private enum LoggedInCodableKeys: String, CodingKey {
- case _0 = "account"
- case _1 = "device"
- }
-
- var isLoggedIn: Bool {
- switch self {
- case .loggedIn:
- return true
- case .loggedOut, .revoked:
- return false
- }
- }
-
- var accountData: StoredAccountData? {
- switch self {
- case let .loggedIn(accountData, _):
- return accountData
- case .loggedOut, .revoked:
- return nil
- }
- }
-
- var deviceData: StoredDeviceData? {
- switch self {
- case let .loggedIn(_, deviceData):
- return deviceData
- case .loggedOut, .revoked:
- return nil
- }
- }
-}
-
-struct StoredDeviceData: Codable, Equatable {
- /// Device creation date.
- var creationDate: Date
-
- /// Device identifier.
- var identifier: String
-
- /// Device name.
- var name: String
-
- /// Whether relay hijacks DNS from this device.
- var hijackDNS: Bool
-
- /// IPv4 address + mask assigned to device.
- var ipv4Address: IPAddressRange
-
- /// IPv6 address + mask assigned to device.
- var ipv6Address: IPAddressRange
-
- /// WireGuard key data.
- var wgKeyData: StoredWgKeyData
-
- /// Returns capitalized device name.
- var capitalizedName: String {
- name.capitalized
- }
-
- /// Fill in part of the structure that contains device related properties from `Device` struct.
- mutating func update(from device: Device) {
- identifier = device.id
- name = device.name
- creationDate = device.created
- hijackDNS = device.hijackDNS
- ipv4Address = device.ipv4Address
- ipv6Address = device.ipv6Address
- }
-}
-
struct StoredWgKeyData: Codable, Equatable {
/// Private key creation date.
var creationDate: Date
diff --git a/ios/MullvadVPN/TunnelManager/LoadTunnelConfigurationOperation.swift b/ios/MullvadVPN/TunnelManager/LoadTunnelConfigurationOperation.swift
index 89aa391965..43fdea1c97 100644
--- a/ios/MullvadVPN/TunnelManager/LoadTunnelConfigurationOperation.swift
+++ b/ios/MullvadVPN/TunnelManager/LoadTunnelConfigurationOperation.swift
@@ -30,7 +30,7 @@ class LoadTunnelConfigurationOperation: ResultOperation<Void> {
let settings = settingsResult.flattenValue()
let deviceState = deviceStateResult.flattenValue()
- interactor.setSettings(settings ?? TunnelSettingsV2(), persist: false)
+ interactor.setSettings(settings ?? LatestTunnelSettings(), persist: false)
interactor.setDeviceState(deviceState ?? .loggedOut, persist: false)
if let tunnel, deviceState == nil {
@@ -57,7 +57,7 @@ class LoadTunnelConfigurationOperation: ResultOperation<Void> {
finish(result: .success(()))
}
- private func readSettings() -> Result<TunnelSettingsV2?, Error> {
+ private func readSettings() -> Result<LatestTunnelSettings?, Error> {
Result { try SettingsManager.readSettings() }
.flatMapError { error in
if let error = error as? KeychainError, error == .itemNotFound {
diff --git a/ios/MullvadVPN/TunnelManager/SetAccountOperation.swift b/ios/MullvadVPN/TunnelManager/SetAccountOperation.swift
index edb0fec6a4..0ae6e8b5e6 100644
--- a/ios/MullvadVPN/TunnelManager/SetAccountOperation.swift
+++ b/ios/MullvadVPN/TunnelManager/SetAccountOperation.swift
@@ -201,7 +201,7 @@ class SetAccountOperation: ResultOperation<StoredAccountData?> {
)
// Reset tunnel settings.
- interactor.setSettings(TunnelSettingsV2(), persist: true)
+ interactor.setSettings(LatestTunnelSettings(), persist: true)
// Transition device state to logged in.
interactor.setDeviceState(.loggedIn(accountData, storedDeviceData), persist: true)
diff --git a/ios/MullvadVPN/TunnelManager/TunnelBlockObserver.swift b/ios/MullvadVPN/TunnelManager/TunnelBlockObserver.swift
index 24fea197f3..2e327299d4 100644
--- a/ios/MullvadVPN/TunnelManager/TunnelBlockObserver.swift
+++ b/ios/MullvadVPN/TunnelManager/TunnelBlockObserver.swift
@@ -16,7 +16,7 @@ final class TunnelBlockObserver: TunnelObserver {
_ deviceState: DeviceState,
_ previousDeviceState: DeviceState
) -> Void
- typealias DidUpdateTunnelSettingsHandler = (TunnelManager, TunnelSettingsV2) -> Void
+ typealias DidUpdateTunnelSettingsHandler = (TunnelManager, LatestTunnelSettings) -> Void
typealias DidFailWithErrorHandler = (TunnelManager, Error) -> Void
private let didLoadConfiguration: DidLoadConfigurationHandler?
@@ -55,7 +55,7 @@ final class TunnelBlockObserver: TunnelObserver {
didUpdateDeviceState?(manager, deviceState, previousDeviceState)
}
- func tunnelManager(_ manager: TunnelManager, didUpdateTunnelSettings tunnelSettings: TunnelSettingsV2) {
+ func tunnelManager(_ manager: TunnelManager, didUpdateTunnelSettings tunnelSettings: LatestTunnelSettings) {
didUpdateTunnelSettings?(manager, tunnelSettings)
}
diff --git a/ios/MullvadVPN/TunnelManager/TunnelInteractor.swift b/ios/MullvadVPN/TunnelManager/TunnelInteractor.swift
index 5a387b369f..ca42b56b52 100644
--- a/ios/MullvadVPN/TunnelManager/TunnelInteractor.swift
+++ b/ios/MullvadVPN/TunnelManager/TunnelInteractor.swift
@@ -27,11 +27,11 @@ protocol TunnelInteractor {
// MARK: - Configuration
var isConfigurationLoaded: Bool { get }
- var settings: TunnelSettingsV2 { get }
+ var settings: LatestTunnelSettings { get }
var deviceState: DeviceState { get }
func setConfigurationLoaded()
- func setSettings(_ settings: TunnelSettingsV2, persist: Bool)
+ func setSettings(_ settings: LatestTunnelSettings, persist: Bool)
func setDeviceState(_ deviceState: DeviceState, persist: Bool)
func handleRestError(_ error: Error)
diff --git a/ios/MullvadVPN/TunnelManager/TunnelManager.swift b/ios/MullvadVPN/TunnelManager/TunnelManager.swift
index b642dbf8ef..e04039df2f 100644
--- a/ios/MullvadVPN/TunnelManager/TunnelManager.swift
+++ b/ios/MullvadVPN/TunnelManager/TunnelManager.swift
@@ -68,7 +68,7 @@ final class TunnelManager: StorePaymentObserver {
private var _isConfigurationLoaded = false
private var _deviceState: DeviceState = .loggedOut
- private var _tunnelSettings = TunnelSettingsV2()
+ private var _tunnelSettings = LatestTunnelSettings()
private var _tunnel: Tunnel?
private var _tunnelStatus = TunnelStatus()
@@ -623,7 +623,7 @@ final class TunnelManager: StorePaymentObserver {
return _tunnelStatus
}
- var settings: TunnelSettingsV2 {
+ var settings: LatestTunnelSettings {
nslock.lock()
defer { nslock.unlock() }
@@ -764,7 +764,7 @@ final class TunnelManager: StorePaymentObserver {
lastDeviceCheck = deviceCheck
}
- fileprivate func setSettings(_ settings: TunnelSettingsV2, persist: Bool) {
+ fileprivate func setSettings(_ settings: LatestTunnelSettings, persist: Bool) {
nslock.lock()
defer { nslock.unlock() }
@@ -991,7 +991,7 @@ final class TunnelManager: StorePaymentObserver {
private func scheduleSettingsUpdate(
taskName: String,
- modificationBlock: @escaping (inout TunnelSettingsV2) -> Void,
+ modificationBlock: @escaping (inout LatestTunnelSettings) -> Void,
completionHandler: (() -> Void)?
) {
let operation = AsyncBlockOperation(dispatchQueue: internalQueue) {
@@ -1289,7 +1289,7 @@ private struct TunnelInteractorProxy: TunnelInteractor {
tunnelManager.isConfigurationLoaded
}
- var settings: TunnelSettingsV2 {
+ var settings: LatestTunnelSettings {
tunnelManager.settings
}
@@ -1301,7 +1301,7 @@ private struct TunnelInteractorProxy: TunnelInteractor {
tunnelManager.setConfigurationLoaded()
}
- func setSettings(_ settings: TunnelSettingsV2, persist: Bool) {
+ func setSettings(_ settings: LatestTunnelSettings, persist: Bool) {
tunnelManager.setSettings(settings, persist: persist)
}
diff --git a/ios/MullvadVPN/TunnelManager/TunnelObserver.swift b/ios/MullvadVPN/TunnelManager/TunnelObserver.swift
index f53461fb70..af5775cca9 100644
--- a/ios/MullvadVPN/TunnelManager/TunnelObserver.swift
+++ b/ios/MullvadVPN/TunnelManager/TunnelObserver.swift
@@ -16,6 +16,6 @@ protocol TunnelObserver: AnyObject {
didUpdateDeviceState deviceState: DeviceState,
previousDeviceState: DeviceState
)
- func tunnelManager(_ manager: TunnelManager, didUpdateTunnelSettings tunnelSettings: TunnelSettingsV2)
+ func tunnelManager(_ manager: TunnelManager, didUpdateTunnelSettings tunnelSettings: LatestTunnelSettings)
func tunnelManager(_ manager: TunnelManager, didFailWithError error: Error)
}
diff --git a/ios/MullvadVPN/View controllers/Preferences/PreferencesDataSource.swift b/ios/MullvadVPN/View controllers/Preferences/PreferencesDataSource.swift
index be24b99d53..8927d2107c 100644
--- a/ios/MullvadVPN/View controllers/Preferences/PreferencesDataSource.swift
+++ b/ios/MullvadVPN/View controllers/Preferences/PreferencesDataSource.swift
@@ -243,7 +243,7 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
}
}
- func update(from tunnelSettings: TunnelSettingsV2) {
+ func update(from tunnelSettings: LatestTunnelSettings) {
let newViewModel = PreferencesViewModel(from: tunnelSettings)
let mergedViewModel = viewModel.merged(newViewModel)
diff --git a/ios/MullvadVPN/View controllers/Preferences/PreferencesInteractor.swift b/ios/MullvadVPN/View controllers/Preferences/PreferencesInteractor.swift
index 3c8371ad3f..7bd7a80051 100644
--- a/ios/MullvadVPN/View controllers/Preferences/PreferencesInteractor.swift
+++ b/ios/MullvadVPN/View controllers/Preferences/PreferencesInteractor.swift
@@ -14,10 +14,10 @@ final class PreferencesInteractor {
private var tunnelObserver: TunnelObserver?
private let relayCacheTracker: RelayCacheTracker
- var tunnelSettingsDidChange: ((TunnelSettingsV2) -> Void)?
+ var tunnelSettingsDidChange: ((LatestTunnelSettings) -> Void)?
var cachedRelaysDidChange: ((CachedRelays) -> Void)?
- var tunnelSettings: TunnelSettingsV2 {
+ var tunnelSettings: LatestTunnelSettings {
tunnelManager.settings
}
diff --git a/ios/MullvadVPN/View controllers/Preferences/PreferencesViewModel.swift b/ios/MullvadVPN/View controllers/Preferences/PreferencesViewModel.swift
index d8b8266ecc..2c68adb97b 100644
--- a/ios/MullvadVPN/View controllers/Preferences/PreferencesViewModel.swift
+++ b/ios/MullvadVPN/View controllers/Preferences/PreferencesViewModel.swift
@@ -154,7 +154,7 @@ struct PreferencesViewModel: Equatable {
}
}
- init(from tunnelSettings: TunnelSettingsV2 = TunnelSettingsV2()) {
+ init(from tunnelSettings: LatestTunnelSettings = LatestTunnelSettings()) {
let dnsSettings = tunnelSettings.dnsSettings
blockAdvertising = dnsSettings.blockingOptions.contains(.blockAdvertising)
blockTracking = dnsSettings.blockingOptions.contains(.blockTracking)
diff --git a/ios/PacketTunnel/PacketTunnelConfiguration.swift b/ios/PacketTunnel/PacketTunnelConfiguration.swift
index 08eba32da2..7cab5d3e22 100644
--- a/ios/PacketTunnel/PacketTunnelConfiguration.swift
+++ b/ios/PacketTunnel/PacketTunnelConfiguration.swift
@@ -14,7 +14,7 @@ import WireGuardKit
struct PacketTunnelConfiguration {
var deviceState: DeviceState
- var tunnelSettings: TunnelSettingsV2
+ var tunnelSettings: LatestTunnelSettings
var selectorResult: RelaySelectorResult
}