aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-10-24 17:19:14 +0530
committerRoopesh Chander <roop@roopc.net>2018-10-27 15:13:01 +0530
commit06c84a22ca688a702b1d99c96b53951facefcffc (patch)
tree7df03ebc79ea7e245c0f7c06b77cf799d1046580 /WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift
parentTunnel creation: After saving the new tunnel, show the detail view (diff)
downloadwireguard-apple-06c84a22ca688a702b1d99c96b53951facefcffc.tar.xz
wireguard-apple-06c84a22ca688a702b1d99c96b53951facefcffc.zip
Tunnel editing: Modifying a tunnel configuration
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift')
-rw-r--r--WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift28
1 files changed, 21 insertions, 7 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift
index 6be42b8..2543444 100644
--- a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift
@@ -63,13 +63,27 @@ class TunnelEditTableViewController: UITableViewController {
let erroringConfiguration = (tunnelViewModel.interfaceData.validatedConfiguration == nil) ? "Interface" : "Peer"
showErrorAlert(title: "Invalid \(erroringConfiguration)", message: errorMessage)
case .saved(let tunnelConfiguration):
- tunnelsManager.add(tunnelConfiguration: tunnelConfiguration) { [weak self] (tunnel, error) in
- if let error = error {
- print("Could not save: \(error)")
- self?.showErrorAlert(title: "Could not save", message: "Internal error")
- } else {
- self?.delegate?.saved(tunnel: tunnel)
- self?.dismiss(animated: true, completion: nil)
+ if let tunnel = tunnel {
+ // We're modifying an existing tunnel
+ tunnelsManager.modify(tunnel: tunnel, with: tunnelConfiguration) { [weak self] (error) in
+ if let error = error {
+ print("Could not modify tunnel: \(error)")
+ self?.showErrorAlert(title: "Could not save", message: "Internal error")
+ } else {
+ self?.delegate?.saved(tunnel: tunnel)
+ self?.dismiss(animated: true, completion: nil)
+ }
+ }
+ } else {
+ // We're adding a new tunnel
+ tunnelsManager.add(tunnelConfiguration: tunnelConfiguration) { [weak self] (tunnel, error) in
+ if let error = error {
+ print("Could not add tunnel: \(error)")
+ self?.showErrorAlert(title: "Could not save", message: "Internal error")
+ } else {
+ self?.delegate?.saved(tunnel: tunnel)
+ self?.dismiss(animated: true, completion: nil)
+ }
}
}
}