ConfTextStorage: Let's keep the AllowedIPs and DNS servers as strings

This commit is contained in:
Roopesh Chander 2019-02-16 00:31:28 +05:30
parent 0e124746d9
commit 89c108d00f
1 changed files with 4 additions and 8 deletions

View File

@ -17,8 +17,8 @@ class ConfTextStorage: NSTextStorage {
private(set) var privateKeyString: String?
private(set) var hasOnePeer: Bool = false
private(set) var lastOnePeerAllowedIPs: [IPAddressRange] = []
private(set) var lastOnePeerDNSServers: [DNSServer] = []
private(set) var lastOnePeerAllowedIPs = [String]()
private(set) var lastOnePeerDNSServers = [String]()
override init() {
backingStore = NSMutableAttributedString(string: "")
@ -117,9 +117,7 @@ class ConfTextStorage: NSTextStorage {
} else if span.type == HighlightField {
fieldType = FieldType(rawValue: substring.lowercased())
} else if span.type == HighlightIP && fieldType == .dns {
if let parsed = DNSServer(from: substring) {
lastOnePeerDNSServers.append(parsed)
}
lastOnePeerDNSServers.append(substring)
} else if span.type == HighlightIP && fieldType == .allowedips {
let next = spans.successor()
let nextnext = next.successor()
@ -127,9 +125,7 @@ class ConfTextStorage: NSTextStorage {
substring += backingStore.attributedSubstring(from: NSRange(location: next.pointee.start, length: next.pointee.len)).string +
backingStore.attributedSubstring(from: NSRange(location: nextnext.pointee.start, length: nextnext.pointee.len)).string
}
if let parsed = IPAddressRange(from: substring) {
lastOnePeerAllowedIPs.append(parsed)
}
lastOnePeerAllowedIPs.append(substring)
}
spans = spans.successor()
}