VPN: Specify an error when there are no peers with an endpoint

This commit is contained in:
Roopesh Chander 2018-10-29 23:38:34 +05:30
parent 22dd3dcc40
commit 0ef0eeb116
1 changed files with 5 additions and 0 deletions

View File

@ -13,6 +13,7 @@ protocol TunnelsManagerDelegate: class {
}
enum TunnelsManagerError: Error {
case noEndpoint
case dnsResolutionFailed
case tunnelOperationFailed
case attemptingActivationWhenAnotherTunnelIsActive
@ -262,6 +263,10 @@ class TunnelContainer: NSObject {
let dnsResolver = DNSResolver(endpoints: endpoints)
assert(self.dnsResolver == nil)
if let endpoints = dnsResolver.resolveWithoutNetworkRequests() {
guard (endpoints.contains(where: { $0 != nil })) else {
completionHandler(TunnelsManagerError.noEndpoint)
return
}
self.tunnelProvider.loadFromPreferences { [weak self] (error) in
guard let s = self else { return }
s.startObservingTunnelStatus()