Report vpnIsEnabled = false on install error

This commit is contained in:
Davide De Rosa 2022-04-27 15:44:40 +02:00
parent e075ba6a76
commit 6e0471a55b
1 changed files with 6 additions and 5 deletions

View File

@ -86,7 +86,7 @@ public class NetworkExtensionVPN: VPN {
}
try manager.connection.startVPNTunnel()
} catch {
notifyError(error)
notifyInstallError(error)
throw error
}
}
@ -195,12 +195,12 @@ public class NetworkExtensionVPN: VPN {
manager.isOnDemandEnabled = false
manager.isEnabled = false
continuation.resume(throwing: error)
self.notifyError(error)
self.notifyInstallError(error)
} else {
manager.loadFromPreferences { error in
if let error = error {
continuation.resume(throwing: error)
self.notifyError(error)
self.notifyInstallError(error)
} else {
continuation.resume(returning: manager)
self.notifyReinstall(manager)
@ -284,11 +284,12 @@ public class NetworkExtensionVPN: VPN {
NotificationCenter.default.post(notification)
}
private func notifyError(_ error: Error) {
log.error("VPN command failed: \(error))")
private func notifyInstallError(_ error: Error) {
log.error("VPN installation failed: \(error))")
var notification = Notification(name: VPNNotification.didFail)
notification.vpnError = error
notification.vpnIsEnabled = false
NotificationCenter.default.post(notification)
}
}