Clear VPN error status before restart
This commit is contained in:
parent
e8f2aaaf08
commit
976e47af64
|
@ -286,6 +286,13 @@ class ConnectionService: Codable {
|
||||||
return TunnelKitProvider.ProviderError(rawValue: rawValue)
|
return TunnelKitProvider.ProviderError(rawValue: rawValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func clearVpnLastError() {
|
||||||
|
guard let key = tunnelConfiguration.lastErrorKey else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defaults.removeObject(forKey: key)
|
||||||
|
}
|
||||||
|
|
||||||
// func eraseVpnLog() {
|
// func eraseVpnLog() {
|
||||||
// defaults.removeObject(forKey: Keys.vpnLog)
|
// defaults.removeObject(forKey: Keys.vpnLog)
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -58,10 +58,12 @@ class GracefulVPN {
|
||||||
func prepare(withProfile profile: ConnectionProfile?, completionHandler: (() -> Void)?) {
|
func prepare(withProfile profile: ConnectionProfile?, completionHandler: (() -> Void)?) {
|
||||||
self.profile = profile
|
self.profile = profile
|
||||||
log.info("Preparing...")
|
log.info("Preparing...")
|
||||||
|
service.clearVpnLastError()
|
||||||
vpn?.prepare(completionHandler: completionHandler)
|
vpn?.prepare(completionHandler: completionHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func reconnect(completionHandler: ((Error?) -> Void)?) {
|
func reconnect(completionHandler: ((Error?) -> Void)?) {
|
||||||
|
service.clearVpnLastError()
|
||||||
do {
|
do {
|
||||||
log.info("Reconnecting...")
|
log.info("Reconnecting...")
|
||||||
try vpn?.reconnect(configuration: service.vpnConfiguration(), completionHandler: completionHandler)
|
try vpn?.reconnect(configuration: service.vpnConfiguration(), completionHandler: completionHandler)
|
||||||
|
@ -71,6 +73,7 @@ class GracefulVPN {
|
||||||
}
|
}
|
||||||
|
|
||||||
func reinstall(completionHandler: ((Error?) -> Void)?) {
|
func reinstall(completionHandler: ((Error?) -> Void)?) {
|
||||||
|
service.clearVpnLastError()
|
||||||
do {
|
do {
|
||||||
log.info("Reinstalling...")
|
log.info("Reinstalling...")
|
||||||
try vpn?.install(configuration: service.vpnConfiguration(), completionHandler: completionHandler)
|
try vpn?.install(configuration: service.vpnConfiguration(), completionHandler: completionHandler)
|
||||||
|
|
Loading…
Reference in New Issue