diff options
| author | Bug Magnet <marco.nikic@mullvad.net> | 2024-06-10 08:17:42 +0200 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2024-06-10 08:17:42 +0200 |
| commit | 5f1dcf7478447e7c2377450d2275ac8580739997 (patch) | |
| tree | cb2665c0ebb2c3b3c36185ee7c0f763d4c1587bb | |
| parent | 8a7bc6ab42b627c99cac79905391f0a267bc64cf (diff) | |
| parent | 5be80b767528d0c13e7dbad68c264c204771b926 (diff) | |
| download | mullvadvpn-5f1dcf7478447e7c2377450d2275ac8580739997.tar.xz mullvadvpn-5f1dcf7478447e7c2377450d2275ac8580739997.zip | |
Merge branch 'ios-680-make-amimullvadnet-work-on-staging'
| -rw-r--r-- | ios/Configurations/Api.xcconfig.template | 13 | ||||
| -rw-r--r-- | ios/MullvadVPN/GeneralAPIs/OutgoingConnectionProxy.swift | 12 | ||||
| -rw-r--r-- | ios/MullvadVPN/SceneDelegate.swift | 5 | ||||
| -rw-r--r-- | ios/MullvadVPN/Supporting Files/Info.plist | 2 | ||||
| -rw-r--r-- | ios/MullvadVPNTests/MullvadVPN/GeneralAPIs/OutgoingConnectionProxyTests.swift | 11 | ||||
| -rw-r--r-- | ios/PacketTunnel/Info.plist | 2 | ||||
| -rw-r--r-- | ios/Shared/ApplicationConfiguration.swift | 11 |
7 files changed, 38 insertions, 18 deletions
diff --git a/ios/Configurations/Api.xcconfig.template b/ios/Configurations/Api.xcconfig.template index 99d1fc1fc1..cddd4f815a 100644 --- a/ios/Configurations/Api.xcconfig.template +++ b/ios/Configurations/Api.xcconfig.template @@ -1,7 +1,12 @@ -API_HOST_NAME[config=Debug] = api.mullvad.net -API_HOST_NAME[config=Release] = api.mullvad.net -API_HOST_NAME[config=MockRelease] = api.mullvad.net -API_HOST_NAME[config=Staging] = api.stagemole.eu +HOST_NAME[config=Debug] = mullvad.net +HOST_NAME[config=Release] = mullvad.net +HOST_NAME[config=MockRelease] = mullvad.net +HOST_NAME[config=Staging] = stagemole.eu + +API_HOST_NAME[config=Debug] = api.$(HOST_NAME) +API_HOST_NAME[config=Release] = api.$(HOST_NAME) +API_HOST_NAME[config=MockRelease] = api.$(HOST_NAME) +API_HOST_NAME[config=Staging] = api.$(HOST_NAME) API_ENDPOINT[config=Debug] = 45.83.223.196:443 API_ENDPOINT[config=Release] = 45.83.223.196:443 diff --git a/ios/MullvadVPN/GeneralAPIs/OutgoingConnectionProxy.swift b/ios/MullvadVPN/GeneralAPIs/OutgoingConnectionProxy.swift index 233bd4d763..67b347d1e8 100644 --- a/ios/MullvadVPN/GeneralAPIs/OutgoingConnectionProxy.swift +++ b/ios/MullvadVPN/GeneralAPIs/OutgoingConnectionProxy.swift @@ -20,15 +20,17 @@ final class OutgoingConnectionProxy: OutgoingConnectionHandling { enum ExitIPVersion: String { case v4 = "ipv4", v6 = "ipv6" - var host: String { - "\(rawValue).am.i.mullvad.net" + func host(hostname: String) -> String { + "\(rawValue).am.i.\(hostname)" } } let urlSession: URLSessionProtocol + let hostname: String - init(urlSession: URLSessionProtocol) { + init(urlSession: URLSessionProtocol, hostname: String) { self.urlSession = urlSession + self.hostname = hostname } func getIPV6(retryStrategy: REST.RetryStrategy) async throws -> IPV6ConnectionData { @@ -43,7 +45,7 @@ final class OutgoingConnectionProxy: OutgoingConnectionHandling { let delayIterator = retryStrategy.makeDelayIterator() for _ in 0 ..< retryStrategy.maxRetryCount { do { - return try await perform(host: version.host) + return try await perform(host: version.host(hostname: hostname)) } catch { // ignore if request is cancelled if case URLError.cancelled = error { @@ -57,7 +59,7 @@ final class OutgoingConnectionProxy: OutgoingConnectionHandling { } } } - return try await perform(host: version.host) + return try await perform(host: version.host(hostname: hostname)) } private func perform<T: Decodable>(host: String) async throws -> T { diff --git a/ios/MullvadVPN/SceneDelegate.swift b/ios/MullvadVPN/SceneDelegate.swift index 6105d06fdf..d70b631b37 100644 --- a/ios/MullvadVPN/SceneDelegate.swift +++ b/ios/MullvadVPN/SceneDelegate.swift @@ -73,7 +73,10 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, SettingsMigrationUIHand devicesProxy: appDelegate.devicesProxy, accountsProxy: appDelegate.accountsProxy, outgoingConnectionService: OutgoingConnectionService( - outgoingConnectionProxy: OutgoingConnectionProxy(urlSession: URLSession(configuration: .ephemeral)) + outgoingConnectionProxy: OutgoingConnectionProxy( + urlSession: URLSession(configuration: .ephemeral), + hostname: ApplicationConfiguration.hostName + ) ), appPreferences: AppPreferences(), accessMethodRepository: accessMethodRepository, diff --git a/ios/MullvadVPN/Supporting Files/Info.plist b/ios/MullvadVPN/Supporting Files/Info.plist index b6b1ffa003..64cc53a997 100644 --- a/ios/MullvadVPN/Supporting Files/Info.plist +++ b/ios/MullvadVPN/Supporting Files/Info.plist @@ -2,6 +2,8 @@ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> + <key>HostName</key> + <string>$(HOST_NAME)</string> <key>NSLocalNetworkUsageDescription</key> <string>The app needs this to connect and test a new method.</string> <key>ApplicationSecurityGroupIdentifier</key> diff --git a/ios/MullvadVPNTests/MullvadVPN/GeneralAPIs/OutgoingConnectionProxyTests.swift b/ios/MullvadVPNTests/MullvadVPN/GeneralAPIs/OutgoingConnectionProxyTests.swift index 2ffdbdf92d..1d0bd39506 100644 --- a/ios/MullvadVPNTests/MullvadVPN/GeneralAPIs/OutgoingConnectionProxyTests.swift +++ b/ios/MullvadVPNTests/MullvadVPN/GeneralAPIs/OutgoingConnectionProxyTests.swift @@ -11,6 +11,7 @@ import XCTest final class OutgoingConnectionProxyTests: XCTestCase { private var mockIPV6ConnectionData: Data! private var mockIPV4ConnectionData: Data! + private let hostname = "mullvad.net" private let encoder = JSONEncoder() @@ -29,7 +30,7 @@ final class OutgoingConnectionProxyTests: XCTestCase { let outgoingConnectionProxy = OutgoingConnectionProxy(urlSession: URLSessionStub( response: (mockIPV4ConnectionData, createHTTPURLResponse(ip: .v4, statusCode: 200)) - )) + ), hostname: hostname) let result = try await outgoingConnectionProxy.getIPV4(retryStrategy: .noRetry) @@ -44,7 +45,7 @@ final class OutgoingConnectionProxyTests: XCTestCase { let outgoingConnectionProxy = OutgoingConnectionProxy(urlSession: URLSessionStub( response: (Data(), createHTTPURLResponse(ip: .v4, statusCode: 503)) - )) + ), hostname: hostname) await XCTAssertThrowsErrorAsync(try await outgoingConnectionProxy.getIPV4(retryStrategy: .noRetry)) { _ in noIPv4Expectation.fulfill() @@ -57,7 +58,7 @@ final class OutgoingConnectionProxyTests: XCTestCase { let outgoingConnectionProxy = OutgoingConnectionProxy(urlSession: URLSessionStub( response: (mockIPV6ConnectionData, createHTTPURLResponse(ip: .v6, statusCode: 200)) - )) + ), hostname: hostname) let result = try await outgoingConnectionProxy.getIPV6(retryStrategy: .noRetry) @@ -72,7 +73,7 @@ final class OutgoingConnectionProxyTests: XCTestCase { let outgoingConnectionProxy = OutgoingConnectionProxy(urlSession: URLSessionStub( response: (mockIPV6ConnectionData, createHTTPURLResponse(ip: .v6, statusCode: 404)) - )) + ), hostname: hostname) await XCTAssertThrowsErrorAsync(try await outgoingConnectionProxy.getIPV6(retryStrategy: .noRetry)) { _ in noIPv6Expectation.fulfill() @@ -84,7 +85,7 @@ final class OutgoingConnectionProxyTests: XCTestCase { extension OutgoingConnectionProxyTests { private func createHTTPURLResponse(ip: OutgoingConnectionProxy.ExitIPVersion, statusCode: Int) -> HTTPURLResponse { return HTTPURLResponse( - url: URL(string: "https://\(ip.host)/json")!, + url: URL(string: "https://\(ip.host(hostname: hostname))/json")!, statusCode: statusCode, httpVersion: nil, headerFields: ["Content-Type": "application/json"] diff --git a/ios/PacketTunnel/Info.plist b/ios/PacketTunnel/Info.plist index f6e4c63b45..35b671be8f 100644 --- a/ios/PacketTunnel/Info.plist +++ b/ios/PacketTunnel/Info.plist @@ -2,6 +2,8 @@ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> + <key>HostName</key> + <string>$(HOST_NAME)</string> <key>ApplicationSecurityGroupIdentifier</key> <string>$(SECURITY_GROUP_IDENTIFIER)</string> <key>MainApplicationIdentifier</key> diff --git a/ios/Shared/ApplicationConfiguration.swift b/ios/Shared/ApplicationConfiguration.swift index 403c6ff7fa..ed1b00b2e0 100644 --- a/ios/Shared/ApplicationConfiguration.swift +++ b/ios/Shared/ApplicationConfiguration.swift @@ -10,6 +10,11 @@ import Foundation import Network enum ApplicationConfiguration { + static var hostName: String { + // swiftlint:disable:next force_cast + Bundle.main.object(forInfoDictionaryKey: "HostName") as! String + } + /// Shared container security group identifier. static var securityGroupIdentifier: String { // swiftlint:disable:next force_cast @@ -59,13 +64,13 @@ enum ApplicationConfiguration { static let logMaximumFileSize: UInt64 = 131_072 // 128 kB. /// Privacy policy URL. - static let privacyPolicyURL = URL(string: "https://mullvad.net/help/privacy-policy/")! + static let privacyPolicyURL = URL(string: "https://\(Self.hostName)/help/privacy-policy/")! /// Make a start regarding policy URL. - static let privacyGuidesURL = URL(string: "https://mullvad.net/help/first-steps-towards-online-privacy/")! + static let privacyGuidesURL = URL(string: "https://\(Self.hostName)/help/first-steps-towards-online-privacy/")! /// FAQ & Guides URL. - static let faqAndGuidesURL = URL(string: "https://mullvad.net/help/tag/mullvad-app/")! + static let faqAndGuidesURL = URL(string: "https://\(Self.hostName)/help/tag/mullvad-app/")! /// Maximum number of devices per account. static let maxAllowedDevices = 5 |
