summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/TunnelManager/TunnelInteractor.swift
blob: ba798107a19acb9df43812f57ddc433667210506 (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
38
39
40
41
42
43
44
45
//
//  TunnelInteractor.swift
//  MullvadVPN
//
//  Created by pronebird on 05/07/2022.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import Foundation
import MullvadREST
import MullvadSettings
import MullvadTypes
import PacketTunnelCore

protocol TunnelInteractor {
    // MARK: - Tunnel manipulation

    var tunnel: (any TunnelProtocol)? { get }
    var backgroundTaskProvider: BackgroundTaskProviding { get }

    func getPersistentTunnels() -> [any TunnelProtocol]
    func createNewTunnel() -> any TunnelProtocol
    func setTunnel(_ tunnel: (any TunnelProtocol)?, shouldRefreshTunnelState: Bool)

    // MARK: - Tunnel status

    var tunnelStatus: TunnelStatus { get }
    @discardableResult func updateTunnelStatus(_ block: @Sendable (inout TunnelStatus) -> Void) -> TunnelStatus

    // MARK: - Configuration

    var isConfigurationLoaded: Bool { get }
    var settings: LatestTunnelSettings { get }
    var deviceState: DeviceState { get }

    func setConfigurationLoaded()
    func setSettings(_ settings: LatestTunnelSettings, persist: Bool)
    func setDeviceState(_ deviceState: DeviceState, persist: Bool)
    func removeLastUsedAccount()
    func handleRestError(_ error: Error)

    func startTunnel()
    func prepareForVPNConfigurationDeletion()
    func selectRelays() throws -> SelectedRelays
}