VPN: Better error messages
This commit is contained in:
parent
0ef0eeb116
commit
495b017449
|
@ -165,11 +165,19 @@ extension TunnelDetailTableViewController {
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: TunnelDetailTableViewStatusCell.id, for: indexPath) as! TunnelDetailTableViewStatusCell
|
let cell = tableView.dequeueReusableCell(withIdentifier: TunnelDetailTableViewStatusCell.id, for: indexPath) as! TunnelDetailTableViewStatusCell
|
||||||
cell.tunnel = self.tunnel
|
cell.tunnel = self.tunnel
|
||||||
cell.onSwitchToggled = { [weak self] isOn in
|
cell.onSwitchToggled = { [weak self] isOn in
|
||||||
cell.isSwitchInteractionEnabled = false
|
|
||||||
guard let s = self else { return }
|
guard let s = self else { return }
|
||||||
if (isOn) {
|
if (isOn) {
|
||||||
s.tunnelsManager.startActivation(of: s.tunnel) { error in
|
s.tunnelsManager.startActivation(of: s.tunnel) { [weak self] error in
|
||||||
print("Error while activating: \(String(describing: error))")
|
if let error = error {
|
||||||
|
switch (error) {
|
||||||
|
case TunnelsManagerError.noEndpoint:
|
||||||
|
self?.showErrorAlert(title: "Endpoint missing", message: "There must be atleast one peer with an endpoint")
|
||||||
|
case TunnelsManagerError.dnsResolutionFailed:
|
||||||
|
self?.showErrorAlert(title: "DNS Failure", message: "One or more endpoint domains could not be resolved")
|
||||||
|
default:
|
||||||
|
self?.showErrorAlert(title: "Internal error", message: "The tunnel could not be activated")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s.tunnelsManager.startDeactivation(of: s.tunnel) { error in
|
s.tunnelsManager.startDeactivation(of: s.tunnel) { error in
|
||||||
|
|
|
@ -232,7 +232,16 @@ extension TunnelsListTableViewController {
|
||||||
guard let s = self, let tunnelsManager = s.tunnelsManager else { return }
|
guard let s = self, let tunnelsManager = s.tunnelsManager else { return }
|
||||||
if (isOn) {
|
if (isOn) {
|
||||||
tunnelsManager.startActivation(of: tunnel) { error in
|
tunnelsManager.startActivation(of: tunnel) { error in
|
||||||
print("Error while activating: \(String(describing: error))")
|
if let error = error {
|
||||||
|
switch (error) {
|
||||||
|
case TunnelsManagerError.noEndpoint:
|
||||||
|
self?.showErrorAlert(title: "Endpoint missing", message: "There must be atleast one peer with an endpoint")
|
||||||
|
case TunnelsManagerError.dnsResolutionFailed:
|
||||||
|
self?.showErrorAlert(title: "DNS Failure", message: "One or more endpoint domains could not be resolved")
|
||||||
|
default:
|
||||||
|
self?.showErrorAlert(title: "Internal error", message: "The tunnel could not be activated")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tunnelsManager.startDeactivation(of: tunnel) { error in
|
tunnelsManager.startDeactivation(of: tunnel) { error in
|
||||||
|
|
|
@ -265,6 +265,7 @@ class TunnelContainer: NSObject {
|
||||||
if let endpoints = dnsResolver.resolveWithoutNetworkRequests() {
|
if let endpoints = dnsResolver.resolveWithoutNetworkRequests() {
|
||||||
guard (endpoints.contains(where: { $0 != nil })) else {
|
guard (endpoints.contains(where: { $0 != nil })) else {
|
||||||
completionHandler(TunnelsManagerError.noEndpoint)
|
completionHandler(TunnelsManagerError.noEndpoint)
|
||||||
|
status = .inactive
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.tunnelProvider.loadFromPreferences { [weak self] (error) in
|
self.tunnelProvider.loadFromPreferences { [weak self] (error) in
|
||||||
|
@ -278,7 +279,10 @@ class TunnelContainer: NSObject {
|
||||||
} catch (let error) {
|
} catch (let error) {
|
||||||
os_log("Failed to activate tunnel: %{public}@", log: OSLog.default, type: .debug, "\(error)")
|
os_log("Failed to activate tunnel: %{public}@", log: OSLog.default, type: .debug, "\(error)")
|
||||||
completionHandler(error)
|
completionHandler(error)
|
||||||
|
s.status = .inactive
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
completionHandler(nil)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.dnsResolver = dnsResolver
|
self.dnsResolver = dnsResolver
|
||||||
|
@ -302,7 +306,8 @@ class TunnelContainer: NSObject {
|
||||||
try session.startTunnel(options: tunnelOptions)
|
try session.startTunnel(options: tunnelOptions)
|
||||||
} catch (let error) {
|
} catch (let error) {
|
||||||
os_log("Failed to activate tunnel: %{public}@", log: OSLog.default, type: .debug, "\(error)")
|
os_log("Failed to activate tunnel: %{public}@", log: OSLog.default, type: .debug, "\(error)")
|
||||||
completionHandler(error)
|
s.status = .inactive
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue