diff options
author | 2019-02-16 18:25:17 +0530 | |
---|---|---|
committer | 2019-02-16 18:25:17 +0530 | |
commit | 5031a7db4c70d6f71ea568839b67c39ab68b4bdb (patch) | |
tree | b46c45118752673224d873e3946879e01726cd54 /WireGuard/WireGuard/UI/macOS/View | |
parent | TunnelViewModel: Minor refactoring of exclude private IPs handling (diff) | |
download | wireguard-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.swift | 12 |
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 } |