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
@@ -172,13 +172,7 @@ public class Interface extends BaseObservable implements Parcelable {
public void addDnses(String[] dnses) {
if (dnses != null && dnses.length > 0) {
for (final String dns : dnses) {
if (dns.isEmpty())
throw new IllegalArgumentException("DNS is empty");
try {
this.dnsList.add(InetAddress.getByName(dns));
} catch (UnknownHostException e) {
throw new IllegalArgumentException(e);
}
this.dnsList.add(Attribute.parseIPString(dns));
}
}
notifyPropertyChanged(BR.dnses);