Disconnect before switching active profile
Make sure that completionHandler is ALWAYS called, despite vpn object being nil.
This commit is contained in:
parent
b97b6eedeb
commit
3ddfa87b58
|
@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
- Profile sometimes not connecting right after add.
|
||||||
|
|
||||||
## 1.0.2 Beta 1315 (2019-03-03)
|
## 1.0.2 Beta 1315 (2019-03-03)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -185,12 +185,13 @@ class ServiceViewController: UIViewController, TableModelHost {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func activateProfile() {
|
private func activateProfile() {
|
||||||
service.activateProfile(uncheckedProfile)
|
vpn.disconnect { (error) in
|
||||||
|
self.service.activateProfile(self.uncheckedProfile)
|
||||||
reloadModel()
|
self.vpn.prepare(withProfile: self.uncheckedProfile) {
|
||||||
tableView.reloadData()
|
self.reloadModel()
|
||||||
|
self.tableView.reloadData()
|
||||||
vpn.disconnect(completionHandler: nil)
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction private func renameProfile() {
|
@IBAction private func renameProfile() {
|
||||||
|
|
|
@ -59,14 +59,22 @@ class GracefulVPN {
|
||||||
self.profile = profile
|
self.profile = profile
|
||||||
log.info("Preparing...")
|
log.info("Preparing...")
|
||||||
service.clearVpnLastError()
|
service.clearVpnLastError()
|
||||||
vpn?.prepare(completionHandler: completionHandler)
|
guard let vpn = vpn else {
|
||||||
|
completionHandler?()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
vpn.prepare(completionHandler: completionHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func reconnect(completionHandler: ((Error?) -> Void)?) {
|
func reconnect(completionHandler: ((Error?) -> Void)?) {
|
||||||
service.clearVpnLastError()
|
service.clearVpnLastError()
|
||||||
|
guard let vpn = vpn else {
|
||||||
|
completionHandler?(nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
do {
|
do {
|
||||||
log.info("Reconnecting...")
|
log.info("Reconnecting...")
|
||||||
try vpn?.reconnect(configuration: service.vpnConfiguration(), completionHandler: completionHandler)
|
try vpn.reconnect(configuration: service.vpnConfiguration(), completionHandler: completionHandler)
|
||||||
} catch let e {
|
} catch let e {
|
||||||
log.error("Could not reconnect: \(e)")
|
log.error("Could not reconnect: \(e)")
|
||||||
}
|
}
|
||||||
|
@ -74,9 +82,13 @@ class GracefulVPN {
|
||||||
|
|
||||||
func reinstall(completionHandler: ((Error?) -> Void)?) {
|
func reinstall(completionHandler: ((Error?) -> Void)?) {
|
||||||
service.clearVpnLastError()
|
service.clearVpnLastError()
|
||||||
|
guard let vpn = vpn else {
|
||||||
|
completionHandler?(nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
do {
|
do {
|
||||||
log.info("Reinstalling...")
|
log.info("Reinstalling...")
|
||||||
try vpn?.install(configuration: service.vpnConfiguration(), completionHandler: completionHandler)
|
try vpn.install(configuration: service.vpnConfiguration(), completionHandler: completionHandler)
|
||||||
} catch let e {
|
} catch let e {
|
||||||
log.error("Could not reinstall: \(e)")
|
log.error("Could not reinstall: \(e)")
|
||||||
}
|
}
|
||||||
|
@ -95,14 +107,26 @@ class GracefulVPN {
|
||||||
}
|
}
|
||||||
|
|
||||||
func disconnect(completionHandler: ((Error?) -> Void)?) {
|
func disconnect(completionHandler: ((Error?) -> Void)?) {
|
||||||
vpn?.disconnect(completionHandler: completionHandler)
|
guard let vpn = vpn else {
|
||||||
|
completionHandler?(nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
vpn.disconnect(completionHandler: completionHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func uninstall(completionHandler: (() -> Void)?) {
|
func uninstall(completionHandler: (() -> Void)?) {
|
||||||
vpn?.uninstall(completionHandler: completionHandler)
|
guard let vpn = vpn else {
|
||||||
|
completionHandler?()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
vpn.uninstall(completionHandler: completionHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func requestBytesCount(completionHandler: @escaping ((UInt, UInt)?) -> Void) {
|
func requestBytesCount(completionHandler: @escaping ((UInt, UInt)?) -> Void) {
|
||||||
vpn?.requestBytesCount(completionHandler: completionHandler)
|
guard let vpn = vpn else {
|
||||||
|
completionHandler(nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
vpn.requestBytesCount(completionHandler: completionHandler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue