aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/VPN/TunnelsManager.swift
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/WireGuard/VPN/TunnelsManager.swift')
-rw-r--r--WireGuard/WireGuard/VPN/TunnelsManager.swift22
1 files changed, 9 insertions, 13 deletions
diff --git a/WireGuard/WireGuard/VPN/TunnelsManager.swift b/WireGuard/WireGuard/VPN/TunnelsManager.swift
index f2d02d4..d0c0dc1 100644
--- a/WireGuard/WireGuard/VPN/TunnelsManager.swift
+++ b/WireGuard/WireGuard/VPN/TunnelsManager.swift
@@ -13,7 +13,6 @@ protocol TunnelsManagerDelegate: class {
}
enum TunnelActivationError: Error {
- case noEndpoint
case dnsResolutionFailed
case tunnelActivationFailed
case attemptingActivationWhenAnotherTunnelIsBusy(otherTunnelStatus: TunnelStatus)
@@ -214,14 +213,20 @@ extension NETunnelProviderProtocol {
self.init()
let appId = Bundle.main.bundleIdentifier!
- let firstValidEndpoint = tunnelConfiguration.peers.first(where: { $0.endpoint != nil })?.endpoint
-
providerBundleIdentifier = "\(appId).network-extension"
providerConfiguration = [
"tunnelConfiguration": serializedTunnelConfiguration,
"tunnelConfigurationVersion": 1
]
- serverAddress = firstValidEndpoint?.stringRepresentation() ?? "Unspecified"
+
+ let endpoints = tunnelConfiguration.peers.compactMap({$0.endpoint})
+ if endpoints.count == 1 {
+ serverAddress = endpoints.first!.stringRepresentation()
+ } else if endpoints.isEmpty {
+ serverAddress = "Unspecified"
+ } else {
+ serverAddress = "Multiple endpoints"
+ }
username = tunnelConfiguration.interface.name
}
@@ -262,15 +267,6 @@ class TunnelContainer: NSObject {
guard let tunnelConfiguration = tunnelConfiguration() else { fatalError() }
let endpoints = tunnelConfiguration.peers.map { $0.endpoint }
- // Ensure there's a tunner server address we can give to iOS
- guard (endpoints.contains(where: { $0 != nil })) else {
- DispatchQueue.main.async { [weak self] in
- self?.status = .inactive
- completionHandler(TunnelActivationError.noEndpoint)
- }
- return
- }
-
// Resolve DNS and start the tunnel
let dnsResolver = DNSResolver(endpoints: endpoints)
let resolvedEndpoints = dnsResolver.resolveWithoutNetworkRequests()