-
Notifications
You must be signed in to change notification settings - Fork 357
/
ChipFeature.swift
87 lines (70 loc) · 1.71 KB
/
ChipFeature.swift
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// ChipFeature.swift
// MullvadVPN
//
// Created by Mojgan on 2024-12-06.
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//
import MullvadSettings
import SwiftUI
protocol ChipFeature {
var isEnabled: Bool { get }
var name: String { get }
}
struct DaitaFeature: ChipFeature {
let settings: LatestTunnelSettings
var isEnabled: Bool {
settings.daita.daitaState.isEnabled
}
var name: String {
String("DAITA")
}
}
struct QuantumResistanceFeature: ChipFeature {
let settings: LatestTunnelSettings
var isEnabled: Bool {
settings.tunnelQuantumResistance.isEnabled
}
var name: String {
String("Quantum resistance")
}
}
struct MultihopFeature: ChipFeature {
let settings: LatestTunnelSettings
var isEnabled: Bool {
settings.tunnelMultihopState.isEnabled
}
var name: String {
String("Multihop")
}
}
struct ObfuscationFeature: ChipFeature {
let settings: LatestTunnelSettings
var isEnabled: Bool {
settings.wireGuardObfuscation.state.isEnabled
}
var name: String {
String("Obfuscation")
}
}
struct DNSFeature: ChipFeature {
let settings: LatestTunnelSettings
var isEnabled: Bool {
settings.dnsSettings.enableCustomDNS || !settings.dnsSettings.blockingOptions.isEmpty
}
var name: String {
if !settings.dnsSettings.blockingOptions.isEmpty {
return String("DNS content blockers")
}
return String("Custom DNS")
}
}
struct IPOverrideFeature: ChipFeature {
let overrides: [IPOverride]
var isEnabled: Bool {
!overrides.isEmpty
}
var name: String {
String("Server IP override")
}
}