aboutsummaryrefslogtreecommitdiffstats
path: root/Sources/WireGuardApp/UI/iOS/ViewController/TunnelsListTableViewController.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Sources/WireGuardApp/UI/iOS/ViewController/TunnelsListTableViewController.swift')
-rw-r--r--Sources/WireGuardApp/UI/iOS/ViewController/TunnelsListTableViewController.swift14
1 files changed, 11 insertions, 3 deletions
diff --git a/Sources/WireGuardApp/UI/iOS/ViewController/TunnelsListTableViewController.swift b/Sources/WireGuardApp/UI/iOS/ViewController/TunnelsListTableViewController.swift
index 16e2adc..85e64ce 100644
--- a/Sources/WireGuardApp/UI/iOS/ViewController/TunnelsListTableViewController.swift
+++ b/Sources/WireGuardApp/UI/iOS/ViewController/TunnelsListTableViewController.swift
@@ -317,10 +317,18 @@ extension TunnelsListTableViewController: UITableViewDataSource {
cell.tunnel = tunnel
cell.onSwitchToggled = { [weak self] isOn in
guard let self = self, let tunnelsManager = self.tunnelsManager else { return }
- if isOn {
- tunnelsManager.startActivation(of: tunnel)
+ if tunnel.hasOnDemandRules {
+ tunnelsManager.setOnDemandEnabled(isOn, on: tunnel) { error in
+ if error == nil && !isOn {
+ tunnelsManager.startDeactivation(of: tunnel)
+ }
+ }
} else {
- tunnelsManager.startDeactivation(of: tunnel)
+ if isOn {
+ tunnelsManager.startActivation(of: tunnel)
+ } else {
+ tunnelsManager.startDeactivation(of: tunnel)
+ }
}
}
}