aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-01-15 22:35:30 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-01-15 22:35:30 +0100
commit811714e21a637c408d5b149b1af615b785693c83 (patch)
treee36c7c01d4261e00cbff2e3a9147e2a65ef05719 /WireGuard
parentmacOS: Use tunnelOverheadBytes for automatic MTU in macOS (diff)
downloadwireguard-apple-811714e21a637c408d5b149b1af615b785693c83.tar.xz
wireguard-apple-811714e21a637c408d5b149b1af615b785693c83.zip
macOS: Networks should show allowedIPs and disappear when inactive
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'WireGuard')
-rw-r--r--WireGuard/WireGuard/UI/macOS/StatusMenu.swift12
1 files changed, 7 insertions, 5 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/StatusMenu.swift b/WireGuard/WireGuard/UI/macOS/StatusMenu.swift
index a2f02d8c..fa8b8e44 100644
--- a/WireGuard/WireGuard/UI/macOS/StatusMenu.swift
+++ b/WireGuard/WireGuard/UI/macOS/StatusMenu.swift
@@ -63,6 +63,7 @@ class StatusMenu: NSMenu {
addItem(statusMenuItem)
let networksMenuItem = NSMenuItem(title: tr("macMenuNetworksInactive"), action: #selector(manageTunnelsClicked), keyEquivalent: "")
networksMenuItem.isEnabled = false
+ networksMenuItem.isHidden = true
addItem(networksMenuItem)
self.statusMenuItem = statusMenuItem
self.networksMenuItem = networksMenuItem
@@ -98,14 +99,15 @@ class StatusMenu: NSMenu {
if tunnel.status == .inactive {
networksMenuItem.title = tr("macMenuNetworksInactive")
+ networksMenuItem.isHidden = true
} else {
- let addresses = tunnel.tunnelConfiguration?.interface.addresses ?? []
- let addressesString = addresses.map { $0.stringRepresentation }.joined(separator: ", ")
- if addressesString.isEmpty {
- networksMenuItem.title = tr("macMenuNetworksNone")
+ let allowedIPs = tunnel.tunnelConfiguration?.peers.flatMap { $0.allowedIPs }.map { $0.stringRepresentation }.joined(separator: ", ") ?? ""
+ if !allowedIPs.isEmpty {
+ networksMenuItem.title = tr(format: "macMenuNetworks (%@)", allowedIPs)
} else {
- networksMenuItem.title = tr(format: "macMenuNetworks (%@)", addressesString)
+ networksMenuItem.title = tr("macMenuNetworksNone")
}
+ networksMenuItem.isHidden = false
}
return true
}