diff options
author | Roopesh Chander <roop@roopc.net> | 2019-02-05 16:45:32 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2019-02-05 16:45:32 +0530 |
commit | 71525c9d4e5fe929408233ce10f5af0d79bfc81a (patch) | |
tree | d0417be8817c531a09a3b84637a9e4753fc96bac /WireGuard/Shared | |
parent | macOS: Select tunnel after adding it with 'Add empty tunnel' (diff) | |
download | wireguard-apple-71525c9d4e5fe929408233ce10f5af0d79bfc81a.tar.xz wireguard-apple-71525c9d4e5fe929408233ce10f5af0d79bfc81a.zip |
wg-quick conf parser: Handle inline comments correctly
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/Shared')
-rw-r--r-- | WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift b/WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift index 65676f5..fa32de2 100644 --- a/WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift +++ b/WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift @@ -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) { |