VPN: Remove ability to deactivate the tunnel while resolving DNS
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
493166bd70
commit
269a6c3719
|
@ -13,7 +13,6 @@ protocol TunnelsManagerDelegate: class {
|
||||||
|
|
||||||
enum TunnelsManagerError: Error {
|
enum TunnelsManagerError: Error {
|
||||||
case dnsResolutionFailed
|
case dnsResolutionFailed
|
||||||
case dnsResolutionCancelled
|
|
||||||
case tunnelOperationFailed
|
case tunnelOperationFailed
|
||||||
case attemptingActivationWhenAnotherTunnelIsActive
|
case attemptingActivationWhenAnotherTunnelIsActive
|
||||||
case attemptingActivationWhenTunnelIsNotInactive
|
case attemptingActivationWhenTunnelIsNotInactive
|
||||||
|
@ -252,16 +251,13 @@ class TunnelContainer: NSObject {
|
||||||
status = .resolvingEndpointDomains
|
status = .resolvingEndpointDomains
|
||||||
dnsResolver.resolve { [weak self] endpoints in
|
dnsResolver.resolve { [weak self] endpoints in
|
||||||
guard let s = self else { return }
|
guard let s = self else { return }
|
||||||
if (s.dnsResolver == nil) {
|
assert(s.status == .resolvingEndpointDomains)
|
||||||
s.status = .inactive
|
s.dnsResolver = nil
|
||||||
completionHandler(TunnelsManagerError.dnsResolutionCancelled)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
guard let endpoints = endpoints else {
|
guard let endpoints = endpoints else {
|
||||||
completionHandler(TunnelsManagerError.dnsResolutionFailed)
|
completionHandler(TunnelsManagerError.dnsResolutionFailed)
|
||||||
|
s.status = .inactive
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.dnsResolver = nil
|
|
||||||
s.startObservingTunnelStatus()
|
s.startObservingTunnelStatus()
|
||||||
let session = (s.tunnelProvider.connection as! NETunnelProviderSession)
|
let session = (s.tunnelProvider.connection as! NETunnelProviderSession)
|
||||||
do {
|
do {
|
||||||
|
@ -276,12 +272,10 @@ class TunnelContainer: NSObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func startDeactivation() {
|
fileprivate func startDeactivation() {
|
||||||
if (status != .inactive) {
|
assert(status == .active)
|
||||||
dnsResolver = nil
|
assert(statusObservationToken != nil)
|
||||||
assert(statusObservationToken != nil)
|
let session = (tunnelProvider.connection as! NETunnelProviderSession)
|
||||||
let session = (tunnelProvider.connection as! NETunnelProviderSession)
|
session.stopTunnel()
|
||||||
session.stopTunnel()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func startObservingTunnelStatus() {
|
private func startObservingTunnelStatus() {
|
||||||
|
|
Loading…
Reference in New Issue