diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-01-24 00:33:22 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-01-24 01:37:57 +0100 |
commit | 2fe9f83ba52043b70d803d329b368bb169043a1a (patch) | |
tree | 7ce6d6b23079644366250fc0784da4756e99eb85 /WireGuard | |
parent | Tunnel: support getting runtime configuration (diff) | |
download | wireguard-apple-2fe9f83ba52043b70d803d329b368bb169043a1a.tar.xz wireguard-apple-2fe9f83ba52043b70d803d329b368bb169043a1a.zip |
macOS: show runtime configuration in tunnel manager
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'WireGuard')
-rw-r--r-- | WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift index 6c3a0e9..6a9aff1 100644 --- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift +++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift @@ -37,7 +37,8 @@ class TunnelDetailTableViewController: NSViewController { let peerFields: [TunnelViewModel.PeerField] = [ .publicKey, .preSharedKey, .endpoint, - .allowedIPs, .persistentKeepAlive + .allowedIPs, .persistentKeepAlive, + .rxBytes, .txBytes, .lastHandshakeTime ] let tableView: NSTableView = { @@ -96,6 +97,8 @@ class TunnelDetailTableViewController: NSViewController { statusObservationToken = tunnel.observe(\TunnelContainer.status) { [weak self] _, _ in self?.updateStatus() } + + // TODO(roopc): call reloadRuntimeConfiguration() once per second } required init?(coder: NSCoder) { @@ -196,6 +199,7 @@ class TunnelDetailTableViewController: NSViewController { let shouldBeEnabled = (tunnel.status == .active || tunnel.status == .inactive) statusCheckbox.state = shouldBeChecked ? .on : .off statusCheckbox.isEnabled = shouldBeEnabled + reloadRuntimeConfiguration() } @objc func handleEditTunnelAction() { @@ -228,6 +232,19 @@ class TunnelDetailTableViewController: NSViewController { dismiss(tunnelEditVC) } } + + private func reloadRuntimeConfiguration() { + tunnel.getRuntimeTunnelConfiguration(completionHandler: { + guard let tunnelConfiguration = $0 else { return } + if tunnelConfiguration == self.tunnel.tunnelConfiguration { + return + } + self.tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnelConfiguration) + // TODO(roopc): make this not loose scroll position + self.tableView.reloadData() + self.tunnelEditVC = nil + }) + } } extension TunnelDetailTableViewController: NSTableViewDataSource { @@ -271,6 +288,7 @@ extension TunnelDetailTableViewController: TunnelEditViewControllerDelegate { tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration) tableView.reloadData() self.tunnelEditVC = nil + updateStatus() } func tunnelEditingCancelled() { |