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

import Foundation
import MullvadSettings

protocol ShadowsocksObfuscationSettingsViewModel: ObservableObject {
    var value: WireGuardObfuscationShadowsocksPort { get set }

    func commit()
}

/** A simple mock view model for use in Previews and similar */
class MockShadowsocksObfuscationSettingsViewModel: ShadowsocksObfuscationSettingsViewModel {
    @Published var value: WireGuardObfuscationShadowsocksPort

    init(shadowsocksPort: WireGuardObfuscationShadowsocksPort = .automatic) {
        self.value = shadowsocksPort
    }

    func commit() {}
}

/// ** The live view model which interfaces with the TunnelManager  */
class TunnelShadowsocksObfuscationSettingsViewModel: TunnelObfuscationSettingsWatchingObservableObject<
    WireGuardObfuscationShadowsocksPort
>,
ShadowsocksObfuscationSettingsViewModel
{
    init(tunnelManager: TunnelManager) {
        super.init(
            tunnelManager: tunnelManager,
            keyPath: \.shadowsocksPort
        )
    }
}