wg-quick conf parser: Handle inline comments correctly

This commit is contained in:
Roopesh Chander 2019-02-05 16:45:32 +05:30
parent d3a4d606cf
commit 4ac1437c4b
1 changed files with 3 additions and 3 deletions

View File

@ -57,11 +57,11 @@ extension TunnelConfiguration {
let lowercasedLine = trimmedLine.lowercased()
if !trimmedLine.isEmpty {
if let equalsIndex = line.firstIndex(of: "=") {
if let equalsIndex = trimmedLine.firstIndex(of: "=") {
// Line contains an attribute
let keyWithCase = line[..<equalsIndex].trimmingCharacters(in: .whitespaces)
let keyWithCase = trimmedLine[..<equalsIndex].trimmingCharacters(in: .whitespaces)
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"]
if let presentValue = attributes[key] {
if keysWithMultipleEntriesAllowed.contains(key) {