aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/View
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-02-16 00:26:49 +0530
committerRoopesh Chander <roop@roopc.net>2019-02-16 00:26:49 +0530
commit2fb9d6af71923d9d5641b1a0708d003b6c472268 (patch)
tree2fddcd84faf50948d5ad34ea85f261317b303007 /WireGuard/WireGuard/UI/macOS/View
parentConfTextStorage: keep track of single peer state for exclude private IPs (diff)
downloadwireguard-apple-2fb9d6af71923d9d5641b1a0708d003b6c472268.tar.xz
wireguard-apple-2fb9d6af71923d9d5641b1a0708d003b6c472268.zip
ConfTextStorage: Make fieldType an enum
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/UI/macOS/View/ConfTextStorage.swift19
1 files changed, 8 insertions, 11 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/View/ConfTextStorage.swift b/WireGuard/WireGuard/UI/macOS/View/ConfTextStorage.swift
index 47c05b1..48a32ed 100644
--- a/WireGuard/WireGuard/UI/macOS/View/ConfTextStorage.swift
+++ b/WireGuard/WireGuard/UI/macOS/View/ConfTextStorage.swift
@@ -92,7 +92,11 @@ class ConfTextStorage: NSTextStorage {
func evaluateExcludePrivateIPs(highlightSpans: UnsafePointer<highlight_span>) {
var spans = highlightSpans
- var fieldType = 0
+ enum FieldType: String {
+ case dns
+ case allowedips
+ }
+ var fieldType: FieldType?
resetLastPeer()
while spans.pointee.type != HighlightEnd {
let span = spans.pointee
@@ -111,19 +115,12 @@ class ConfTextStorage: NSTextStorage {
hasOnePeer = true
}
} else if span.type == HighlightField {
- let field = substring.lowercased()
- if field == "dns" {
- fieldType = 1
- } else if field == "allowedips" {
- fieldType = 2
- } else {
- fieldType = 0
- }
- } else if span.type == HighlightIP && fieldType == 1 {
+ fieldType = FieldType(rawValue: substring.lowercased())
+ } else if span.type == HighlightIP && fieldType == .dns {
if let parsed = DNSServer(from: substring) {
lastOnePeerDNSServers.append(parsed)
}
- } else if span.type == HighlightIP && fieldType == 2 {
+ } else if span.type == HighlightIP && fieldType == .allowedips {
let next = spans.successor()
let nextnext = next.successor()
if next.pointee.type == HighlightDelimiter && nextnext.pointee.type == HighlightCidr {