aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-22 19:57:35 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-22 20:06:52 +0530
commit54f45cb3f82187c7d0c0fdce5a89166e5b23b6cb (patch)
treee3e80bc667425aa91ff4869324fd3a29488a7710 /WireGuard
parentTunnelsManager: refresh status after replacing insides (diff)
downloadwireguard-apple-54f45cb3f82187c7d0c0fdce5a89166e5b23b6cb.tar.xz
wireguard-apple-54f45cb3f82187c7d0c0fdce5a89166e5b23b6cb.zip
macOS: reload: Iterate in reverse
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard')
-rw-r--r--WireGuard/WireGuard/Tunnel/TunnelsManager.swift8
1 files changed, 3 insertions, 5 deletions
diff --git a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
index 28b69692..82d10a38 100644
--- a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
+++ b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
@@ -61,13 +61,11 @@ class TunnelsManager {
let loadedTunnelProviders = managers ?? []
- var numberOfRemovedTunnels = 0
- for (index, currentTunnel) in self.tunnels.enumerated() {
+ for (index, currentTunnel) in self.tunnels.enumerated().reversed() {
if !loadedTunnelProviders.contains(where: { $0.tunnelConfiguration == currentTunnel.tunnelConfiguration }) {
// Tunnel was deleted outside the app
- self.tunnels.remove(at: index - numberOfRemovedTunnels)
- self.tunnelsListDelegate?.tunnelRemoved(at: index - numberOfRemovedTunnels)
- numberOfRemovedTunnels += 1
+ self.tunnels.remove(at: index)
+ self.tunnelsListDelegate?.tunnelRemoved(at: index)
}
}
for loadedTunnelProvider in loadedTunnelProviders {