]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
Parser: Address, DNS and AllowedIPs can have mutliple entries
authorRoopesh Chander <roop@roopc.net>
Mon, 5 Nov 2018 18:22:16 +0000 (23:52 +0530)
committerRoopesh Chander <roop@roopc.net>
Mon, 5 Nov 2018 18:23:00 +0000 (23:53 +0530)
Signed-off-by: Roopesh Chander <roop@roopc.net>
WireGuard/WireGuard/ConfigFile/WgQuickConfigFileParser.swift

index 2b4ca0baf74e8602dd6e81cfe6f5932400ef1cfc..869d94e03dc3da30df6a5c2ebf31c237302b450c 100644 (file)
@@ -114,7 +114,12 @@ class WgQuickConfigFileParser {
                 // Line contains an attribute
                 let key = line[..<equalsIndex].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 {
                 if (lowercasedLine != "[interface]" && lowercasedLine != "[peer]") {
                     throw ParseError.invalidLine(line)