aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/WireGuard/Tunnel/TunnelsManager.swift')
-rw-r--r--WireGuard/WireGuard/Tunnel/TunnelsManager.swift17
1 files changed, 14 insertions, 3 deletions
diff --git a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
index 8f4c87c..3b976f4 100644
--- a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
+++ b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
@@ -47,11 +47,18 @@ class TunnelsManager {
var tunnelManagers = managers ?? []
var refs: Set<Data> = []
for (index, tunnelManager) in tunnelManagers.enumerated().reversed() {
- let proto = tunnelManager.protocolConfiguration as? NETunnelProviderProtocol
- if proto?.migrateConfigurationIfNeeded(called: tunnelManager.localizedDescription ?? "unknown") ?? false {
+ guard let proto = tunnelManager.protocolConfiguration as? NETunnelProviderProtocol else { continue }
+ if proto.migrateConfigurationIfNeeded(called: tunnelManager.localizedDescription ?? "unknown") {
tunnelManager.saveToPreferences { _ in }
}
- if let ref = proto?.verifyConfigurationReference() {
+ #if os(iOS)
+ let passwordRef = proto.verifyConfigurationReference() ? proto.passwordReference : nil
+ #elseif os(macOS)
+ let passwordRef = proto.passwordReference // To handle multiple users in macOS, we skip verifying
+ #else
+ #error("Unimplemented")
+ #endif
+ if let ref = passwordRef {
refs.insert(ref)
} else {
tunnelManager.removeFromPreferences { _ in }
@@ -455,6 +462,10 @@ class TunnelContainer: NSObject {
return tunnelProvider.tunnelConfiguration
}
+ var isTunnelConfigurationAvailableInKeychain: Bool {
+ return (tunnelProvider.protocolConfiguration as? NETunnelProviderProtocol)?.verifyConfigurationReference() ?? false
+ }
+
var onDemandOption: ActivateOnDemandOption {
return ActivateOnDemandOption(from: tunnelProvider)
}