Tunnel creation: Generate key pair

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2018-10-24 14:18:52 +05:30
parent 571e9b5826
commit 0ae4b3bcf1
1 changed files with 10 additions and 2 deletions

View File

@ -141,8 +141,16 @@ extension TunnelEditTableViewController {
if (field == .generateKeyPair) { if (field == .generateKeyPair) {
let cell = tableView.dequeueReusableCell(withIdentifier: TunnelsEditTableViewButtonCell.id, for: indexPath) as! TunnelsEditTableViewButtonCell let cell = tableView.dequeueReusableCell(withIdentifier: TunnelsEditTableViewButtonCell.id, for: indexPath) as! TunnelsEditTableViewButtonCell
cell.buttonText = field.rawValue cell.buttonText = field.rawValue
cell.onTapped = { cell.onTapped = { [weak self, weak interfaceData] in
print("Generating keypair is unimplemented") // TODO 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 return cell
} else { } else {