diff options
39 files changed, 838 insertions, 407 deletions
diff --git a/ios/MullvadTypes/Location.swift b/ios/MullvadTypes/Location.swift new file mode 100644 index 0000000000..06e44a91d6 --- /dev/null +++ b/ios/MullvadTypes/Location.swift @@ -0,0 +1,39 @@ +// +// Location.swift +// MullvadTypes +// +// Created by pronebird on 12/02/2020. +// Copyright © 2020 Mullvad VPN AB. All rights reserved. +// + +import struct CoreLocation.CLLocationCoordinate2D +import Foundation + +public struct Location: Codable, Equatable { + public var country: String + public var countryCode: String + public var city: String + public var cityCode: String + public var latitude: Double + public var longitude: Double + + public var geoCoordinate: CLLocationCoordinate2D { + return CLLocationCoordinate2D(latitude: latitude, longitude: longitude) + } + + public init( + country: String, + countryCode: String, + city: String, + cityCode: String, + latitude: Double, + longitude: Double + ) { + self.country = country + self.countryCode = countryCode + self.city = city + self.cityCode = cityCode + self.latitude = latitude + self.longitude = longitude + } +} diff --git a/ios/MullvadTypes/MullvadEndpoint.swift b/ios/MullvadTypes/MullvadEndpoint.swift new file mode 100644 index 0000000000..82e122a32f --- /dev/null +++ b/ios/MullvadTypes/MullvadEndpoint.swift @@ -0,0 +1,34 @@ +// +// MullvadEndpoint.swift +// MullvadTypes +// +// Created by pronebird on 12/06/2019. +// Copyright © 2019 Mullvad VPN AB. All rights reserved. +// + +import Foundation +import struct Network.IPv4Address +import struct Network.IPv6Address + +/// Contains server data needed to connect to a single mullvad endpoint. +public struct MullvadEndpoint: Equatable, Codable { + public let ipv4Relay: IPv4Endpoint + public let ipv6Relay: IPv6Endpoint? + public let ipv4Gateway: IPv4Address + public let ipv6Gateway: IPv6Address + public let publicKey: Data + + public init( + ipv4Relay: IPv4Endpoint, + ipv6Relay: IPv6Endpoint? = nil, + ipv4Gateway: IPv4Address, + ipv6Gateway: IPv6Address, + publicKey: Data + ) { + self.ipv4Relay = ipv4Relay + self.ipv6Relay = ipv6Relay + self.ipv4Gateway = ipv4Gateway + self.ipv6Gateway = ipv6Gateway + self.publicKey = publicKey + } +} diff --git a/ios/MullvadTypes/RelayConstraint.swift b/ios/MullvadTypes/RelayConstraint.swift new file mode 100644 index 0000000000..5c12f1d8d7 --- /dev/null +++ b/ios/MullvadTypes/RelayConstraint.swift @@ -0,0 +1,65 @@ +// +// RelayConstraint.swift +// MullvadTypes +// +// Created by pronebird on 21/10/2022. +// Copyright © 2022 Mullvad VPN AB. All rights reserved. +// + +import Foundation + +private let anyConstraint = "any" + +public enum RelayConstraint<T>: Codable, Equatable, + CustomDebugStringConvertible where T: Codable & Equatable +{ + case any + case only(T) + + public var value: T? { + if case let .only(value) = self { + return value + } else { + return nil + } + } + + public var debugDescription: String { + var output = "RelayConstraint." + switch self { + case .any: + output += "any" + case let .only(value): + output += "only(\(String(reflecting: value)))" + } + return output + } + + private struct OnlyRepr: Codable { + var only: T + } + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + + let decoded = try? container.decode(String.self) + if decoded == anyConstraint { + self = .any + } else { + let onlyVariant = try container.decode(OnlyRepr.self) + + self = .only(onlyVariant.only) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + + switch self { + case .any: + try container.encode(anyConstraint) + case let .only(inner): + try container.encode(OnlyRepr(only: inner)) + } + } +} diff --git a/ios/MullvadTypes/RelayConstraints.swift b/ios/MullvadTypes/RelayConstraints.swift new file mode 100644 index 0000000000..55de62f9b3 --- /dev/null +++ b/ios/MullvadTypes/RelayConstraints.swift @@ -0,0 +1,24 @@ +// +// RelayConstraint.swift +// MullvadTypes +// +// Created by pronebird on 10/06/2019. +// Copyright © 2019 Mullvad VPN AB. All rights reserved. +// + +import Foundation + +public struct RelayConstraints: Codable, Equatable, CustomDebugStringConvertible { + public var location: RelayConstraint<RelayLocation> + + public var debugDescription: String { + var output = "RelayConstraints { " + output += "location: \(String(reflecting: location))" + output += " }" + return output + } + + public init(location: RelayConstraint<RelayLocation> = .only(.country("se"))) { + self.location = location + } +} diff --git a/ios/MullvadVPN/RelayConstraints.swift b/ios/MullvadTypes/RelayLocation.swift index e6637f4fd3..3018d157c4 100644 --- a/ios/MullvadVPN/RelayConstraints.swift +++ b/ios/MullvadTypes/RelayLocation.swift @@ -1,75 +1,19 @@ // -// RelayConstraint.swift -// MullvadVPN +// RelayLocation.swift +// MullvadTypes // -// Created by pronebird on 10/06/2019. -// Copyright © 2019 Mullvad VPN AB. All rights reserved. +// Created by pronebird on 21/10/2022. +// Copyright © 2022 Mullvad VPN AB. All rights reserved. // import Foundation -private let kRelayConstraintAnyRepr = "any" - -enum RelayConstraint<T>: Codable, Equatable where T: Codable & Equatable { - case any - case only(T) - - var value: T? { - if case let .only(value) = self { - return value - } else { - return nil - } - } - - private struct OnlyRepr: Codable { - var only: T - } - - init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - let decoded = try? container.decode(String.self) - if decoded == kRelayConstraintAnyRepr { - self = .any - } else { - let onlyVariant = try container.decode(OnlyRepr.self) - - self = .only(onlyVariant.only) - } - } - - func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch self { - case .any: - try container.encode(kRelayConstraintAnyRepr) - case let .only(inner): - try container.encode(OnlyRepr(only: inner)) - } - } -} - -extension RelayConstraint: CustomDebugStringConvertible { - var debugDescription: String { - var output = "RelayConstraint." - switch self { - case .any: - output += "any" - case let .only(value): - output += "only(\(String(reflecting: value)))" - } - return output - } -} - -enum RelayLocation: Codable, Hashable { +public enum RelayLocation: Codable, Hashable, CustomDebugStringConvertible { case country(String) case city(String, String) case hostname(String, String, String) - init?(dashSeparatedString: String) { + public init?(dashSeparatedString: String) { let components = dashSeparatedString.split(separator: "-", maxSplits: 2).map(String.init) switch components.count { @@ -84,9 +28,8 @@ enum RelayLocation: Codable, Hashable { } } - init(from decoder: Decoder) throws { + public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - let components = try container.decode([String].self) switch components.count { @@ -104,7 +47,7 @@ enum RelayLocation: Codable, Hashable { } } - func encode(to encoder: Encoder) throws { + public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() switch self { @@ -120,7 +63,7 @@ enum RelayLocation: Codable, Hashable { } /// A list of `RelayLocation` items preceding the given one in the relay tree - var ascendants: [RelayLocation] { + public var ascendants: [RelayLocation] { switch self { case let .hostname(country, city, _): return [.country(country), .city(country, city)] @@ -132,10 +75,8 @@ enum RelayLocation: Codable, Hashable { return [] } } -} -extension RelayLocation: CustomDebugStringConvertible { - var debugDescription: String { + public var debugDescription: String { var output = "RelayLocation." switch self { @@ -154,7 +95,7 @@ extension RelayLocation: CustomDebugStringConvertible { return output } - var stringRepresentation: String { + public var stringRepresentation: String { switch self { case let .country(country): return country @@ -165,16 +106,3 @@ extension RelayLocation: CustomDebugStringConvertible { } } } - -struct RelayConstraints: Codable, Equatable { - var location: RelayConstraint<RelayLocation> = .only(.country("se")) -} - -extension RelayConstraints: CustomDebugStringConvertible { - var debugDescription: String { - var output = "RelayConstraints { " - output += "location: \(String(reflecting: location))" - output += " }" - return output - } -} diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj index 0d86521498..b2a17184f1 100644 --- a/ios/MullvadVPN.xcodeproj/project.pbxproj +++ b/ios/MullvadVPN.xcodeproj/project.pbxproj @@ -12,8 +12,6 @@ 062B45B428FD508C00746E77 /* Logging in Frameworks */ = {isa = PBXBuildFile; productRef = 062B45B328FD508C00746E77 /* Logging */; }; 062B45BC28FD8C3B00746E77 /* RESTDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 062B45BB28FD8C3B00746E77 /* RESTDefaults.swift */; }; 062B45C228FE980000746E77 /* api-ip-address.json in Resources */ = {isa = PBXBuildFile; fileRef = 062B45C128FE97FF00746E77 /* api-ip-address.json */; }; - 063687B028EB083800BE7161 /* ProxyURLRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 063687AF28EB083800BE7161 /* ProxyURLRequest.swift */; }; - 063687B228EB083F00BE7161 /* ProxyURLRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 063687AF28EB083800BE7161 /* ProxyURLRequest.swift */; }; 063687BA28EB234F00BE7161 /* PacketTunnelTransport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 063687B928EB234F00BE7161 /* PacketTunnelTransport.swift */; }; 063F026628FFE11C001FA09F /* RESTCreateApplePaymentResponse+Localization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06FAE67828F83CA50033DD93 /* RESTCreateApplePaymentResponse+Localization.swift */; }; 063F026729002768001FA09F /* Cancellable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06AC113628F83FD70037AF9A /* Cancellable.swift */; }; @@ -62,7 +60,6 @@ 06D9845428F99133003AABE9 /* libMullvadLogging.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 581943D628F800C900B0CB5E /* libMullvadLogging.a */; }; 06D9845A28F9918C003AABE9 /* Logging in Frameworks */ = {isa = PBXBuildFile; productRef = 06D9845928F9918C003AABE9 /* Logging */; }; 06D9846328F9A049003AABE9 /* libMullvadLogging.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 581943D628F800C900B0CB5E /* libMullvadLogging.a */; }; - 5804BEBD28F811F600B49CA5 /* PacketTunnelStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 585DA89826B0329200B8C587 /* PacketTunnelStatus.swift */; }; 5806767C27048E9B00C858CB /* PacketTunnelProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58CE5E7B224146470008646E /* PacketTunnelProvider.swift */; }; 5807483B27DB8A980020ECBF /* WireGuardKitTypes in Frameworks */ = {isa = PBXBuildFile; productRef = 5807483A27DB8A980020ECBF /* WireGuardKitTypes */; }; 5807E2C02432038B00F5FF30 /* String+Split.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5807E2BF2432038B00F5FF30 /* String+Split.swift */; }; @@ -115,8 +112,6 @@ 5838318B27C40A3900000571 /* Pinger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5838318A27C40A3900000571 /* Pinger.swift */; }; 583DA21425FA4B5C00318683 /* LocationDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 583DA21325FA4B5C00318683 /* LocationDataSource.swift */; }; 583E1E2C2848E1A1004838B3 /* WireGuardKitTypes in Frameworks */ = {isa = PBXBuildFile; productRef = 583E1E2B2848E1A1004838B3 /* WireGuardKitTypes */; }; - 5840250422B11AB700E4CFEC /* MullvadEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5840250322B11AB700E4CFEC /* MullvadEndpoint.swift */; }; - 5840250522B11AB700E4CFEC /* MullvadEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5840250322B11AB700E4CFEC /* MullvadEndpoint.swift */; }; 58421030282D8A3C00F24E46 /* UpdateAccountDataOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5842102F282D8A3C00F24E46 /* UpdateAccountDataOperation.swift */; }; 58421032282E42B000F24E46 /* UpdateDeviceDataOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58421031282E42B000F24E46 /* UpdateDeviceDataOperation.swift */; }; 58421034282E4B1500F24E46 /* TunnelSettingsV2+REST.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58421033282E4B1500F24E46 /* TunnelSettingsV2+REST.swift */; }; @@ -128,19 +123,12 @@ 584D26C2270C8542004EA533 /* SettingsStaticTextFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 584D26C1270C8542004EA533 /* SettingsStaticTextFooterView.swift */; }; 584D26C4270C855B004EA533 /* PreferencesDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 584D26C3270C855A004EA533 /* PreferencesDataSource.swift */; }; 584D26C6270C8741004EA533 /* SettingsDNSTextCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 584D26C5270C8741004EA533 /* SettingsDNSTextCell.swift */; }; - 584E96BC240FD4DA00D3334F /* Location.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58A1AA8623F43901009F7EA6 /* Location.swift */; }; - 584E96BD240FD4DA00D3334F /* Location.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58A1AA8623F43901009F7EA6 /* Location.swift */; }; - 584E96BE240FD4DB00D3334F /* Location.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58A1AA8623F43901009F7EA6 /* Location.swift */; }; 584EBDBD2747C98F00A0C9FD /* NSAttributedString+Markdown.swift in Sources */ = {isa = PBXBuildFile; fileRef = 584EBDBC2747C98F00A0C9FD /* NSAttributedString+Markdown.swift */; }; 5857F24324C8662600CF6F47 /* SelectLocationHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5857F24224C8662600CF6F47 /* SelectLocationHeaderView.swift */; }; 5857F24724C882D700CF6F47 /* SelectLocationNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5857F24624C882D700CF6F47 /* SelectLocationNavigationController.swift */; }; 585B4B8726D9098900555C4C /* TunnelStatusNotificationProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58A94AE326CFD945001CB97C /* TunnelStatusNotificationProvider.swift */; }; 585C6F4C28F80745005196BE /* Logging in Frameworks */ = {isa = PBXBuildFile; productRef = 585C6F4B28F80745005196BE /* Logging */; }; 585CA70F25F8C44600B47C62 /* UIMetrics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 585CA70E25F8C44600B47C62 /* UIMetrics.swift */; }; - 585DA89326B0323E00B8C587 /* TunnelProviderMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 585DA89226B0323E00B8C587 /* TunnelProviderMessage.swift */; }; - 585DA89426B0323E00B8C587 /* TunnelProviderMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 585DA89226B0323E00B8C587 /* TunnelProviderMessage.swift */; }; - 585DA89926B0329200B8C587 /* PacketTunnelStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 585DA89826B0329200B8C587 /* PacketTunnelStatus.swift */; }; - 585DA89A26B0329200B8C587 /* PacketTunnelStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 585DA89826B0329200B8C587 /* PacketTunnelStatus.swift */; }; 585E820327F3285E00939F0E /* SendAppStoreReceiptOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 585E820227F3285E00939F0E /* SendAppStoreReceiptOperation.swift */; }; 5862805422428EF100F5A6E1 /* TranslucentButtonBlurView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5862805322428EF100F5A6E1 /* TranslucentButtonBlurView.swift */; }; 5868585524054096000B8131 /* AppButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5868585424054096000B8131 /* AppButton.swift */; }; @@ -163,9 +151,6 @@ 587425C12299833500CA2045 /* RootContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587425C02299833500CA2045 /* RootContainerViewController.swift */; }; 5875960A26F371FC00BF6711 /* Tunnel+Messaging.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5875960926F371FC00BF6711 /* Tunnel+Messaging.swift */; }; 5877D70F282137E8002FCFC7 /* SettingsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58FF2C02281BDE02009EF542 /* SettingsManager.swift */; }; - 58781CC922AE7CA8009B9D8E /* RelayConstraints.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58781CC822AE7CA8009B9D8E /* RelayConstraints.swift */; }; - 58781CCE22AE8918009B9D8E /* RelayConstraints.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58781CC822AE7CA8009B9D8E /* RelayConstraints.swift */; }; - 58781CD522AFBA39009B9D8E /* RelaySelector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58781CD422AFBA39009B9D8E /* RelaySelector.swift */; }; 587988C728A2A01F00E3DF54 /* AccountDataThrottling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587988C628A2A01F00E3DF54 /* AccountDataThrottling.swift */; }; 587A01FC23F1F0BE00B68763 /* SimulatorTunnelProviderHost.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587A01FB23F1F0BE00B68763 /* SimulatorTunnelProviderHost.swift */; }; 587AD7C623421D7000E93A53 /* TunnelSettingsV1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587AD7C523421D7000E93A53 /* TunnelSettingsV1.swift */; }; @@ -175,8 +160,6 @@ 587B753D2666468F00DEF7E9 /* NotificationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B753C2666468F00DEF7E9 /* NotificationController.swift */; }; 587B753F2668E5A700DEF7E9 /* NotificationContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B753E2668E5A700DEF7E9 /* NotificationContainerView.swift */; }; 587B75412668FD7800DEF7E9 /* AccountExpiryNotificationProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B75402668FD7700DEF7E9 /* AccountExpiryNotificationProvider.swift */; }; - 587C575326D2615F005EF767 /* PacketTunnelOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587C575226D2615F005EF767 /* PacketTunnelOptions.swift */; }; - 587C575426D2615F005EF767 /* PacketTunnelOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587C575226D2615F005EF767 /* PacketTunnelOptions.swift */; }; 587CBFE322807F530028DED3 /* UIColor+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587CBFE222807F530028DED3 /* UIColor+Helpers.swift */; }; 587D96742886D87C00CD8F1C /* DeviceManagementContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587D96732886D87C00CD8F1C /* DeviceManagementContentView.swift */; }; 587D9676288989DB00CD8F1C /* NSLayoutConstraint+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587D9675288989DB00CD8F1C /* NSLayoutConstraint+Helpers.swift */; }; @@ -203,6 +186,26 @@ 5896AE86246D6AD8005B36CB /* CustomDateComponentsFormattingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5896AE85246D6AD8005B36CB /* CustomDateComponentsFormattingTests.swift */; }; 5896AE88246D7FAF005B36CB /* CustomDateComponentsFormatting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5896AE83246D5889005B36CB /* CustomDateComponentsFormatting.swift */; }; 5896CEF226972DEB00B0FAE8 /* AccountContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5896CEF126972DEB00B0FAE8 /* AccountContentView.swift */; }; + 5898D29029017BEE00EB5EBA /* PacketTunnelOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587C575226D2615F005EF767 /* PacketTunnelOptions.swift */; }; + 5898D29129017C3100EB5EBA /* TunnelProviderMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 585DA89226B0323E00B8C587 /* TunnelProviderMessage.swift */; }; + 5898D29229017CA000EB5EBA /* ProxyURLRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 063687AF28EB083800BE7161 /* ProxyURLRequest.swift */; }; + 5898D29329017CFD00EB5EBA /* Location.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58A1AA8623F43901009F7EA6 /* Location.swift */; }; + 5898D29F29017DD000EB5EBA /* RelaySelector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58781CD422AFBA39009B9D8E /* RelaySelector.swift */; }; + 5898D2A129017EF400EB5EBA /* libRelaySelector.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5898D29829017DAC00EB5EBA /* libRelaySelector.a */; }; + 5898D2A22901801000EB5EBA /* MullvadREST.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06799ABC28F98E1D00ACD94E /* MullvadREST.framework */; }; + 5898D2A32901807500EB5EBA /* MullvadEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5840250322B11AB700E4CFEC /* MullvadEndpoint.swift */; }; + 5898D2A52901815E00EB5EBA /* RelaySelectorResult+PacketTunnelRelay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5898D2A42901815E00EB5EBA /* RelaySelectorResult+PacketTunnelRelay.swift */; }; + 5898D2A62901820C00EB5EBA /* PacketTunnelStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 585DA89826B0329200B8C587 /* PacketTunnelStatus.swift */; }; + 5898D2A8290182B000EB5EBA /* TunnelProviderReply.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5898D2A7290182B000EB5EBA /* TunnelProviderReply.swift */; }; + 5898D2A92901844E00EB5EBA /* libRelaySelector.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5898D29829017DAC00EB5EBA /* libRelaySelector.a */; }; + 5898D2AA2901844E00EB5EBA /* libTunnelProviderMessaging.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5898D28929017BD400EB5EBA /* libTunnelProviderMessaging.a */; }; + 5898D2AB2901845400EB5EBA /* libRelaySelector.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5898D29829017DAC00EB5EBA /* libRelaySelector.a */; }; + 5898D2AC2901845400EB5EBA /* libTunnelProviderMessaging.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5898D28929017BD400EB5EBA /* libTunnelProviderMessaging.a */; }; + 5898D2AE290185D200EB5EBA /* ProxyURLResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5898D2AD290185D200EB5EBA /* ProxyURLResponse.swift */; }; + 5898D2B32902A8F000EB5EBA /* RelayLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5898D2AF2902A67C00EB5EBA /* RelayLocation.swift */; }; + 5898D2B42902A8F000EB5EBA /* RelayConstraints.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58781CC822AE7CA8009B9D8E /* RelayConstraints.swift */; }; + 5898D2B52902A8F000EB5EBA /* RelayConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5898D2B12902A6DE00EB5EBA /* RelayConstraint.swift */; }; + 5898D2B72902A9EA00EB5EBA /* PacketTunnelRelay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5898D2B62902A9EA00EB5EBA /* PacketTunnelRelay.swift */; }; 589A454C28DDF5E100565204 /* Swizzle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 589A454B28DDF5E100565204 /* Swizzle.swift */; }; 589A455628E094B300565204 /* libOperations.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58E5126528DDF04200B0BCDE /* libOperations.a */; }; 589A455C28E094BF00565204 /* OperationSmokeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58DF5B7E2852778600E92647 /* OperationSmokeTests.swift */; }; @@ -221,12 +224,8 @@ 58AEEF652344A36000C9BBD5 /* KeychainError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58AEEF642344A36000C9BBD5 /* KeychainError.swift */; }; 58AEEF662344A37400C9BBD5 /* KeychainError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58AEEF642344A36000C9BBD5 /* KeychainError.swift */; }; 58B0A2A8238EE68200BC001D /* RelaySelectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 584B26F3237434D00073B10E /* RelaySelectorTests.swift */; }; - 58B0A2A9238EE6A100BC001D /* RelayConstraints.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58781CC822AE7CA8009B9D8E /* RelayConstraints.swift */; }; - 58B0A2AA238EE6A900BC001D /* RelaySelector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58781CD422AFBA39009B9D8E /* RelaySelector.swift */; }; - 58B0A2AD238EE6EC00BC001D /* MullvadEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5840250322B11AB700E4CFEC /* MullvadEndpoint.swift */; }; 58B3F30F2742708B00A2DD38 /* HeaderBarButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58B3F30E2742708B00A2DD38 /* HeaderBarButton.swift */; }; 58B43C1925F77DB60002C8C3 /* ConnectContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58B43C1825F77DB60002C8C3 /* ConnectContentView.swift */; }; - 58B67B482602079E008EF58E /* RelaySelector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58781CD422AFBA39009B9D8E /* RelaySelector.swift */; }; 58B93A1326C3F13600A55733 /* TunnelState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58B93A1226C3F13600A55733 /* TunnelState.swift */; }; 58B993B12608A34500BA7811 /* LoginContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58B993B02608A34500BA7811 /* LoginContentView.swift */; }; 58B9EB152489139B00095626 /* DisplayChainedError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58B9EB142489139B00095626 /* DisplayChainedError.swift */; }; @@ -452,6 +451,24 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5898D28729017BD300EB5EBA /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5898D29629017DAC00EB5EBA /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 58CE5E85224146470008646E /* Embed Foundation Extensions */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -489,7 +506,6 @@ 06AC114028F841390037AF9A /* AddressCacheTracker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddressCacheTracker.swift; sourceTree = "<group>"; }; 06AC114128F8413A0037AF9A /* AddressCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddressCache.swift; sourceTree = "<group>"; }; 06AC115628F848D00037AF9A /* IPAddress+Codable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "IPAddress+Codable.swift"; sourceTree = "<group>"; }; - 06AC115B28F84B2B0037AF9A /* Network.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Network.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Network.framework; sourceTree = DEVELOPER_DIR; }; 06FAE66528F83CA30033DD93 /* RESTURLSession.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RESTURLSession.swift; sourceTree = "<group>"; }; 06FAE66628F83CA30033DD93 /* RESTResponseHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RESTResponseHandler.swift; sourceTree = "<group>"; }; 06FAE66728F83CA30033DD93 /* RESTProxyFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RESTProxyFactory.swift; sourceTree = "<group>"; }; @@ -645,6 +661,14 @@ 5896AE83246D5889005B36CB /* CustomDateComponentsFormatting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomDateComponentsFormatting.swift; sourceTree = "<group>"; }; 5896AE85246D6AD8005B36CB /* CustomDateComponentsFormattingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomDateComponentsFormattingTests.swift; sourceTree = "<group>"; }; 5896CEF126972DEB00B0FAE8 /* AccountContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountContentView.swift; sourceTree = "<group>"; }; + 5898D28929017BD400EB5EBA /* libTunnelProviderMessaging.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libTunnelProviderMessaging.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 5898D29829017DAC00EB5EBA /* libRelaySelector.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRelaySelector.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 5898D2A42901815E00EB5EBA /* RelaySelectorResult+PacketTunnelRelay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RelaySelectorResult+PacketTunnelRelay.swift"; sourceTree = "<group>"; }; + 5898D2A7290182B000EB5EBA /* TunnelProviderReply.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelProviderReply.swift; sourceTree = "<group>"; }; + 5898D2AD290185D200EB5EBA /* ProxyURLResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProxyURLResponse.swift; sourceTree = "<group>"; }; + 5898D2AF2902A67C00EB5EBA /* RelayLocation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayLocation.swift; sourceTree = "<group>"; }; + 5898D2B12902A6DE00EB5EBA /* RelayConstraint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayConstraint.swift; sourceTree = "<group>"; }; + 5898D2B62902A9EA00EB5EBA /* PacketTunnelRelay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PacketTunnelRelay.swift; sourceTree = "<group>"; }; 589A454B28DDF5E100565204 /* Swizzle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Swizzle.swift; sourceTree = "<group>"; }; 589A455228E094B300565204 /* OperationsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OperationsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 589D28772846250500F9A7B3 /* OperationCondition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OperationCondition.swift; sourceTree = "<group>"; }; @@ -785,6 +809,22 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5898D28629017BD300EB5EBA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 5898D2A129017EF400EB5EBA /* libRelaySelector.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5898D29529017DAC00EB5EBA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 5898D2A22901801000EB5EBA /* MullvadREST.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 589A454F28E094B300565204 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -807,6 +847,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 5898D2A92901844E00EB5EBA /* libRelaySelector.a in Frameworks */, + 5898D2AA2901844E00EB5EBA /* libTunnelProviderMessaging.a in Frameworks */, 06D9845A28F9918C003AABE9 /* Logging in Frameworks */, 58AC829428F803A200181C40 /* libMullvadLogging.a in Frameworks */, 06799AD128F98E1D00ACD94E /* MullvadREST.framework in Frameworks */, @@ -821,6 +863,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 5898D2AB2901845400EB5EBA /* libRelaySelector.a in Frameworks */, + 5898D2AC2901845400EB5EBA /* libTunnelProviderMessaging.a in Frameworks */, 062B45B428FD508C00746E77 /* Logging in Frameworks */, 06D9846328F9A049003AABE9 /* libMullvadLogging.a in Frameworks */, 062B45AE28FD503000746E77 /* WireGuardKit in Frameworks */, @@ -907,14 +951,6 @@ path = MullvadREST; sourceTree = "<group>"; }; - 0E15C74FDCF763609B367486 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 06AC115B28F84B2B0037AF9A /* Network.framework */, - ); - name = Frameworks; - sourceTree = "<group>"; - }; 580F8B88281A79A7002E0998 /* SettingsManager */ = { isa = PBXGroup; children = ( @@ -953,6 +989,11 @@ 58E511E028DDB7F100B0BCDE /* WrappingError.swift */, 58E511E328DDDE8900B0BCDE /* CustomErrorDescriptionProtocol.swift */, 58E511EA28DDE18400B0BCDE /* Error+Chain.swift */, + 58A1AA8623F43901009F7EA6 /* Location.swift */, + 5840250322B11AB700E4CFEC /* MullvadEndpoint.swift */, + 5898D2B12902A6DE00EB5EBA /* RelayConstraint.swift */, + 58781CC822AE7CA8009B9D8E /* RelayConstraints.swift */, + 5898D2AF2902A67C00EB5EBA /* RelayLocation.swift */, ); path = MullvadTypes; sourceTree = "<group>"; @@ -963,8 +1004,6 @@ 588527B1276B3F0700BAA373 /* LoadTunnelConfigurationOperation.swift */, 58F2E147276A307400A79513 /* MapConnectionStatusOperation.swift */, 58161C9B28352F850028ECFD /* MigrateSettingsOperation.swift */, - 587C575226D2615F005EF767 /* PacketTunnelOptions.swift */, - 585DA89826B0329200B8C587 /* PacketTunnelStatus.swift */, 584B17AA27637DE40057F3B8 /* ReconnectTunnelOperation.swift */, 58F2E14B276A61C000A79513 /* RotateKeyOperation.swift */, 586E54FA27A2DF6D0029B88B /* SendTunnelProviderMessageOperation.swift */, @@ -977,8 +1016,6 @@ 5835B7CB233B76CB0096D79F /* TunnelManager.swift */, 5820676326E771DB00655B05 /* TunnelManagerErrors.swift */, 5823FA5326CE49F600283BF8 /* TunnelObserver.swift */, - 585DA89226B0323E00B8C587 /* TunnelProviderMessage.swift */, - 063687AF28EB083800BE7161 /* ProxyURLRequest.swift */, 58B93A1226C3F13600A55733 /* TunnelState.swift */, 5842102F282D8A3C00F24E46 /* UpdateAccountDataOperation.swift */, 58421031282E42B000F24E46 /* UpdateDeviceDataOperation.swift */, @@ -1036,6 +1073,29 @@ path = Notifications; sourceTree = "<group>"; }; + 5898D28A29017BD400EB5EBA /* TunnelProviderMessaging */ = { + isa = PBXGroup; + children = ( + 587C575226D2615F005EF767 /* PacketTunnelOptions.swift */, + 585DA89826B0329200B8C587 /* PacketTunnelStatus.swift */, + 5898D2B62902A9EA00EB5EBA /* PacketTunnelRelay.swift */, + 063687AF28EB083800BE7161 /* ProxyURLRequest.swift */, + 5898D2AD290185D200EB5EBA /* ProxyURLResponse.swift */, + 5898D2A42901815E00EB5EBA /* RelaySelectorResult+PacketTunnelRelay.swift */, + 585DA89226B0323E00B8C587 /* TunnelProviderMessage.swift */, + 5898D2A7290182B000EB5EBA /* TunnelProviderReply.swift */, + ); + path = TunnelProviderMessaging; + sourceTree = "<group>"; + }; + 5898D29929017DAC00EB5EBA /* RelaySelector */ = { + isa = PBXGroup; + children = ( + 58781CD422AFBA39009B9D8E /* RelaySelector.swift */, + ); + path = RelaySelector; + sourceTree = "<group>"; + }; 589A454A28DDF59B00565204 /* Shared */ = { isa = PBXGroup; children = ( @@ -1084,7 +1144,6 @@ 58F3C0A824A50C0E003E76BE /* Assets */, 58ECD29023F178FD004298B6 /* Configurations */, 063F02742902B63F001FA09F /* RelayCache */, - 0E15C74FDCF763609B367486 /* Frameworks */, 582CFEE1269448160072883A /* Localizations */, 589A454A28DDF59B00565204 /* Shared */, 58CE5E62224146200008646E /* MullvadVPN */, @@ -1093,6 +1152,8 @@ 581943D728F800C900B0CB5E /* MullvadLogging */, 581943F228F8014500B0CB5E /* MullvadTypes */, 06799ABD28F98E1D00ACD94E /* MullvadREST */, + 5898D29929017DAC00EB5EBA /* RelaySelector */, + 5898D28A29017BD400EB5EBA /* TunnelProviderMessaging */, 58E5126628DDF04200B0BCDE /* Operations */, 589A455328E094B300565204 /* OperationsTests */, 58CE5E7A224146470008646E /* PacketTunnel */, @@ -1113,6 +1174,8 @@ 581943F128F8014500B0CB5E /* libMullvadTypes.a */, 06799ABC28F98E1D00ACD94E /* MullvadREST.framework */, 063F02732902B63F001FA09F /* RelayCache.framework */, + 5898D28929017BD400EB5EBA /* libTunnelProviderMessaging.a */, + 5898D29829017DAC00EB5EBA /* libRelaySelector.a */, ); name = Products; sourceTree = "<group>"; @@ -1167,11 +1230,9 @@ 58AEEF642344A36000C9BBD5 /* KeychainError.swift */, 58727282265D173C00F315B2 /* LaunchScreen.storyboard */, 58E20770274672CA00DE5D77 /* LaunchViewController.swift */, - 58A1AA8623F43901009F7EA6 /* Location.swift */, 583DA21325FA4B5C00318683 /* LocationDataSource.swift */, 58B993B02608A34500BA7811 /* LoginContentView.swift */, 58CE5E65224146200008646E /* LoginViewController.swift */, - 5840250322B11AB700E4CFEC /* MullvadEndpoint.swift */, 5866F39B2243B82D00168AE5 /* MullvadVPN.entitlements */, 58906DDF2445C7A5002F0673 /* NEProviderStopReason+Debug.swift */, 5811DE4F239014550011EB53 /* NEVPNStatus+Debug.swift */, @@ -1195,8 +1256,6 @@ 58EF580A25D69D7A00AEBA94 /* ProblemReportSubmissionOverlayView.swift */, 58293FAC2510CA58005D0BB5 /* ProblemReportViewController.swift */, 585DA87526B0249A00B8C587 /* RelayCache */, - 58781CC822AE7CA8009B9D8E /* RelayConstraints.swift */, - 58781CD422AFBA39009B9D8E /* RelaySelector.swift */, 06FAE67828F83CA50033DD93 /* RESTCreateApplePaymentResponse+Localization.swift */, 58F1311427E0B2AB007AC5BC /* Result+Extensions.swift */, 580909D22876D09A0078138D /* RevokedDeviceViewController.swift */, @@ -1455,6 +1514,40 @@ productReference = 581943F128F8014500B0CB5E /* libMullvadTypes.a */; productType = "com.apple.product-type.library.static"; }; + 5898D28829017BD300EB5EBA /* TunnelProviderMessaging */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5898D28F29017BD400EB5EBA /* Build configuration list for PBXNativeTarget "TunnelProviderMessaging" */; + buildPhases = ( + 5898D28529017BD300EB5EBA /* Sources */, + 5898D28629017BD300EB5EBA /* Frameworks */, + 5898D28729017BD300EB5EBA /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TunnelProviderMessaging; + productName = PacketTunnelMessaging; + productReference = 5898D28929017BD400EB5EBA /* libTunnelProviderMessaging.a */; + productType = "com.apple.product-type.library.static"; + }; + 5898D29729017DAC00EB5EBA /* RelaySelector */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5898D29C29017DAC00EB5EBA /* Build configuration list for PBXNativeTarget "RelaySelector" */; + buildPhases = ( + 5898D29429017DAC00EB5EBA /* Sources */, + 5898D29529017DAC00EB5EBA /* Frameworks */, + 5898D29629017DAC00EB5EBA /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = RelaySelector; + productName = MullvadRelaySelector; + productReference = 5898D29829017DAC00EB5EBA /* libRelaySelector.a */; + productType = "com.apple.product-type.library.static"; + }; 589A455128E094B300565204 /* OperationsTests */ = { isa = PBXNativeTarget; buildConfigurationList = 589A455928E094B300565204 /* Build configuration list for PBXNativeTarget "OperationsTests" */; @@ -1588,7 +1681,7 @@ 58CE5E58224146200008646E /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 1400; + LastSwiftUpdateCheck = 1410; LastUpgradeCheck = 1400; ORGANIZATIONNAME = "Mullvad VPN AB"; TargetAttributes = { @@ -1605,6 +1698,12 @@ 581943F028F8014500B0CB5E = { CreatedOnToolsVersion = 14.0.1; }; + 5898D28829017BD300EB5EBA = { + CreatedOnToolsVersion = 14.1; + }; + 5898D29729017DAC00EB5EBA = { + CreatedOnToolsVersion = 14.1; + }; 589A455128E094B300565204 = { CreatedOnToolsVersion = 14.0.1; }; @@ -1672,6 +1771,8 @@ 581943F028F8014500B0CB5E /* MullvadTypes */, 06799ABB28F98E1D00ACD94E /* MullvadREST */, 063F02722902B63F001FA09F /* RelayCache */, + 5898D28829017BD300EB5EBA /* TunnelProviderMessaging */, + 5898D29729017DAC00EB5EBA /* RelaySelector */, ); }; /* End PBXProject section */ @@ -1840,16 +1941,44 @@ files = ( 586A951429013235007BAF2B /* AnyIPEndpoint.swift in Sources */, 581943FC28F8020500B0CB5E /* Error+Chain.swift in Sources */, + 5898D29329017CFD00EB5EBA /* Location.swift in Sources */, 581943FB28F801D500B0CB5E /* CustomErrorDescriptionProtocol.swift in Sources */, + 5898D2B52902A8F000EB5EBA /* RelayConstraint.swift in Sources */, + 5898D2B42902A8F000EB5EBA /* RelayConstraints.swift in Sources */, 586A95172901344A007BAF2B /* IPAddress+Codable.swift in Sources */, 063F026729002768001FA09F /* Cancellable.swift in Sources */, 586A9516290133ED007BAF2B /* AnyIPAddress.swift in Sources */, + 5898D2A32901807500EB5EBA /* MullvadEndpoint.swift in Sources */, + 5898D2B32902A8F000EB5EBA /* RelayLocation.swift in Sources */, 063F026A29002E44001FA09F /* IPv4Endpoint.swift in Sources */, 586A95122901321B007BAF2B /* IPv6Endpoint.swift in Sources */, 581943FA28F801B500B0CB5E /* WrappingError.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; + 5898D28529017BD300EB5EBA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5898D29129017C3100EB5EBA /* TunnelProviderMessage.swift in Sources */, + 5898D2A62901820C00EB5EBA /* PacketTunnelStatus.swift in Sources */, + 5898D2A52901815E00EB5EBA /* RelaySelectorResult+PacketTunnelRelay.swift in Sources */, + 5898D29029017BEE00EB5EBA /* PacketTunnelOptions.swift in Sources */, + 5898D2AE290185D200EB5EBA /* ProxyURLResponse.swift in Sources */, + 5898D2B72902A9EA00EB5EBA /* PacketTunnelRelay.swift in Sources */, + 5898D29229017CA000EB5EBA /* ProxyURLRequest.swift in Sources */, + 5898D2A8290182B000EB5EBA /* TunnelProviderReply.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5898D29429017DAC00EB5EBA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5898D29F29017DD000EB5EBA /* RelaySelector.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 589A454E28E094B300565204 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -1871,16 +2000,11 @@ 5819C2142726CC8D00D6EC38 /* DataSourceSnapshotTests.swift in Sources */, 5807E2C2243203D000F5FF30 /* StringTests.swift in Sources */, 582AE3132440CA2700E6733A /* AccountTokenInput.swift in Sources */, - 58B0A2AA238EE6A900BC001D /* RelaySelector.swift in Sources */, 5807E2C3243203E700F5FF30 /* String+Split.swift in Sources */, 58B0A2A8238EE68200BC001D /* RelaySelectorTests.swift in Sources */, 5819C2152726CC9400D6EC38 /* DataSourceSnapshot.swift in Sources */, - 584E96BE240FD4DB00D3334F /* Location.swift in Sources */, 582A8A3B28BCE1AB00D0F9FB /* FixedWidthInteger+Arithmetics.swift in Sources */, - 58B0A2AD238EE6EC00BC001D /* MullvadEndpoint.swift in Sources */, 5896AE88246D7FAF005B36CB /* CustomDateComponentsFormatting.swift in Sources */, - 58B0A2A9238EE6A100BC001D /* RelayConstraints.swift in Sources */, - 5804BEBD28F811F600B49CA5 /* PacketTunnelStatus.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1892,7 +2016,6 @@ 5891BF5125E66B1E006D6FB0 /* UIBarButtonItem+KeyboardNavigation.swift in Sources */, 58E511E628DDDEAC00B0BCDE /* CodingErrors+CustomErrorDescription.swift in Sources */, 587B75412668FD7800DEF7E9 /* AccountExpiryNotificationProvider.swift in Sources */, - 585DA89926B0329200B8C587 /* PacketTunnelStatus.swift in Sources */, 587988C728A2A01F00E3DF54 /* AccountDataThrottling.swift in Sources */, 5896CEF226972DEB00B0FAE8 /* AccountContentView.swift in Sources */, 587D96742886D87C00CD8F1C /* DeviceManagementContentView.swift in Sources */, @@ -1906,7 +2029,6 @@ 584D26C6270C8741004EA533 /* SettingsDNSTextCell.swift in Sources */, 58F2E148276A307400A79513 /* MapConnectionStatusOperation.swift in Sources */, 58BA693123EADA6A009DC256 /* SimulatorTunnelProvider.swift in Sources */, - 587C575326D2615F005EF767 /* PacketTunnelOptions.swift in Sources */, 587B753B2666467500DEF7E9 /* NotificationBannerView.swift in Sources */, 58B993B12608A34500BA7811 /* LoginContentView.swift in Sources */, 58E6771F24ADFE7800AA26E7 /* SettingsNavigationController.swift in Sources */, @@ -1957,22 +2079,18 @@ 588527B4276B4F2F00BAA373 /* SetAccountOperation.swift in Sources */, 585CA70F25F8C44600B47C62 /* UIMetrics.swift in Sources */, E1187ABD289BBB850024E748 /* OutOfTimeContentView.swift in Sources */, - 5840250422B11AB700E4CFEC /* MullvadEndpoint.swift in Sources */, 58CC40EF24A601900019D96E /* ObserverList.swift in Sources */, 58CCA01822426713004F3011 /* AccountViewController.swift in Sources */, 75FD0C2528B117D30021E33E /* ShortcutsViewController.swift in Sources */, 5871FBA0254C26C00051A0A4 /* NSRegularExpression+IPAddress.swift in Sources */, 58F7CA882692E34000FC59FD /* WireguardKeysContentView.swift in Sources */, 5868585524054096000B8131 /* AppButton.swift in Sources */, - 58781CC922AE7CA8009B9D8E /* RelayConstraints.swift in Sources */, - 584E96BC240FD4DA00D3334F /* Location.swift in Sources */, 58E25F812837BBBB002CFB2C /* SceneDelegate.swift in Sources */, 585E820327F3285E00939F0E /* SendAppStoreReceiptOperation.swift in Sources */, 584B17AB27637DE40057F3B8 /* ReconnectTunnelOperation.swift in Sources */, 5820676426E771DB00655B05 /* TunnelManagerErrors.swift in Sources */, 585B4B8726D9098900555C4C /* TunnelStatusNotificationProvider.swift in Sources */, 063F026628FFE11C001FA09F /* RESTCreateApplePaymentResponse+Localization.swift in Sources */, - 58B67B482602079E008EF58E /* RelaySelector.swift in Sources */, 58DF28A52417CB4B00E836B0 /* AppStorePaymentManager.swift in Sources */, 583DA21425FA4B5C00318683 /* LocationDataSource.swift in Sources */, 587EB6742714520600123C75 /* PreferencesDataSourceDelegate.swift in Sources */, @@ -1983,7 +2101,6 @@ 5862805422428EF100F5A6E1 /* TranslucentButtonBlurView.swift in Sources */, 587EB66A270EFACB00123C75 /* CharacterSet+IPAddress.swift in Sources */, 5888AD83227B11080051EB06 /* SelectLocationCell.swift in Sources */, - 585DA89326B0323E00B8C587 /* TunnelProviderMessage.swift in Sources */, 5891BF1C25E3E3EB006D6FB0 /* Bundle+ProductVersion.swift in Sources */, 5807E2C02432038B00F5FF30 /* String+Split.swift in Sources */, 58CE5E66224146200008646E /* LoginViewController.swift in Sources */, @@ -1995,7 +2112,6 @@ 586A950D290125F0007BAF2B /* PresentAlertOperation.swift in Sources */, 58B93A1326C3F13600A55733 /* TunnelState.swift in Sources */, 58FEEB46260A028D00A621A8 /* GeoJSON.swift in Sources */, - 063687B028EB083800BE7161 /* ProxyURLRequest.swift in Sources */, 753D6C0C28B4BF3E0052D9E1 /* ShortcutsManager.swift in Sources */, 58CE5E64224146200008646E /* AppDelegate.swift in Sources */, 5872D6E8286304DE00DB5F4E /* TermsOfService.swift in Sources */, @@ -2046,29 +2162,21 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 587C575426D2615F005EF767 /* PacketTunnelOptions.swift in Sources */, 5806767C27048E9B00C858CB /* PacketTunnelProvider.swift in Sources */, - 585DA89426B0323E00B8C587 /* TunnelProviderMessage.swift in Sources */, 587AD7C723421D8600E93A53 /* TunnelSettingsV1.swift in Sources */, 58AEEF662344A37400C9BBD5 /* KeychainError.swift in Sources */, 58CE38C828992C9200A6D6E5 /* TunnelMonitorDelegate.swift in Sources */, 58FC040A27B3EE03001C21F0 /* TunnelMonitor.swift in Sources */, 5838318B27C40A3900000571 /* Pinger.swift in Sources */, - 585DA89A26B0329200B8C587 /* PacketTunnelStatus.swift in Sources */, 58E0729D28814AAE008902F8 /* PacketTunnelConfiguration.swift in Sources */, 58E0729F28814ACC008902F8 /* WireGuardLogLevel+Logging.swift in Sources */, 580F8B8428197884002E0998 /* TunnelSettingsV2.swift in Sources */, - 5840250522B11AB700E4CFEC /* MullvadEndpoint.swift in Sources */, 58906DE02445C7A5002F0673 /* NEProviderStopReason+Debug.swift in Sources */, 580F8B872819795C002E0998 /* DNSSettings.swift in Sources */, 58E072A128814B0E008902F8 /* MullvadEndpoint+WgEndpoint.swift in Sources */, - 584E96BD240FD4DA00D3334F /* Location.swift in Sources */, 06AC116228F94C450037AF9A /* ApplicationConfiguration.swift in Sources */, - 063687B228EB083F00BE7161 /* ProxyURLRequest.swift in Sources */, 58900D0328BBDCC70094E4F0 /* FixedWidthInteger+Arithmetics.swift in Sources */, 58A3BDB028A1821A00C8C2C6 /* WgStats.swift in Sources */, - 58781CCE22AE8918009B9D8E /* RelayConstraints.swift in Sources */, - 58781CD522AFBA39009B9D8E /* RelaySelector.swift in Sources */, 5877D70F282137E8002FCFC7 /* SettingsManager.swift in Sources */, 58CE38C728992C8700A6D6E5 /* WireGuardAdapterError+Localization.swift in Sources */, 58E511E828DDDF2400B0BCDE /* CodingErrors+CustomErrorDescription.swift in Sources */, @@ -2275,15 +2383,13 @@ }; 06799AD428F98E1D00ACD94E /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 5808273928487E3E006B77A4 /* Base.xcconfig */; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = CKG9MXH72F; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -2309,15 +2415,13 @@ }; 06799AD528F98E1D00ACD94E /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 5808273928487E3E006B77A4 /* Base.xcconfig */; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = CKG9MXH72F; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -2348,8 +2452,6 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CLANG_ENABLE_MODULES = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = CKG9MXH72F; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2371,8 +2473,6 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CLANG_ENABLE_MODULES = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = CKG9MXH72F; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2392,8 +2492,6 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = CKG9MXH72F; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -2408,8 +2506,62 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = CKG9MXH72F; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 5898D28D29017BD400EB5EBA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 5898D28E29017BD400EB5EBA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 5898D29D29017DAC00EB5EBA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 5898D29E29017DAC00EB5EBA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -2734,12 +2886,11 @@ }; 58E5126928DDF04200B0BCDE /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 5808273928487E3E006B77A4 /* Base.xcconfig */; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = CKG9MXH72F; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -2754,8 +2905,6 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = CKG9MXH72F; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -2830,6 +2979,24 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 5898D28F29017BD400EB5EBA /* Build configuration list for PBXNativeTarget "TunnelProviderMessaging" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5898D28D29017BD400EB5EBA /* Debug */, + 5898D28E29017BD400EB5EBA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 5898D29C29017DAC00EB5EBA /* Build configuration list for PBXNativeTarget "RelaySelector" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5898D29D29017DAC00EB5EBA /* Debug */, + 5898D29E29017DAC00EB5EBA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 589A455928E094B300565204 /* Build configuration list for PBXNativeTarget "OperationsTests" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/ios/MullvadVPN.xcodeproj/xcshareddata/xcschemes/RelaySelector.xcscheme b/ios/MullvadVPN.xcodeproj/xcshareddata/xcschemes/RelaySelector.xcscheme new file mode 100644 index 0000000000..5a1350b80b --- /dev/null +++ b/ios/MullvadVPN.xcodeproj/xcshareddata/xcschemes/RelaySelector.xcscheme @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "1410" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "5898D29729017DAC00EB5EBA" + BuildableName = "libRelaySelector.a" + BlueprintName = "RelaySelector" + ReferencedContainer = "container:MullvadVPN.xcodeproj"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES"> + <Testables> + </Testables> + </TestAction> + <LaunchAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + debugServiceExtension = "internal" + allowLocationSimulation = "YES"> + </LaunchAction> + <ProfileAction + buildConfiguration = "Release" + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + debugDocumentVersioning = "YES"> + <MacroExpansion> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "5898D29729017DAC00EB5EBA" + BuildableName = "libRelaySelector.a" + BlueprintName = "RelaySelector" + ReferencedContainer = "container:MullvadVPN.xcodeproj"> + </BuildableReference> + </MacroExpansion> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/ios/MullvadVPN.xcodeproj/xcshareddata/xcschemes/TunnelProviderMessaging.xcscheme b/ios/MullvadVPN.xcodeproj/xcshareddata/xcschemes/TunnelProviderMessaging.xcscheme new file mode 100644 index 0000000000..13114a109c --- /dev/null +++ b/ios/MullvadVPN.xcodeproj/xcshareddata/xcschemes/TunnelProviderMessaging.xcscheme @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "1410" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "5898D28829017BD300EB5EBA" + BuildableName = "libTunnelProviderMessaging.a" + BlueprintName = "TunnelProviderMessaging" + ReferencedContainer = "container:MullvadVPN.xcodeproj"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES"> + <Testables> + </Testables> + </TestAction> + <LaunchAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + debugServiceExtension = "internal" + allowLocationSimulation = "YES"> + </LaunchAction> + <ProfileAction + buildConfiguration = "Release" + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + debugDocumentVersioning = "YES"> + <MacroExpansion> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "5898D28829017BD300EB5EBA" + BuildableName = "libTunnelProviderMessaging.a" + BlueprintName = "TunnelProviderMessaging" + ReferencedContainer = "container:MullvadVPN.xcodeproj"> + </BuildableReference> + </MacroExpansion> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/ios/MullvadVPN/ConnectViewController.swift b/ios/MullvadVPN/ConnectViewController.swift index 71f620d237..4f2ad13bc6 100644 --- a/ios/MullvadVPN/ConnectViewController.swift +++ b/ios/MullvadVPN/ConnectViewController.swift @@ -8,6 +8,7 @@ import MapKit import MullvadLogging +import TunnelProviderMessaging import UIKit class CustomOverlayRenderer: MKOverlayRenderer { diff --git a/ios/MullvadVPN/Location.swift b/ios/MullvadVPN/Location.swift deleted file mode 100644 index ae8566a6e1..0000000000 --- a/ios/MullvadVPN/Location.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// Location.swift -// MullvadVPN -// -// Created by pronebird on 12/02/2020. -// Copyright © 2020 Mullvad VPN AB. All rights reserved. -// - -import struct CoreLocation.CLLocationCoordinate2D -import Foundation - -struct Location: Codable, Equatable { - var country: String - var countryCode: String - var city: String - var cityCode: String - var latitude: Double - var longitude: Double - - var geoCoordinate: CLLocationCoordinate2D { - return CLLocationCoordinate2D(latitude: latitude, longitude: longitude) - } -} diff --git a/ios/MullvadVPN/LocationDataSource.swift b/ios/MullvadVPN/LocationDataSource.swift index 49c4b5ece1..0f58953882 100644 --- a/ios/MullvadVPN/LocationDataSource.swift +++ b/ios/MullvadVPN/LocationDataSource.swift @@ -7,6 +7,7 @@ // import MullvadREST +import MullvadTypes import UIKit protocol LocationDataSourceItemProtocol { diff --git a/ios/MullvadVPN/MullvadEndpoint.swift b/ios/MullvadVPN/MullvadEndpoint.swift deleted file mode 100644 index 9e14c9eea9..0000000000 --- a/ios/MullvadVPN/MullvadEndpoint.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// MullvadEndpoint.swift -// MullvadVPN -// -// Created by pronebird on 12/06/2019. -// Copyright © 2019 Mullvad VPN AB. All rights reserved. -// - -import Foundation -import MullvadTypes -import Network - -/// Contains server data needed to connect to a single mullvad endpoint -struct MullvadEndpoint: Equatable, Codable { - let ipv4Relay: IPv4Endpoint - let ipv6Relay: IPv6Endpoint? - let ipv4Gateway: IPv4Address - let ipv6Gateway: IPv6Address - let publicKey: Data -} diff --git a/ios/MullvadVPN/SceneDelegate.swift b/ios/MullvadVPN/SceneDelegate.swift index b77ccf42ae..6a8a136f4a 100644 --- a/ios/MullvadVPN/SceneDelegate.swift +++ b/ios/MullvadVPN/SceneDelegate.swift @@ -8,6 +8,7 @@ import MullvadLogging import MullvadREST +import MullvadTypes import Operations import RelayCache import UIKit diff --git a/ios/MullvadVPN/SelectLocationViewController.swift b/ios/MullvadVPN/SelectLocationViewController.swift index abe8d765f4..d4ebeacaf8 100644 --- a/ios/MullvadVPN/SelectLocationViewController.swift +++ b/ios/MullvadVPN/SelectLocationViewController.swift @@ -7,6 +7,7 @@ // import MullvadLogging +import MullvadTypes import RelayCache import UIKit diff --git a/ios/MullvadVPN/SettingsManager/TunnelSettingsV1.swift b/ios/MullvadVPN/SettingsManager/TunnelSettingsV1.swift index b5a8ed207f..f5c0ed8bc1 100644 --- a/ios/MullvadVPN/SettingsManager/TunnelSettingsV1.swift +++ b/ios/MullvadVPN/SettingsManager/TunnelSettingsV1.swift @@ -7,6 +7,7 @@ // import Foundation +import MullvadTypes import struct Network.IPv4Address import struct WireGuardKitTypes.IPAddressRange import class WireGuardKitTypes.PrivateKey diff --git a/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift b/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift index c38dc00ddb..d382bf238b 100644 --- a/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift +++ b/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift @@ -7,6 +7,7 @@ // import Foundation +import MullvadTypes import struct Network.IPv4Address import struct WireGuardKitTypes.IPAddressRange import class WireGuardKitTypes.PrivateKey diff --git a/ios/MullvadVPN/SimulatorTunnelProviderHost.swift b/ios/MullvadVPN/SimulatorTunnelProviderHost.swift index 4bd7b19696..d06a404f9a 100644 --- a/ios/MullvadVPN/SimulatorTunnelProviderHost.swift +++ b/ios/MullvadVPN/SimulatorTunnelProviderHost.swift @@ -13,6 +13,8 @@ import MullvadLogging import MullvadREST import enum NetworkExtension.NEProviderStopReason import RelayCache +import RelaySelector +import TunnelProviderMessaging class SimulatorTunnelProviderHost: SimulatorTunnelProviderDelegate { private var selectorResult: RelaySelectorResult? diff --git a/ios/MullvadVPN/TransportMonitor/PacketTunnelTransport.swift b/ios/MullvadVPN/TransportMonitor/PacketTunnelTransport.swift index 87dd2b6f32..bf994e33ce 100644 --- a/ios/MullvadVPN/TransportMonitor/PacketTunnelTransport.swift +++ b/ios/MullvadVPN/TransportMonitor/PacketTunnelTransport.swift @@ -9,6 +9,7 @@ import Foundation import protocol MullvadREST.RESTTransport import MullvadTypes +import TunnelProviderMessaging final class PacketTunnelTransport: RESTTransport { var name: String { diff --git a/ios/MullvadVPN/TunnelManager/MapConnectionStatusOperation.swift b/ios/MullvadVPN/TunnelManager/MapConnectionStatusOperation.swift index 1ea9cbcfaa..6b0248cf4c 100644 --- a/ios/MullvadVPN/TunnelManager/MapConnectionStatusOperation.swift +++ b/ios/MullvadVPN/TunnelManager/MapConnectionStatusOperation.swift @@ -12,6 +12,7 @@ import MullvadREST import MullvadTypes import NetworkExtension import Operations +import TunnelProviderMessaging class MapConnectionStatusOperation: AsyncOperation { private let interactor: TunnelInteractor diff --git a/ios/MullvadVPN/TunnelManager/PacketTunnelStatus.swift b/ios/MullvadVPN/TunnelManager/PacketTunnelStatus.swift deleted file mode 100644 index f918035523..0000000000 --- a/ios/MullvadVPN/TunnelManager/PacketTunnelStatus.swift +++ /dev/null @@ -1,37 +0,0 @@ -// -// PacketTunnelStatus.swift -// PacketTunnelStatus -// -// Created by pronebird on 27/07/2021. -// Copyright © 2021 Mullvad VPN AB. All rights reserved. -// - -import Foundation -import MullvadTypes - -/// Struct describing packet tunnel process status. -struct PacketTunnelStatus: Codable, Equatable { - /// Last tunnel error. - var lastError: String? = nil - - /// Flag indicating whether network is reachable. - var isNetworkReachable = true - - /// Current relay. - var tunnelRelay: PacketTunnelRelay? -} - -/// Struct holding tunnel relay information. -struct PacketTunnelRelay: Codable, Equatable { - /// IPv4 relay endpoint. - let ipv4Relay: IPv4Endpoint - - /// IPv6 relay endpoint. - let ipv6Relay: IPv6Endpoint? - - /// Relay hostname. - let hostname: String - - /// Relay location. - let location: Location -} diff --git a/ios/MullvadVPN/TunnelManager/ProxyURLRequest.swift b/ios/MullvadVPN/TunnelManager/ProxyURLRequest.swift deleted file mode 100644 index ccc3ec4ee7..0000000000 --- a/ios/MullvadVPN/TunnelManager/ProxyURLRequest.swift +++ /dev/null @@ -1,100 +0,0 @@ -// -// ProxyURLRequest.swift -// MullvadVPN -// -// Created by Sajad Vishkai on 2022-10-03. -// Copyright © 2022 Mullvad VPN AB. All rights reserved. -// - -import Foundation - -/// Struct describing serializable URLRequest data. -struct ProxyURLRequest: Codable { - let id: UUID - let url: URL - let method: String? - let httpBody: Data? - let httpHeaders: [String: String]? - - var urlRequest: URLRequest { - var urlRequest = URLRequest(url: url) - urlRequest.httpMethod = method - urlRequest.httpBody = httpBody - urlRequest.allHTTPHeaderFields = httpHeaders - return urlRequest - } - - init(id: UUID, urlRequest: URLRequest) throws { - guard let url = urlRequest.url else { - throw InvalidURLRequestError() - } - - self.id = id - self.url = url - method = urlRequest.httpMethod - httpBody = urlRequest.httpBody - httpHeaders = urlRequest.allHTTPHeaderFields - } -} - -/// Struct describing serializable URLResponse data. -struct ProxyURLResponse: Codable { - let data: Data? - let response: HTTPURLResponseWrapper? - let error: URLErrorWrapper? - - init(data: Data?, response: URLResponse?, error: Error?) { - self.data = data - self.response = response.flatMap { HTTPURLResponseWrapper($0) } - self.error = error.flatMap { URLErrorWrapper($0) } - } -} - -struct URLErrorWrapper: Codable { - let code: Int? - let localizedDescription: String - - init?(_ error: Error) { - localizedDescription = error.localizedDescription - code = (error as? URLError)?.errorCode - } - - var originalError: Error? { - guard let code = code else { return nil } - - return URLError(URLError.Code(rawValue: code)) - } -} - -struct HTTPURLResponseWrapper: Codable { - let url: URL? - let statusCode: Int - let headerFields: [String: String]? - - init?(_ response: URLResponse) { - guard let response = response as? HTTPURLResponse else { return nil } - - url = response.url - statusCode = response.statusCode - headerFields = Dictionary( - uniqueKeysWithValues: response.allHeaderFields.map { ("\($0)", "\($1)") } - ) - } - - var originalResponse: HTTPURLResponse? { - guard let url = url else { return nil } - - return HTTPURLResponse( - url: url, - statusCode: statusCode, - httpVersion: nil, - headerFields: headerFields - ) - } -} - -struct InvalidURLRequestError: LocalizedError { - var errorDescription: String? { - return "Invalid URLRequest URL." - } -} diff --git a/ios/MullvadVPN/TunnelManager/ReconnectTunnelOperation.swift b/ios/MullvadVPN/TunnelManager/ReconnectTunnelOperation.swift index 748a77e3a6..fd145e332a 100644 --- a/ios/MullvadVPN/TunnelManager/ReconnectTunnelOperation.swift +++ b/ios/MullvadVPN/TunnelManager/ReconnectTunnelOperation.swift @@ -11,6 +11,7 @@ import MullvadREST import MullvadTypes import Operations import RelayCache +import RelaySelector class ReconnectTunnelOperation: ResultOperation<Void, Error> { private let interactor: TunnelInteractor diff --git a/ios/MullvadVPN/TunnelManager/SendTunnelProviderMessageOperation.swift b/ios/MullvadVPN/TunnelManager/SendTunnelProviderMessageOperation.swift index 5fa81f6248..960393f7fd 100644 --- a/ios/MullvadVPN/TunnelManager/SendTunnelProviderMessageOperation.swift +++ b/ios/MullvadVPN/TunnelManager/SendTunnelProviderMessageOperation.swift @@ -10,6 +10,7 @@ import Foundation import MullvadTypes import NetworkExtension import Operations +import TunnelProviderMessaging /// Delay for sending tunnel provider messages to the tunnel when in connecting state. /// Used to workaround a bug when talking to the tunnel too early during startup may cause it diff --git a/ios/MullvadVPN/TunnelManager/StartTunnelOperation.swift b/ios/MullvadVPN/TunnelManager/StartTunnelOperation.swift index c2611323a0..d646103ce5 100644 --- a/ios/MullvadVPN/TunnelManager/StartTunnelOperation.swift +++ b/ios/MullvadVPN/TunnelManager/StartTunnelOperation.swift @@ -11,6 +11,8 @@ import MullvadLogging import NetworkExtension import Operations import RelayCache +import RelaySelector +import TunnelProviderMessaging class StartTunnelOperation: ResultOperation<Void, Error> { typealias EncodeErrorHandler = (Error) -> Void diff --git a/ios/MullvadVPN/TunnelManager/Tunnel+Messaging.swift b/ios/MullvadVPN/TunnelManager/Tunnel+Messaging.swift index 99477290da..339e9b0da6 100644 --- a/ios/MullvadVPN/TunnelManager/Tunnel+Messaging.swift +++ b/ios/MullvadVPN/TunnelManager/Tunnel+Messaging.swift @@ -10,6 +10,8 @@ import Foundation import MullvadREST import MullvadTypes import Operations +import RelaySelector +import TunnelProviderMessaging /// Shared operation queue used for IPC requests. private let operationQueue = AsyncOperationQueue() diff --git a/ios/MullvadVPN/TunnelManager/TunnelManager.swift b/ios/MullvadVPN/TunnelManager/TunnelManager.swift index b39bc951a0..28ab12b8ad 100644 --- a/ios/MullvadVPN/TunnelManager/TunnelManager.swift +++ b/ios/MullvadVPN/TunnelManager/TunnelManager.swift @@ -12,7 +12,9 @@ import MullvadREST import MullvadTypes import NetworkExtension import Operations +import RelaySelector import StoreKit +import TunnelProviderMessaging import UIKit import class WireGuardKitTypes.PublicKey diff --git a/ios/MullvadVPN/TunnelManager/TunnelState.swift b/ios/MullvadVPN/TunnelManager/TunnelState.swift index fd58e48d51..9e6e3a68d7 100644 --- a/ios/MullvadVPN/TunnelManager/TunnelState.swift +++ b/ios/MullvadVPN/TunnelManager/TunnelState.swift @@ -7,6 +7,7 @@ // import Foundation +import TunnelProviderMessaging /// A struct describing the tunnel status. struct TunnelStatus: Equatable, CustomStringConvertible { diff --git a/ios/PacketTunnel/MullvadEndpoint+WgEndpoint.swift b/ios/PacketTunnel/MullvadEndpoint+WgEndpoint.swift index c39af86ea0..7f561f2ac8 100644 --- a/ios/PacketTunnel/MullvadEndpoint+WgEndpoint.swift +++ b/ios/PacketTunnel/MullvadEndpoint+WgEndpoint.swift @@ -7,6 +7,7 @@ // import Foundation +import MullvadTypes import WireGuardKit extension MullvadEndpoint { diff --git a/ios/PacketTunnel/PacketTunnelConfiguration.swift b/ios/PacketTunnel/PacketTunnelConfiguration.swift index ef774489da..08eba32da2 100644 --- a/ios/PacketTunnel/PacketTunnelConfiguration.swift +++ b/ios/PacketTunnel/PacketTunnelConfiguration.swift @@ -7,7 +7,9 @@ // import Foundation +import MullvadTypes import protocol Network.IPAddress +import RelaySelector import WireGuardKit struct PacketTunnelConfiguration { diff --git a/ios/PacketTunnel/PacketTunnelProvider.swift b/ios/PacketTunnel/PacketTunnelProvider.swift index 45b79f51ac..00b8c47b97 100644 --- a/ios/PacketTunnel/PacketTunnelProvider.swift +++ b/ios/PacketTunnel/PacketTunnelProvider.swift @@ -9,9 +9,12 @@ import Foundation import MullvadLogging import MullvadREST +import MullvadTypes import Network import NetworkExtension import RelayCache +import RelaySelector +import TunnelProviderMessaging import WireGuardKit class PacketTunnelProvider: NEPacketTunnelProvider, TunnelMonitorDelegate { diff --git a/ios/MullvadVPN/RelaySelector.swift b/ios/RelaySelector/RelaySelector.swift index abf8a30197..bc88795b7d 100644 --- a/ios/MullvadVPN/RelaySelector.swift +++ b/ios/RelaySelector/RelaySelector.swift @@ -1,6 +1,6 @@ // // RelaySelector.swift -// PacketTunnel +// RelaySelector // // Created by pronebird on 11/06/2019. // Copyright © 2019 Mullvad VPN AB. All rights reserved. @@ -10,38 +10,8 @@ import Foundation import MullvadREST import MullvadTypes -struct RelaySelectorResult: Codable { - var endpoint: MullvadEndpoint - var relay: REST.ServerRelay - var location: Location -} - -private struct RelayWithLocation { - var relay: REST.ServerRelay - var location: Location -} - -extension RelaySelectorResult { - var packetTunnelRelay: PacketTunnelRelay { - return PacketTunnelRelay( - ipv4Relay: endpoint.ipv4Relay, - ipv6Relay: endpoint.ipv6Relay, - hostname: relay.hostname, - location: location - ) - } -} - -struct NoRelaysSatisfyingConstraintsError: LocalizedError { - var errorDescription: String? { - return "No relays satisfying constraints." - } -} - -enum RelaySelector {} - -extension RelaySelector { - static func evaluate( +public enum RelaySelector { + public static func evaluate( relays: REST.ServerRelaysResponse, constraints: RelayConstraints ) throws -> RelaySelectorResult { @@ -190,3 +160,20 @@ extension RelaySelector { } } } + +public struct NoRelaysSatisfyingConstraintsError: LocalizedError { + public var errorDescription: String? { + return "No relays satisfying constraints." + } +} + +public struct RelaySelectorResult: Codable { + public var endpoint: MullvadEndpoint + public var relay: REST.ServerRelay + public var location: Location +} + +private struct RelayWithLocation { + var relay: REST.ServerRelay + var location: Location +} diff --git a/ios/MullvadVPN/TunnelManager/PacketTunnelOptions.swift b/ios/TunnelProviderMessaging/PacketTunnelOptions.swift index 850c24f37c..380718083e 100644 --- a/ios/MullvadVPN/TunnelManager/PacketTunnelOptions.swift +++ b/ios/TunnelProviderMessaging/PacketTunnelOptions.swift @@ -1,14 +1,15 @@ // // PacketTunnelOptions.swift -// PacketTunnelOptions +// TunnelProviderMessaging // // Created by pronebird on 22/08/2021. // Copyright © 2021 Mullvad VPN AB. All rights reserved. // import Foundation +import RelaySelector -struct PacketTunnelOptions { +public struct PacketTunnelOptions { /// Keys for options dictionary private enum Keys: String { /// Option key that holds the `NSData` value with `RelaySelectorResult` @@ -24,29 +25,29 @@ struct PacketTunnelOptions { private var _rawOptions: [String: NSObject] - func rawOptions() -> [String: NSObject] { + public func rawOptions() -> [String: NSObject] { return _rawOptions } - init() { + public init() { _rawOptions = [:] } - init(rawOptions: [String: NSObject]) { + public init(rawOptions: [String: NSObject]) { _rawOptions = rawOptions } - func getSelectorResult() throws -> RelaySelectorResult? { + public func getSelectorResult() throws -> RelaySelectorResult? { guard let data = _rawOptions[Keys.relaySelectorResult.rawValue] as? Data else { return nil } return try Self.decode(RelaySelectorResult.self, data) } - mutating func setSelectorResult(_ value: RelaySelectorResult) throws { + public mutating func setSelectorResult(_ value: RelaySelectorResult) throws { _rawOptions[Keys.relaySelectorResult.rawValue] = try Self.encode(value) as NSData } - func isOnDemand() -> Bool { + public func isOnDemand() -> Bool { return _rawOptions[Keys.isOnDemand.rawValue] as? Int == .some(1) } diff --git a/ios/TunnelProviderMessaging/PacketTunnelRelay.swift b/ios/TunnelProviderMessaging/PacketTunnelRelay.swift new file mode 100644 index 0000000000..f916dcc02a --- /dev/null +++ b/ios/TunnelProviderMessaging/PacketTunnelRelay.swift @@ -0,0 +1,37 @@ +// +// PacketTunnelRelay.swift +// TunnelProviderMessaging +// +// Created by pronebird on 21/10/2022. +// Copyright © 2022 Mullvad VPN AB. All rights reserved. +// + +import Foundation +import MullvadTypes + +/// Struct holding tunnel relay information. +public struct PacketTunnelRelay: Codable, Equatable { + /// IPv4 relay endpoint. + public let ipv4Relay: IPv4Endpoint + + /// IPv6 relay endpoint. + public let ipv6Relay: IPv6Endpoint? + + /// Relay hostname. + public let hostname: String + + /// Relay location. + public let location: Location + + public init( + ipv4Relay: IPv4Endpoint, + ipv6Relay: IPv6Endpoint? = nil, + hostname: String, + location: Location + ) { + self.ipv4Relay = ipv4Relay + self.ipv6Relay = ipv6Relay + self.hostname = hostname + self.location = location + } +} diff --git a/ios/TunnelProviderMessaging/PacketTunnelStatus.swift b/ios/TunnelProviderMessaging/PacketTunnelStatus.swift new file mode 100644 index 0000000000..ad39c68212 --- /dev/null +++ b/ios/TunnelProviderMessaging/PacketTunnelStatus.swift @@ -0,0 +1,32 @@ +// +// PacketTunnelStatus.swift +// TunnelProviderMessaging +// +// Created by pronebird on 27/07/2021. +// Copyright © 2021 Mullvad VPN AB. All rights reserved. +// + +import Foundation +import MullvadTypes + +/// Struct describing packet tunnel process status. +public struct PacketTunnelStatus: Codable, Equatable { + /// Last tunnel error. + public var lastError: String? + + /// Flag indicating whether network is reachable. + public var isNetworkReachable: Bool + + /// Current relay. + public var tunnelRelay: PacketTunnelRelay? + + public init( + lastError: String? = nil, + isNetworkReachable: Bool = true, + tunnelRelay: PacketTunnelRelay? = nil + ) { + self.lastError = lastError + self.isNetworkReachable = isNetworkReachable + self.tunnelRelay = tunnelRelay + } +} diff --git a/ios/TunnelProviderMessaging/ProxyURLRequest.swift b/ios/TunnelProviderMessaging/ProxyURLRequest.swift new file mode 100644 index 0000000000..acc346f2fc --- /dev/null +++ b/ios/TunnelProviderMessaging/ProxyURLRequest.swift @@ -0,0 +1,44 @@ +// +// ProxyURLRequest.swift +// TunnelProviderMessaging +// +// Created by Sajad Vishkai on 2022-10-03. +// Copyright © 2022 Mullvad VPN AB. All rights reserved. +// + +import Foundation + +/// Struct describing serializable URLRequest data. +public struct ProxyURLRequest: Codable { + public let id: UUID + public let url: URL + public let method: String? + public let httpBody: Data? + public let httpHeaders: [String: String]? + + public var urlRequest: URLRequest { + var urlRequest = URLRequest(url: url) + urlRequest.httpMethod = method + urlRequest.httpBody = httpBody + urlRequest.allHTTPHeaderFields = httpHeaders + return urlRequest + } + + public init(id: UUID, urlRequest: URLRequest) throws { + guard let url = urlRequest.url else { + throw InvalidURLRequestError() + } + + self.id = id + self.url = url + method = urlRequest.httpMethod + httpBody = urlRequest.httpBody + httpHeaders = urlRequest.allHTTPHeaderFields + } +} + +public struct InvalidURLRequestError: LocalizedError { + public var errorDescription: String? { + return "Invalid URLRequest URL." + } +} diff --git a/ios/TunnelProviderMessaging/ProxyURLResponse.swift b/ios/TunnelProviderMessaging/ProxyURLResponse.swift new file mode 100644 index 0000000000..a25a8d861b --- /dev/null +++ b/ios/TunnelProviderMessaging/ProxyURLResponse.swift @@ -0,0 +1,65 @@ +// +// ProxyURLResponse.swift +// TunnelProviderMessaging +// +// Created by pronebird on 20/10/2022. +// Copyright © 2022 Mullvad VPN AB. All rights reserved. +// + +import Foundation + +/// Struct describing serializable URLResponse data. +public struct ProxyURLResponse: Codable { + public let data: Data? + public let response: HTTPURLResponseWrapper? + public let error: URLErrorWrapper? + + public init(data: Data?, response: URLResponse?, error: Error?) { + self.data = data + self.response = response.flatMap { HTTPURLResponseWrapper($0) } + self.error = error.flatMap { URLErrorWrapper($0) } + } +} + +public struct URLErrorWrapper: Codable { + public let code: Int? + public let localizedDescription: String + + public init?(_ error: Error) { + localizedDescription = error.localizedDescription + code = (error as? URLError)?.errorCode + } + + public var originalError: Error? { + guard let code = code else { return nil } + + return URLError(URLError.Code(rawValue: code)) + } +} + +public struct HTTPURLResponseWrapper: Codable { + public let url: URL? + public let statusCode: Int + public let headerFields: [String: String]? + + public init?(_ response: URLResponse) { + guard let response = response as? HTTPURLResponse else { return nil } + + url = response.url + statusCode = response.statusCode + headerFields = Dictionary( + uniqueKeysWithValues: response.allHeaderFields.map { ("\($0)", "\($1)") } + ) + } + + public var originalResponse: HTTPURLResponse? { + guard let url = url else { return nil } + + return HTTPURLResponse( + url: url, + statusCode: statusCode, + httpVersion: nil, + headerFields: headerFields + ) + } +} diff --git a/ios/TunnelProviderMessaging/RelaySelectorResult+PacketTunnelRelay.swift b/ios/TunnelProviderMessaging/RelaySelectorResult+PacketTunnelRelay.swift new file mode 100644 index 0000000000..16fa3069d9 --- /dev/null +++ b/ios/TunnelProviderMessaging/RelaySelectorResult+PacketTunnelRelay.swift @@ -0,0 +1,21 @@ +// +// RelaySelectorResult+PacketTunnelRelay.swift +// TunnelProviderMessaging +// +// Created by pronebird on 20/10/2022. +// Copyright © 2022 Mullvad VPN AB. All rights reserved. +// + +import Foundation +import RelaySelector + +extension RelaySelectorResult { + public var packetTunnelRelay: PacketTunnelRelay { + return PacketTunnelRelay( + ipv4Relay: endpoint.ipv4Relay, + ipv6Relay: endpoint.ipv6Relay, + hostname: relay.hostname, + location: location + ) + } +} diff --git a/ios/MullvadVPN/TunnelManager/TunnelProviderMessage.swift b/ios/TunnelProviderMessaging/TunnelProviderMessage.swift index 836d79c94a..03e55be01f 100644 --- a/ios/MullvadVPN/TunnelManager/TunnelProviderMessage.swift +++ b/ios/TunnelProviderMessaging/TunnelProviderMessage.swift @@ -1,15 +1,16 @@ // // TunnelProviderMessage.swift -// MullvadVPN +// TunnelProviderMessaging // // Created by pronebird on 27/07/2021. // Copyright © 2021 Mullvad VPN AB. All rights reserved. // import Foundation +import RelaySelector /// Enum describing supported app messages handled by packet tunnel provider. -enum TunnelProviderMessage: Codable, CustomStringConvertible { +public enum TunnelProviderMessage: Codable, CustomStringConvertible { /// Request the tunnel to reconnect. /// The packet tunnel reconnects to the current relay when selector result is `nil`. case reconnectTunnel(RelaySelectorResult?) @@ -23,7 +24,7 @@ enum TunnelProviderMessage: Codable, CustomStringConvertible { /// Cancel HTTP request sent outside of VPN tunnel. case cancelURLRequest(UUID) - var description: String { + public var description: String { switch self { case .reconnectTunnel: return "reconnect-tunnel" @@ -36,30 +37,11 @@ enum TunnelProviderMessage: Codable, CustomStringConvertible { } } - init(messageData: Data) throws { + public init(messageData: Data) throws { self = try JSONDecoder().decode(Self.self, from: messageData) } - func encode() throws -> Data { - return try JSONEncoder().encode(self) - } -} - -/// Container type for tunnel provider replies. -/// The primary purpose of this type is to provide a top level object for `JSONEncoder`, since -/// objects and arrays are the only allowed top level objects on iOS 12. -struct TunnelProviderReply<T: Codable>: Codable { - var value: T - - init(_ value: T) { - self.value = value - } - - init(messageData: Data) throws { - self = try JSONDecoder().decode(Self.self, from: messageData) - } - - func encode() throws -> Data { + public func encode() throws -> Data { return try JSONEncoder().encode(self) } } diff --git a/ios/TunnelProviderMessaging/TunnelProviderReply.swift b/ios/TunnelProviderMessaging/TunnelProviderReply.swift new file mode 100644 index 0000000000..4e0b188185 --- /dev/null +++ b/ios/TunnelProviderMessaging/TunnelProviderReply.swift @@ -0,0 +1,26 @@ +// +// TunnelProviderReply.swift +// TunnelProviderMessaging +// +// Created by pronebird on 20/10/2022. +// Copyright © 2022 Mullvad VPN AB. All rights reserved. +// + +import Foundation + +/// Container type for tunnel provider reply. +public struct TunnelProviderReply<T: Codable>: Codable { + public var value: T + + public init(_ value: T) { + self.value = value + } + + public init(messageData: Data) throws { + self = try JSONDecoder().decode(Self.self, from: messageData) + } + + public func encode() throws -> Data { + return try JSONEncoder().encode(self) + } +} |
