Clear VPN error status before restart

This commit is contained in:
Davide De Rosa 2018-10-22 00:14:40 +02:00
parent e8f2aaaf08
commit 976e47af64
2 changed files with 10 additions and 0 deletions

View File

@ -286,6 +286,13 @@ class ConnectionService: Codable {
return TunnelKitProvider.ProviderError(rawValue: rawValue)
}
func clearVpnLastError() {
guard let key = tunnelConfiguration.lastErrorKey else {
return
}
defaults.removeObject(forKey: key)
}
// func eraseVpnLog() {
// defaults.removeObject(forKey: Keys.vpnLog)
// }

View File

@ -58,10 +58,12 @@ class GracefulVPN {
func prepare(withProfile profile: ConnectionProfile?, completionHandler: (() -> Void)?) {
self.profile = profile
log.info("Preparing...")
service.clearVpnLastError()
vpn?.prepare(completionHandler: completionHandler)
}
func reconnect(completionHandler: ((Error?) -> Void)?) {
service.clearVpnLastError()
do {
log.info("Reconnecting...")
try vpn?.reconnect(configuration: service.vpnConfiguration(), completionHandler: completionHandler)
@ -71,6 +73,7 @@ class GracefulVPN {
}
func reinstall(completionHandler: ((Error?) -> Void)?) {
service.clearVpnLastError()
do {
log.info("Reinstalling...")
try vpn?.install(configuration: service.vpnConfiguration(), completionHandler: completionHandler)