[app] Fix DoH fallback (#273)

This commit is contained in:
vvb2060 2021-03-06 02:52:30 +08:00 committed by GitHub
parent 5b6221e04d
commit 329a19b448
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -56,13 +56,13 @@ public class DoHDNS implements Dns {
@Override
public List<InetAddress> lookup(@NonNull String hostname) throws UnknownHostException {
if (App.getPreferences().getBoolean("doh", false)) {
List<InetAddress> inetAddresses = cloudflare.lookup(hostname);
if (inetAddresses.size() > 0) {
return inetAddresses;
} else if ("CN".equals(Locale.getDefault().getCountry())) {
inetAddresses = alidns.lookup(hostname);
if (inetAddresses.size() > 0) {
return inetAddresses;
try {
return cloudflare.lookup(hostname);
} catch (UnknownHostException e) {
try {
if ("CN".equals(Locale.getDefault().getCountry()))
return alidns.lookup(hostname);
} catch (UnknownHostException ignored) {
}
}
}