aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Shared/Model
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-03-11 13:59:31 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-11 14:05:16 -0600
commitf6c70500a79e002f47ecf39441a637dc5282da4a (patch)
tree547d4f982623198a2ab315736ca8ac63eeed1133 /WireGuard/Shared/Model
parentTunnelsManager: Don't restart if only on-demand setting has changed (diff)
downloadwireguard-apple-f6c70500a79e002f47ecf39441a637dc5282da4a.tar.xz
wireguard-apple-f6c70500a79e002f47ecf39441a637dc5282da4a.zip
wg-quick parser: trim \r as well
The influx of Windows users has already begun to infect our nice project. Reported-by: Cosku Bas <cosku.bas@gmail.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'WireGuard/Shared/Model')
-rw-r--r--WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift10
1 files changed, 5 insertions, 5 deletions
diff --git a/WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift b/WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift
index a6afc05c..6aba0ac7 100644
--- a/WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift
+++ b/WireGuard/Shared/Model/TunnelConfiguration+WgQuickConfig.swift
@@ -52,15 +52,15 @@ extension TunnelConfiguration {
trimmedLine = String(line)
}
- trimmedLine = trimmedLine.trimmingCharacters(in: .whitespaces)
+ trimmedLine = trimmedLine.trimmingCharacters(in: .whitespacesAndNewlines)
let lowercasedLine = trimmedLine.lowercased()
if !trimmedLine.isEmpty {
if let equalsIndex = trimmedLine.firstIndex(of: "=") {
// Line contains an attribute
- let keyWithCase = trimmedLine[..<equalsIndex].trimmingCharacters(in: .whitespaces)
+ let keyWithCase = trimmedLine[..<equalsIndex].trimmingCharacters(in: .whitespacesAndNewlines)
let key = keyWithCase.lowercased()
- let value = trimmedLine[trimmedLine.index(equalsIndex, offsetBy: 1)...].trimmingCharacters(in: .whitespaces)
+ let value = trimmedLine[trimmedLine.index(equalsIndex, offsetBy: 1)...].trimmingCharacters(in: .whitespacesAndNewlines)
let keysWithMultipleEntriesAllowed: Set<String> = ["address", "allowedips", "dns"]
if let presentValue = attributes[key] {
if keysWithMultipleEntriesAllowed.contains(key) {
@@ -182,7 +182,7 @@ extension TunnelConfiguration {
}
if let addressesString = attributes["address"] {
var addresses = [IPAddressRange]()
- for addressString in addressesString.splitToArray(trimmingCharacters: .whitespaces) {
+ for addressString in addressesString.splitToArray(trimmingCharacters: .whitespacesAndNewlines) {
guard let address = IPAddressRange(from: addressString) else {
throw ParseError.interfaceHasInvalidAddress(addressString)
}
@@ -192,7 +192,7 @@ extension TunnelConfiguration {
}
if let dnsString = attributes["dns"] {
var dnsServers = [DNSServer]()
- for dnsServerString in dnsString.splitToArray(trimmingCharacters: .whitespaces) {
+ for dnsServerString in dnsString.splitToArray(trimmingCharacters: .whitespacesAndNewlines) {
guard let dnsServer = DNSServer(from: dnsServerString) else {
throw ParseError.interfaceHasInvalidDNS(dnsServerString)
}