aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/View
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-02-16 18:25:17 +0530
committerRoopesh Chander <roop@roopc.net>2019-02-16 18:25:17 +0530
commit5031a7db4c70d6f71ea568839b67c39ab68b4bdb (patch)
treeb46c45118752673224d873e3946879e01726cd54 /WireGuard/WireGuard/UI/macOS/View
parentTunnelViewModel: Minor refactoring of exclude private IPs handling (diff)
downloadwireguard-apple-5031a7db4c70d6f71ea568839b67c39ab68b4bdb.tar.xz
wireguard-apple-5031a7db4c70d6f71ea568839b67c39ab68b4bdb.zip
macOS: Exclude private IPs
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/UI/macOS/View')
-rw-r--r--WireGuard/WireGuard/UI/macOS/View/ConfTextView.swift12
1 files changed, 12 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/View/ConfTextView.swift b/WireGuard/WireGuard/UI/macOS/View/ConfTextView.swift
index bc019f8..2ea8f84 100644
--- a/WireGuard/WireGuard/UI/macOS/View/ConfTextView.swift
+++ b/WireGuard/WireGuard/UI/macOS/View/ConfTextView.swift
@@ -9,6 +9,7 @@ class ConfTextView: NSTextView {
@objc dynamic var hasError: Bool = false
@objc dynamic var privateKeyString: String?
+ @objc dynamic var singlePeerAllowedIPs: [String]?
override var string: String {
didSet {
@@ -52,6 +53,13 @@ class ConfTextView: NSTextView {
}
}
+ func setConfText(_ text: String) {
+ let fullTextRange = NSRange(location: 0, length: (string as NSString).length)
+ if shouldChangeText(in: fullTextRange, replacementString: text) {
+ replaceCharacters(in: fullTextRange, with: text)
+ didChangeText()
+ }
+ }
}
extension ConfTextView: NSTextViewDelegate {
@@ -64,6 +72,10 @@ extension ConfTextView: NSTextViewDelegate {
if privateKeyString != confTextStorage.privateKeyString {
privateKeyString = confTextStorage.privateKeyString
}
+ let updatedSinglePeerAllowedIPs = confTextStorage.hasOnePeer && !confTextStorage.hasError ? confTextStorage.lastOnePeerAllowedIPs : nil
+ if singlePeerAllowedIPs != updatedSinglePeerAllowedIPs {
+ singlePeerAllowedIPs = updatedSinglePeerAllowedIPs
+ }
needsDisplay = true
}