aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-01-21 22:40:43 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-01-21 22:55:25 +0100
commit0b2a4c2811b20e01af81bfd494b6b34d74264020 (patch)
tree34685a4eaabb3d62344652b4020eec67e279e26b /WireGuard
parentmacOS: Better highlighter default value and move c implementation (diff)
downloadwireguard-apple-0b2a4c2811b20e01af81bfd494b6b34d74264020.tar.xz
wireguard-apple-0b2a4c2811b20e01af81bfd494b6b34d74264020.zip
macOS: Observe private key changes for new tunnels too
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'WireGuard')
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift20
1 files changed, 10 insertions, 10 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
index ef51e19..a5547a1 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift
@@ -105,16 +105,6 @@ class TunnelEditViewController: NSViewController {
textView.string = tunnelConfiguration.asWgQuickConfig()
publicKeyRow.value = tunnelConfiguration.interface.publicKey.base64EncodedString()
textView.privateKeyString = tunnelConfiguration.interface.privateKey.base64EncodedString()
- textViewObservationToken = textView.observe(\.privateKeyString) { [weak publicKeyRow] textView, _ in
- if let privateKeyString = textView.privateKeyString,
- let privateKey = Data(base64Encoded: privateKeyString),
- privateKey.count == TunnelConfiguration.keyLength {
- let publicKey = Curve25519.generatePublicKey(fromPrivateKey: privateKey)
- publicKeyRow?.value = publicKey.base64EncodedString()
- } else {
- publicKeyRow?.value = ""
- }
- }
if tunnel.activateOnDemandSetting.isActivateOnDemandEnabled {
selectedActivateOnDemandOption = tunnel.activateOnDemandSetting.activateOnDemandOption
} else {
@@ -129,6 +119,16 @@ class TunnelEditViewController: NSViewController {
textView.string = bootstrappingText
selectedActivateOnDemandOption = .none
}
+ textViewObservationToken = textView.observe(\.privateKeyString) { [weak publicKeyRow] textView, _ in
+ if let privateKeyString = textView.privateKeyString,
+ let privateKey = Data(base64Encoded: privateKeyString),
+ privateKey.count == TunnelConfiguration.keyLength {
+ let publicKey = Curve25519.generatePublicKey(fromPrivateKey: privateKey)
+ publicKeyRow?.value = publicKey.base64EncodedString()
+ } else {
+ publicKeyRow?.value = ""
+ }
+ }
onDemandRow.valueOptions = activateOnDemandOptions.map { TunnelViewModel.activateOnDemandOptionText(for: $0) }
onDemandRow.selectedOptionIndex = activateOnDemandOptions.firstIndex(of: selectedActivateOnDemandOption)!