aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-10-24 14:18:52 +0530
committerRoopesh Chander <roop@roopc.net>2018-10-27 15:13:01 +0530
commit0ae4b3bcf10f98c52a9545ff0bb944d0df9f3762 (patch)
treeccc7fe3ce4ccfc20694f0efd3b5710ae10c47313 /WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift
parentTunnel creation: Compute public key from private key as the text is being edited (diff)
downloadwireguard-apple-0ae4b3bcf10f98c52a9545ff0bb944d0df9f3762.tar.xz
wireguard-apple-0ae4b3bcf10f98c52a9545ff0bb944d0df9f3762.zip
Tunnel creation: Generate key pair
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift12
1 files changed, 10 insertions, 2 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift
index f203e09..d994dcb 100644
--- a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift
@@ -141,8 +141,16 @@ extension TunnelEditTableViewController {
if (field == .generateKeyPair) {
let cell = tableView.dequeueReusableCell(withIdentifier: TunnelsEditTableViewButtonCell.id, for: indexPath) as! TunnelsEditTableViewButtonCell
cell.buttonText = field.rawValue
- cell.onTapped = {
- print("Generating keypair is unimplemented") // TODO
+ cell.onTapped = { [weak self, weak interfaceData] in
+ if let interfaceData = interfaceData, let s = self {
+ interfaceData[.privateKey] = Curve25519.generatePrivateKey().base64EncodedString()
+ if let privateKeyRow = s.interfaceFieldsBySection[section].firstIndex(of: .privateKey),
+ let publicKeyRow = s.interfaceFieldsBySection[section].firstIndex(of: .publicKey) {
+ let privateKeyIndex = IndexPath(row: privateKeyRow, section: section)
+ let publicKeyIndex = IndexPath(row: publicKeyRow, section: section)
+ s.tableView.reloadRows(at: [privateKeyIndex, publicKeyIndex], with: .automatic)
+ }
+ }
}
return cell
} else {