Do not do DNS lookups for IPs

This involves reflection, which is a bummer, but it's better than doing
unnecessary DNS lookups.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld
2018-04-27 18:34:52 +02:00
parent 9c6f9135e9
commit 693228985d
4 changed files with 29 additions and 14 deletions
@@ -39,11 +39,7 @@ public class IPCidr implements Parcelable {
} catch (Exception e) {
}
}
try {
address = InetAddress.getByName(in);
} catch (UnknownHostException e) {
throw new IllegalArgumentException(e);
}
address = Attribute.parseIPString(in);
if ((address instanceof Inet6Address) && (cidr > 128 || cidr < 0))
cidr = 128;
else if ((address instanceof Inet4Address) && (cidr > 32 || cidr < 0))