diff options
author | Jeroen Leenarts <jeroen.leenarts@gmail.com> | 2018-10-03 10:39:04 +0200 |
---|---|---|
committer | Jeroen Leenarts <jeroen.leenarts@gmail.com> | 2018-10-03 10:39:04 +0200 |
commit | ce02b7a4c09bcabd4de3b8c9044c014264bcd4ff (patch) | |
tree | 278c59434a53ddaa55b1dabb93cb28a62c02baff /Shared | |
parent | Remove extra comment cruft (diff) | |
download | wireguard-apple-ce02b7a4c09bcabd4de3b8c9044c014264bcd4ff.tar.xz wireguard-apple-ce02b7a4c09bcabd4de3b8c9044c014264bcd4ff.zip |
Do not try to resolve a valid ip address.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'Shared')
-rw-r--r-- | Shared/Validators.swift | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Shared/Validators.swift b/Shared/Validators.swift index 21758fe..a73f329 100644 --- a/Shared/Validators.swift +++ b/Shared/Validators.swift @@ -49,11 +49,16 @@ struct Endpoint { } hostString = hostString.replacingOccurrences(of: "[", with: "").replacingOccurrences(of: "]", with: "") - - let ipString = convertToipAddress(from: hostString) + var addressType = validateIpAddress(ipToValidate: hostString) + let ipString: String + if addressType == .other { + ipString = convertToipAddress(from: hostString) + } else { + ipString = hostString + } ipAddress = String(ipString) - let addressType = validateIpAddress(ipToValidate: ipAddress) + addressType = validateIpAddress(ipToValidate: ipAddress) guard addressType == .IPv4 || addressType == .IPv6 else { throw EndpointValidationError.invalidIP(ipAddress) } |