Skip to content

Commit d197a1a

Browse files
committed
Remove remainders of AddressCache
1 parent 425f1a4 commit d197a1a

File tree

11 files changed

+8
-348
lines changed

11 files changed

+8
-348
lines changed

ios/MullvadREST/ApiHandlers/AddressCache.swift

Lines changed: 0 additions & 132 deletions
This file was deleted.

ios/MullvadREST/ApiHandlers/RESTDefaults.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import MullvadTypes
1313
extension REST {
1414
/// The API hostname and endpoint are defined in the Info.plist of the MullvadREST framework bundle
1515
/// This is due to not being able to target `Bundle.main` from a Unit Test environment as it gets its own bundle that would not contain the above variables.
16-
nonisolated(unsafe) private static let infoDictionary = Bundle(for: AddressCache.self).infoDictionary!
16+
nonisolated(unsafe) private static let infoDictionary = Bundle(for: ProxyFactory.self).infoDictionary!
1717

1818
/// Default API hostname.
1919
public static let defaultAPIHostname = infoDictionary["ApiHostName"] as! String

ios/MullvadREST/ApiHandlers/RESTURLSession.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ import Foundation
1010
import Network
1111

1212
extension REST {
13-
public static func makeURLSession(addressCache: AddressCache) -> URLSession {
13+
public static func makeURLSession() -> URLSession {
1414
let certificatePath = Bundle(for: SSLPinningURLSessionDelegate.self)
1515
.path(forResource: "le_root_cert", ofType: "cer")!
1616
let data = FileManager.default.contents(atPath: certificatePath)!
1717
let secCertificate = SecCertificateCreateWithData(nil, data as CFData)!
1818

1919
let sessionDelegate = SSLPinningURLSessionDelegate(
2020
sslHostname: defaultAPIHostname,
21-
trustedRootCertificates: [secCertificate],
22-
addressCache: addressCache
21+
trustedRootCertificates: [secCertificate]
2322
)
2423

2524
let sessionConfiguration = URLSessionConfiguration.ephemeral

ios/MullvadREST/ApiHandlers/SSLPinningURLSessionDelegate.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ import Security
1414
final class SSLPinningURLSessionDelegate: NSObject, URLSessionDelegate, @unchecked Sendable {
1515
private let sslHostname: String
1616
private let trustedRootCertificates: [SecCertificate]
17-
private let addressCache: REST.AddressCache
1817

1918
private let logger = Logger(label: "SSLPinningURLSessionDelegate")
2019

21-
init(sslHostname: String, trustedRootCertificates: [SecCertificate], addressCache: REST.AddressCache) {
20+
init(sslHostname: String, trustedRootCertificates: [SecCertificate]) {
2221
self.sslHostname = sslHostname
2322
self.trustedRootCertificates = trustedRootCertificates
24-
self.addressCache = addressCache
2523
}
2624

2725
// MARK: - URLSessionDelegate
@@ -39,13 +37,9 @@ final class SSLPinningURLSessionDelegate: NSObject, URLSessionDelegate, @uncheck
3937
/// The same goes for direct connections to the API, the host would be the IP address of the endpoint.
4038
/// Certificates, cannot be signed for IP addresses, in such case, specify that the host name is `defaultAPIHostname`
4139
var hostName = challenge.protectionSpace.host
42-
let overridenHostnames = [
43-
"\(IPv4Address.loopback)",
44-
"\(IPv6Address.loopback)",
45-
"\(REST.defaultAPIEndpoint.ip)",
46-
"\(addressCache.getCurrentEndpoint().ip)",
47-
]
48-
if overridenHostnames.contains(hostName) {
40+
// this used to check for the current endpoint in the address cache as well, though this has been deprecated.
41+
42+
if hostName == "\(REST.defaultAPIEndpoint.ip)" {
4943
hostName = sslHostname
5044
}
5145

ios/MullvadRESTTests/Mocks/MemoryCache.swift

Lines changed: 0 additions & 24 deletions
This file was deleted.

ios/MullvadRESTTests/MullvadApiTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import XCTest
1919

2020
class MullvadApiTests: XCTestCase {
2121
let encoder = JSONEncoder()
22-
let addressCache = REST.AddressCache(canWriteToCache: false, fileCache: MemoryCache())
2322

2423
func makeApiProxy(port: UInt16) throws -> APIQuerying {
2524
let shadowsocksLoader = ShadowsocksLoaderStub(
@@ -43,7 +42,6 @@ class MullvadApiTests: XCTestCase {
4342
accessMethodsRepository
4443
.fetchAll()
4544
),
46-
addressCacheProvider: addressCache,
4745
accessMethodChangeListeners: []
4846
)
4947

0 commit comments

Comments
 (0)