blob: 7bd32527ae2577cf452ed8d92b2bce69c1a522ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
//
// ProxyConfigurationTester.swift
// MullvadVPN
//
// Created by pronebird on 28/11/2023.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//
import Combine
import Foundation
import MullvadREST
import MullvadSettings
import MullvadTypes
/// A concrete implementation of an access method proxy configuration.
class ProxyConfigurationTester: ProxyConfigurationTesterProtocol {
private var cancellable: MullvadTypes.Cancellable?
private let apiProxy: APIQuerying
init(apiProxy: APIQuerying) {
self.apiProxy = apiProxy
}
func start(configuration: PersistentAccessMethod, completion: @escaping @Sendable (Error?) -> Void) {
cancellable = apiProxy.checkApiAvailability(retryStrategy: .noRetry, accessMethod: configuration) { success in
switch success {
case .success: completion(nil)
case let .failure(error): completion(error)
}
}
}
func cancel() {
cancellable?.cancel()
cancellable = nil
}
}
|