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