Networkstack - switch IPv4 and IPv6
This commit is contained in:
parent
ce8cad3886
commit
d5b7d6b65a
|
@ -7,7 +7,7 @@ import android.util.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.Inet4Address;
|
import java.net.Inet6Address;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -219,12 +219,12 @@ public class Resolver {
|
||||||
private static List<Result> resolveNoSrvRecords(DNSName dnsName, boolean withCnames) {
|
private static List<Result> resolveNoSrvRecords(DNSName dnsName, boolean withCnames) {
|
||||||
List<Result> results = new ArrayList<>();
|
List<Result> results = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
for (A a : resolveWithFallback(dnsName, A.class, false).getAnswersOrEmptySet()) {
|
|
||||||
results.add(Result.createDefault(dnsName, a.getInetAddress()));
|
|
||||||
}
|
|
||||||
for (AAAA aaaa : resolveWithFallback(dnsName, AAAA.class, false).getAnswersOrEmptySet()) {
|
for (AAAA aaaa : resolveWithFallback(dnsName, AAAA.class, false).getAnswersOrEmptySet()) {
|
||||||
results.add(Result.createDefault(dnsName, aaaa.getInetAddress()));
|
results.add(Result.createDefault(dnsName, aaaa.getInetAddress()));
|
||||||
}
|
}
|
||||||
|
for (A a : resolveWithFallback(dnsName, A.class, false).getAnswersOrEmptySet()) {
|
||||||
|
results.add(Result.createDefault(dnsName, a.getInetAddress()));
|
||||||
|
}
|
||||||
if (results.size() == 0 && withCnames) {
|
if (results.size() == 0 && withCnames) {
|
||||||
for (CNAME cname : resolveWithFallback(dnsName, CNAME.class, false).getAnswersOrEmptySet()) {
|
for (CNAME cname : resolveWithFallback(dnsName, CNAME.class, false).getAnswersOrEmptySet()) {
|
||||||
results.addAll(resolveNoSrvRecords(cname.name, false));
|
results.addAll(resolveNoSrvRecords(cname.name, false));
|
||||||
|
@ -379,10 +379,10 @@ public class Resolver {
|
||||||
if (ip == null && result.ip == null) {
|
if (ip == null && result.ip == null) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (ip != null && result.ip != null) {
|
} else if (ip != null && result.ip != null) {
|
||||||
if (ip instanceof Inet4Address && result.ip instanceof Inet4Address) {
|
if (ip instanceof Inet6Address && result.ip instanceof Inet6Address) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return ip instanceof Inet4Address ? -1 : 1;
|
return ip instanceof Inet6Address ? -1 : 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return ip != null ? -1 : 1;
|
return ip != null ? -1 : 1;
|
||||||
|
|
Loading…
Reference in New Issue