blob: 7f59ab00c34f6f43dbe166c3d7763363eb2e5226 (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
//
// AccessMethodKind.swift
// MullvadVPN
//
// Created by pronebird on 02/11/2023.
// Copyright © 2023 Mullvad VPN AB. All rights reserved.
//
import Foundation
/// A kind of API access method.
public enum AccessMethodKind: Equatable, Hashable, CaseIterable {
/// Direct communication.
case direct
/// Communication over bridges.
case bridges
/// Communication over proxy address from a DNS.
case encryptedDNS
/// Communication over shadowsocks.
case shadowsocks
/// Communication over socks v5 proxy.
case socks5
}
public extension AccessMethodKind {
/// Returns `true` if the method is permanent and cannot be deleted.
var isPermanent: Bool {
switch self {
case .direct, .bridges, .encryptedDNS:
true
case .shadowsocks, .socks5:
false
}
}
/// Returns all access method kinds that can be added by user.
static var allUserDefinedKinds: [AccessMethodKind] {
allCases.filter { !$0.isPermanent }
}
}
extension PersistentAccessMethod {
/// A kind of access method.
public var kind: AccessMethodKind {
switch proxyConfiguration {
case .direct:
.direct
case .bridges:
.bridges
case .encryptedDNS:
.encryptedDNS
case .shadowsocks:
.shadowsocks
case .socks5:
.socks5
}
}
}
|