Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix connection method test ios 843 #6875

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ import MullvadTypes
public class ProxyConfigurationTransportProvider {
private let shadowsocksLoader: ShadowsocksLoaderProtocol
private let addressCache: REST.AddressCache
private let encryptedDNSTransport: RESTTransport

public init(shadowsocksLoader: ShadowsocksLoaderProtocol, addressCache: REST.AddressCache) {
public init(
shadowsocksLoader: ShadowsocksLoaderProtocol,
addressCache: REST.AddressCache,
encryptedDNSTransport: RESTTransport
) {
self.shadowsocksLoader = shadowsocksLoader
self.addressCache = addressCache
self.encryptedDNSTransport = encryptedDNSTransport
}

public func makeTransport(with configuration: PersistentProxyConfiguration) throws -> RESTTransport {
Expand All @@ -33,7 +39,7 @@ public class ProxyConfigurationTransportProvider {
addressCache: addressCache
)
case .encryptedDNS:
return EncryptedDNSTransport(urlSession: urlSession)
return encryptedDNSTransport
case let .shadowsocks(shadowSocksConfiguration):
return ShadowsocksTransport(
urlSession: urlSession,
Expand Down
9 changes: 5 additions & 4 deletions ios/MullvadREST/Transport/TransportProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ public final class TransportProvider: RESTTransportProvider {
private var currentTransport: RESTTransport?
private var currentTransportType: TransportStrategy.Transport
private let parallelRequestsMutex = NSLock()
private let encryptedDNSTransport: EncryptedDNSTransport
private let encryptedDNSTransport: RESTTransport

public init(
urlSessionTransport: URLSessionTransport,
addressCache: REST.AddressCache,
transportStrategy: TransportStrategy
transportStrategy: TransportStrategy,
encryptedDNSTransport: RESTTransport
) {
self.urlSessionTransport = urlSessionTransport
self.addressCache = addressCache
self.transportStrategy = transportStrategy
self.currentTransportType = transportStrategy.connectionTransport()
self.encryptedDNSTransport = EncryptedDNSTransport(urlSession: urlSessionTransport.urlSession)
self.encryptedDNSTransport = encryptedDNSTransport
}

public func makeTransport() -> RESTTransport? {
Expand Down Expand Up @@ -56,7 +57,7 @@ public final class TransportProvider: RESTTransportProvider {

if strategy == transportStrategy {
if strategy.connectionTransport() == .encryptedDNS {
encryptedDNSTransport.stop()
(encryptedDNSTransport as? EncryptedDNSTransport)?.stop()
}
transportStrategy.didFail()
currentTransport = nil
Expand Down
2 changes: 2 additions & 0 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@
A9B6AC1B2ADEA3AD00F7802A /* MemoryCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58BDEB9C2A98F69E00F578F2 /* MemoryCache.swift */; };
A9BA08312BA32FA9005A7A2D /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = A92962582B1F4FDB00DFB93B /* PrivacyInfo.xcprivacy */; };
A9BA08322BA32FB6005A7A2D /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = A92962582B1F4FDB00DFB93B /* PrivacyInfo.xcprivacy */; };
A9BD4D552CA58C3700C8A0E6 /* RESTTransportStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = A932D9F42B5EBB9D00999395 /* RESTTransportStub.swift */; };
A9BFAFFF2BD004ED00F2BCA1 /* CustomListsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BFAFFE2BD004ED00F2BCA1 /* CustomListsTests.swift */; };
A9BFB0012BD00B7F00F2BCA1 /* CustomListPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BFB0002BD00B7F00F2BCA1 /* CustomListPage.swift */; };
A9C342C12ACC37E30045F00E /* TunnelStatusBlockObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E0317D2ACC32920095D843 /* TunnelStatusBlockObserver.swift */; };
Expand Down Expand Up @@ -5426,6 +5427,7 @@
A9A5FA312ACB05160083449F /* MockFileCache.swift in Sources */,
A9A5FA322ACB05160083449F /* RelayCacheTests.swift in Sources */,
A9A5FA332ACB05160083449F /* RelaySelectorTests.swift in Sources */,
A9BD4D552CA58C3700C8A0E6 /* RESTTransportStub.swift in Sources */,
F073FCB32C6617D70062EA1D /* TunnelStore+Stubs.swift in Sources */,
58DFF7D32B02570000F864E0 /* MarkdownStylingOptions.swift in Sources */,
A9A5FA342ACB05160083449F /* StringTests.swift in Sources */,
Expand Down
9 changes: 7 additions & 2 deletions ios/MullvadVPN/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
private(set) var configuredTransportProvider: ProxyConfigurationTransportProvider!
private(set) var ipOverrideRepository = IPOverrideRepository()
private var launchArguments = LaunchArguments()
private var encryptedDNSTransport: EncryptedDNSTransport!

// MARK: - Application lifecycle

Expand Down Expand Up @@ -121,9 +122,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
settingsUpdater: tunnelSettingsUpdater
)

encryptedDNSTransport = EncryptedDNSTransport(urlSession: urlSessionTransport.urlSession)

configuredTransportProvider = ProxyConfigurationTransportProvider(
shadowsocksLoader: shadowsocksLoader,
addressCache: addressCache
addressCache: addressCache,
encryptedDNSTransport: encryptedDNSTransport
)

let transportStrategy = TransportStrategy(
Expand All @@ -134,7 +138,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
let transportProvider = TransportProvider(
urlSessionTransport: urlSessionTransport,
addressCache: addressCache,
transportStrategy: transportStrategy
transportStrategy: transportStrategy,
encryptedDNSTransport: encryptedDNSTransport
)
setUpTransportMonitor(transportProvider: transportProvider)
setUpSimulatorHost(transportProvider: transportProvider, relaySelector: relaySelector)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class TunnelManagerTests: XCTestCase {
relaySelector: ShadowsocksRelaySelectorStub(relays: .mock()),
settingsUpdater: SettingsUpdater(listener: TunnelSettingsListener())
)
)
), encryptedDNSTransport: RESTTransportStub()
)

try SettingsManager.writeSettings(LatestTunnelSettings())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
private var relaySelector: RelaySelectorWrapper!
private var ephemeralPeerExchangingPipeline: EphemeralPeerExchangingPipeline!
private let tunnelSettingsUpdater: SettingsUpdater!
private var encryptedDNSTransport: EncryptedDNSTransport!

private let tunnelSettingsListener = TunnelSettingsListener()
private lazy var ephemeralPeerReceiver = {
Expand Down Expand Up @@ -189,10 +190,12 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
)
)

encryptedDNSTransport = EncryptedDNSTransport(urlSession: urlSession)
return TransportProvider(
urlSessionTransport: urlSessionTransport,
addressCache: addressCache,
transportStrategy: transportStrategy
transportStrategy: transportStrategy,
encryptedDNSTransport: encryptedDNSTransport
)
}
}
Expand Down
Loading