mirror of https://github.com/M66B/FairEmail.git
DNS improvements
This commit is contained in:
parent
ab02df1106
commit
aca987277e
|
@ -199,19 +199,19 @@ public class DnsHelper {
|
||||||
client.setDataSource(new AuthoritiveDataSource(client.getDataSource()));
|
client.setDataSource(new AuthoritiveDataSource(client.getDataSource()));
|
||||||
|
|
||||||
// https://github.com/MiniDNS/minidns/issues/102
|
// https://github.com/MiniDNS/minidns/issues/102
|
||||||
if (client instanceof DnssecClient && dns_custom)
|
if (client instanceof DnssecClient)
|
||||||
((DnssecClient) client).setUseHardcodedDnsServers(false);
|
((DnssecClient) client).setUseHardcodedDnsServers(false);
|
||||||
|
|
||||||
|
ResolverResult<? extends Data> data;
|
||||||
|
try {
|
||||||
Log.i("DNS query name=" + type + ":" + name);
|
Log.i("DNS query name=" + type + ":" + name);
|
||||||
ResolverResult<? extends Data> data = resolver.resolve(name, clazz);
|
data = resolver.resolve(name, clazz);
|
||||||
Log.i("DNS resolved name=" + type + ":" + name +
|
Log.i("DNS resolved name=" + type + ":" + name +
|
||||||
" success=" + data.wasSuccessful() +
|
" success=" + data.wasSuccessful() +
|
||||||
" rcode=" + data.getResponseCode());
|
" rcode=" + data.getResponseCode());
|
||||||
|
|
||||||
try {
|
|
||||||
data.throwIfErrorResponse();
|
data.throwIfErrorResponse();
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.i("DNS error message=" + ex.getMessage());
|
Log.w("DNS error message=" + ex.getMessage());
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,9 @@ public class DnsHelper {
|
||||||
} else if (answer instanceof AAAA) {
|
} else if (answer instanceof AAAA) {
|
||||||
AAAA aaaa = (AAAA) answer;
|
AAAA aaaa = (AAAA) answer;
|
||||||
result.add(new DnsRecord(aaaa.getInetAddress()));
|
result.add(new DnsRecord(aaaa.getInetAddress()));
|
||||||
}
|
} else
|
||||||
|
Log.e("DNS unexpected record=" +
|
||||||
|
(answer == null ? null : answer.getClass().getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,10 +393,15 @@ public class DnsHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<String> getDnsServers(Context context) {
|
static List<String> getDnsServers(Context context) {
|
||||||
List<String> result = new ArrayList<>(_getDnsServers(context));
|
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
boolean dns_custom = prefs.getBoolean("dns_custom", false);
|
||||||
String dns_extra = prefs.getString("dns_extra", null);
|
String dns_extra = prefs.getString("dns_extra", null);
|
||||||
|
|
||||||
|
List<String> result = new ArrayList<>();
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || dns_custom)
|
||||||
|
result.addAll(_getDnsServers(context));
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(dns_extra)) {
|
if (!TextUtils.isEmpty(dns_extra)) {
|
||||||
String[] extras = dns_extra.replaceAll("\\s+", "").split(",");
|
String[] extras = dns_extra.replaceAll("\\s+", "").split(",");
|
||||||
for (String extra : extras)
|
for (String extra : extras)
|
||||||
|
|
Loading…
Reference in New Issue