Simplification

pull/214/head
M66B 12 months ago
parent da4c70db32
commit b87ddb9ca6

@ -254,10 +254,10 @@ public class DnsHelper {
result.add(new DnsRecord(sb.toString(), 0)); result.add(new DnsRecord(sb.toString(), 0));
} else if (answer instanceof A) { } else if (answer instanceof A) {
A a = (A) answer; A a = (A) answer;
result.add(new DnsRecord(a.getInetAddress().getHostAddress())); result.add(new DnsRecord(a.getInetAddress()));
} else if (answer instanceof AAAA) { } else if (answer instanceof AAAA) {
AAAA aaaa = (AAAA) answer; AAAA aaaa = (AAAA) answer;
result.add(new DnsRecord(aaaa.getInetAddress().getHostAddress())); result.add(new DnsRecord(aaaa.getInetAddress()));
} else } else
throw new IllegalArgumentException(answer.getClass().getName()); throw new IllegalArgumentException(answer.getClass().getName());
} }
@ -288,19 +288,11 @@ public class DnsHelper {
if (has46[0]) if (has46[0])
for (DnsRecord a : lookup(context, host, "a")) for (DnsRecord a : lookup(context, host, "a"))
try { result.add(a.address);
result.add(Inet4Address.getByName(a.response));
} catch (UnknownHostException ex) {
Log.e(ex);
}
if (has46[1]) if (has46[1])
for (DnsRecord aaaa : lookup(context, host, "aaaa")) for (DnsRecord aaaa : lookup(context, host, "aaaa"))
try { result.add(aaaa.address);
result.add(Inet6Address.getByName(aaaa.response));
} catch (UnknownHostException ex) {
Log.e(ex);
}
if (result.size() == 0) if (result.size() == 0)
throw new UnknownHostException(host); throw new UnknownHostException(host);
@ -371,11 +363,17 @@ public class DnsHelper {
Integer priority; Integer priority;
Integer weight; Integer weight;
Boolean secure; Boolean secure;
InetAddress address;
DnsRecord(String response) { DnsRecord(String response) {
this.response = response; this.response = response;
} }
DnsRecord(InetAddress address) {
this.address = address;
this.response = address.getHostAddress();
}
DnsRecord(String response, int port) { DnsRecord(String response, int port) {
this.response = response; this.response = response;
this.port = port; this.port = port;

Loading…
Cancel
Save