aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-24 18:11:55 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-24 18:11:55 +0530
commit52eec55d36fa12abeafa8a416cb14e3043223df8 (patch)
treee6aba0bb16acf21a41afca0ffae45cd5c7d4f89e /WireGuard
parentTunnelsManager: func tunnelInOperation() (diff)
downloadwireguard-apple-52eec55d36fa12abeafa8a416cb14e3043223df8.tar.xz
wireguard-apple-52eec55d36fa12abeafa8a416cb14e3043223df8.zip
TunnelsTracker: Simplify using TunnelsManager.tunnelInOperation()
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard')
-rw-r--r--WireGuard/WireGuard/UI/macOS/TunnelsTracker.swift19
1 files changed, 2 insertions, 17 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/TunnelsTracker.swift b/WireGuard/WireGuard/UI/macOS/TunnelsTracker.swift
index 8df7789f..69cc5330 100644
--- a/WireGuard/WireGuard/UI/macOS/TunnelsTracker.swift
+++ b/WireGuard/WireGuard/UI/macOS/TunnelsTracker.swift
@@ -33,18 +33,7 @@ class TunnelsTracker {
init(tunnelsManager: TunnelsManager) {
self.tunnelsManager = tunnelsManager
-
- if let waitingTunnel = tunnelsManager.waitingTunnel() {
- currentTunnel = waitingTunnel
- } else {
- for index in 0 ..< tunnelsManager.numberOfTunnels() {
- let tunnel = tunnelsManager.tunnel(at: index)
- if tunnel.status != .inactive {
- currentTunnel = tunnel
- break
- }
- }
- }
+ currentTunnel = tunnelsManager.tunnelInOperation()
for index in 0 ..< tunnelsManager.numberOfTunnels() {
let tunnel = tunnelsManager.tunnel(at: index)
@@ -61,11 +50,7 @@ class TunnelsTracker {
guard let self = self else { return }
if tunnel.status == .deactivating || tunnel.status == .inactive {
if self.currentTunnel == tunnel {
- if let waitingTunnel = self.tunnelsManager.waitingTunnel() {
- self.currentTunnel = waitingTunnel
- } else if tunnel.status == .inactive {
- self.currentTunnel = nil
- }
+ self.currentTunnel = self.tunnelsManager.tunnelInOperation()
}
} else {
self.currentTunnel = tunnel