summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/View controllers/Settings/Obfuscation/UDPOverTCPObfuscationSettingsViewModel.swift
blob: a9d32bf778030bfdb63018b96aeec0ac1f586ef4 (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
//
//  UDPOverTCPObfuscationSettingsViewModel.swift
//  MullvadVPN
//
//  Created by Andrew Bulhak on 2024-11-05.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import Foundation
import MullvadSettings

protocol UDPOverTCPObfuscationSettingsViewModel: ObservableObject {
    var value: WireGuardObfuscationUdpOverTcpPort { get set }

    func commit()
}

/** A simple mock view model for use in Previews and similar */
class MockUDPOverTCPObfuscationSettingsViewModel: UDPOverTCPObfuscationSettingsViewModel {
    @Published var value: WireGuardObfuscationUdpOverTcpPort

    init(udpTcpPort: WireGuardObfuscationUdpOverTcpPort = .automatic) {
        self.value = udpTcpPort
    }

    func commit() {}
}

/** The live view model which interfaces with the TunnelManager  */
class TunnelUDPOverTCPObfuscationSettingsViewModel: TunnelObfuscationSettingsWatchingObservableObject<
    WireGuardObfuscationUdpOverTcpPort
>,
UDPOverTCPObfuscationSettingsViewModel
{
    init(tunnelManager: TunnelManager) {
        super.init(
            tunnelManager: tunnelManager,
            keyPath: \.udpOverTcpPort
        )
    }
}