]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
Do not try to resolve a valid ip address.
authorJeroen Leenarts <jeroen.leenarts@gmail.com>
Wed, 3 Oct 2018 08:39:04 +0000 (10:39 +0200)
committerJeroen Leenarts <jeroen.leenarts@gmail.com>
Wed, 3 Oct 2018 08:39:04 +0000 (10:39 +0200)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Shared/Validators.swift

index 21758fe6bbf7eaff93809cf2e58d8bfcbcc0627b..a73f3292e18d8dce063b2f33682b172fa6c74d50 100644 (file)
@@ -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)
         }