aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Shared
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-02-05 16:45:32 +0530
committerRoopesh Chander <roop@roopc.net>2019-02-05 16:45:32 +0530
commit71525c9d4e5fe929408233ce10f5af0d79bfc81a (patch)
treed0417be8817c531a09a3b84637a9e4753fc96bac /WireGuard/Shared
parentmacOS: Select tunnel after adding it with 'Add empty tunnel' (diff)
downloadwireguard-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 '')
-rw-r--r--WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift6
1 files changed, 3 insertions, 3 deletions
diff --git a/WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift b/WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift
index 65676f56..fa32de2e 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) {