Parser: Address, DNS and AllowedIPs can have mutliple entries
This commit is contained in:
parent
c1286c95c3
commit
4c701a0e4f
|
@ -114,7 +114,12 @@ class WgQuickConfigFileParser {
|
||||||
// Line contains an attribute
|
// Line contains an attribute
|
||||||
let key = line[..<equalsIndex].trimmingCharacters(in: .whitespaces)
|
let key = line[..<equalsIndex].trimmingCharacters(in: .whitespaces)
|
||||||
let value = line[line.index(equalsIndex, offsetBy: 1)...].trimmingCharacters(in: .whitespaces)
|
let value = line[line.index(equalsIndex, offsetBy: 1)...].trimmingCharacters(in: .whitespaces)
|
||||||
attributes[key] = value
|
let keysWithMultipleEntriesAllowed: Set<String> = ["Address", "AllowedIPs", "DNS"]
|
||||||
|
if let presentValue = attributes[key], keysWithMultipleEntriesAllowed.contains(key) {
|
||||||
|
attributes[key] = presentValue + "," + value
|
||||||
|
} else {
|
||||||
|
attributes[key] = value
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (lowercasedLine != "[interface]" && lowercasedLine != "[peer]") {
|
if (lowercasedLine != "[interface]" && lowercasedLine != "[peer]") {
|
||||||
throw ParseError.invalidLine(line)
|
throw ParseError.invalidLine(line)
|
||||||
|
|
Loading…
Reference in New Issue