wg-quick conf parser: Handle inline comments correctly
This commit is contained in:
parent
d3a4d606cf
commit
4ac1437c4b
|
@ -57,11 +57,11 @@ extension TunnelConfiguration {
|
||||||
let lowercasedLine = trimmedLine.lowercased()
|
let lowercasedLine = trimmedLine.lowercased()
|
||||||
|
|
||||||
if !trimmedLine.isEmpty {
|
if !trimmedLine.isEmpty {
|
||||||
if let equalsIndex = line.firstIndex(of: "=") {
|
if let equalsIndex = trimmedLine.firstIndex(of: "=") {
|
||||||
// Line contains an attribute
|
// Line contains an attribute
|
||||||
let keyWithCase = line[..<equalsIndex].trimmingCharacters(in: .whitespaces)
|
let keyWithCase = trimmedLine[..<equalsIndex].trimmingCharacters(in: .whitespaces)
|
||||||
let key = keyWithCase.lowercased()
|
let key = keyWithCase.lowercased()
|
||||||
let value = line[line.index(equalsIndex, offsetBy: 1)...].trimmingCharacters(in: .whitespaces)
|
let value = trimmedLine[trimmedLine.index(equalsIndex, offsetBy: 1)...].trimmingCharacters(in: .whitespaces)
|
||||||
let keysWithMultipleEntriesAllowed: Set<String> = ["address", "allowedips", "dns"]
|
let keysWithMultipleEntriesAllowed: Set<String> = ["address", "allowedips", "dns"]
|
||||||
if let presentValue = attributes[key] {
|
if let presentValue = attributes[key] {
|
||||||
if keysWithMultipleEntriesAllowed.contains(key) {
|
if keysWithMultipleEntriesAllowed.contains(key) {
|
||||||
|
|
Loading…
Reference in New Issue