aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-02-21 17:56:52 +0530
committerRoopesh Chander <roop@roopc.net>2019-02-21 17:57:13 +0530
commit69a064d954fe39c8dc7299814fda47470b488b62 (patch)
treef71ff838b5ed3a1887033d01ba7c483f3adf3964 /WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift
parentmacOS: On saving, update AllowedIPs with the current DNS servers (diff)
downloadwireguard-apple-69a064d954fe39c8dc7299814fda47470b488b62.tar.xz
wireguard-apple-69a064d954fe39c8dc7299814fda47470b488b62.zip
iOS: On changing DNS, update AllowedIPs with the current DNS servers
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift14
1 files changed, 12 insertions, 2 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift
index 0b0be6db..a15d5fe3 100644
--- a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift
@@ -259,8 +259,18 @@ extension TunnelEditTableViewController {
cell.onValueBeingEdited = { [weak self] value in
self?.tunnelViewModel.interfaceData[field] = value
}
+ cell.onValueChanged = { [weak self] oldValue, newValue in
+ guard let self = self else { return }
+ let isAllowedIPsChanged = self.tunnelViewModel.updateDNSServersInAllowedIPsIfRequired(oldDNSServers: oldValue, newDNSServers: newValue)
+ if isAllowedIPsChanged {
+ let section = self.sections.firstIndex { if case .peer(_) = $0 { return true } else { return false } }
+ if let section = section, let row = self.peerFields.firstIndex(of: .allowedIPs) {
+ self.tableView.reloadRows(at: [IndexPath(row: row, section: section)], with: .none)
+ }
+ }
+ }
} else {
- cell.onValueChanged = { [weak self] value in
+ cell.onValueChanged = { [weak self] _, value in
self?.tunnelViewModel.interfaceData[field] = value
}
}
@@ -380,7 +390,7 @@ extension TunnelEditTableViewController {
tableView.reloadRows(at: [IndexPath(row: dnsRow, section: firstInterfaceSection + interfaceSubSection)], with: .none)
}
} else {
- cell.onValueChanged = { [weak peerData] value in
+ cell.onValueChanged = { [weak peerData] _, value in
peerData?[field] = value
}
}