blob: f282b83f8be11f2ee68d9fb329881dd18c47f809 (
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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
//
// TunnelManagerError.swift
// TunnelManagerError
//
// Created by pronebird on 07/09/2021.
// Copyright © 2021 Mullvad VPN AB. All rights reserved.
//
import Foundation
extension TunnelManager {
/// An error emitted by all public methods of TunnelManager
enum Error: ChainedError {
/// Account token is not set
case missingAccount
/// A failure to start the VPN tunnel via system call
case startVPNTunnel(Swift.Error)
/// A failure to load the system VPN configurations created by the app
case loadAllVPNConfigurations(Swift.Error)
/// A failure to save the system VPN configuration
case saveVPNConfiguration(Swift.Error)
/// A failure to reload the system VPN configuration
case reloadVPNConfiguration(Swift.Error)
/// A failure to remove the system VPN configuration
case removeVPNConfiguration(Swift.Error)
/// A failure to perform a recovery (by removing the VPN configuration) when a corrupt
/// VPN configuration is detected.
case removeInconsistentVPNConfiguration(Swift.Error)
/// A failure to read tunnel settings
case readTunnelSettings(TunnelSettingsManager.Error)
/// A failure to read relays cache
case readRelays(RelayCache.Error)
/// A failure to find a relay satisfying the given constraints
case cannotSatisfyRelayConstraints
/// A failure to add the tunnel settings
case addTunnelSettings(TunnelSettingsManager.Error)
/// A failure to update the tunnel settings
case updateTunnelSettings(TunnelSettingsManager.Error)
/// A failure to remove the tunnel settings from Keychain
case removeTunnelSettings(TunnelSettingsManager.Error)
/// A failure to migrate tunnel settings
case migrateTunnelSettings(TunnelSettingsManager.Error)
/// Unable to obtain the persistent keychain reference for the tunnel settings
case obtainPersistentKeychainReference(TunnelSettingsManager.Error)
/// A failure to push the public WireGuard key
case pushWireguardKey(REST.Error)
/// A failure to replace the public WireGuard key
case replaceWireguardKey(REST.Error)
/// A failure to remove the public WireGuard key
case removeWireguardKey(REST.Error)
/// A failure to schedule background task
case backgroundTaskScheduler(Swift.Error)
var errorDescription: String? {
switch self {
case .missingAccount:
return "Missing account token"
case .startVPNTunnel:
return "Failed to start the VPN tunnel"
case .loadAllVPNConfigurations:
return "Failed to load the system VPN configurations"
case .saveVPNConfiguration:
return "Failed to save the system VPN configuration"
case .reloadVPNConfiguration:
return "Failed to reload the system VPN configuration"
case .removeVPNConfiguration:
return "Failed to remove the system VPN configuration"
case .removeInconsistentVPNConfiguration:
return "Failed to remove the inconsistent VPN tunnel"
case .readTunnelSettings:
return "Failed to read the tunnel settings"
case .readRelays:
return "Failed to read relays"
case .cannotSatisfyRelayConstraints:
return "Failed to satisfy the relay constraints"
case .addTunnelSettings:
return "Failed to add the tunnel settings"
case .updateTunnelSettings:
return "Failed to update the tunnel settings"
case .removeTunnelSettings:
return "Failed to remove the tunnel settings"
case .migrateTunnelSettings:
return "Failed to migrate the tunnel settings"
case .obtainPersistentKeychainReference:
return "Failed to obtain the persistent keychain reference"
case .pushWireguardKey:
return "Failed to push the WireGuard key to server"
case .replaceWireguardKey:
return "Failed to replace the WireGuard key on server"
case .removeWireguardKey:
return "Failed to remove the WireGuard key from server"
case .backgroundTaskScheduler:
return "Failed to schedule background task"
}
}
}
}
|