From 4b41975935464c7bf4b41d9fae65ee601949ece9 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 5 Jan 2024 13:38:06 +0100 Subject: [PATCH] MiniDNS: disable using Google's DNS server --- app/src/main/java/eu/faircode/email/DnsHelper.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DnsHelper.java b/app/src/main/java/eu/faircode/email/DnsHelper.java index a1ee41636e..414d638d09 100644 --- a/app/src/main/java/eu/faircode/email/DnsHelper.java +++ b/app/src/main/java/eu/faircode/email/DnsHelper.java @@ -29,10 +29,12 @@ import android.text.TextUtils; import androidx.annotation.NonNull; +import org.minidns.AbstractDnsClient; import org.minidns.DnsClient; import org.minidns.dnsmessage.DnsMessage; import org.minidns.dnsqueryresult.DnsQueryResult; import org.minidns.dnsqueryresult.StandardDnsQueryResult; +import org.minidns.dnssec.DnssecClient; import org.minidns.dnssec.DnssecResultNotAuthenticException; import org.minidns.dnssec.DnssecValidationFailedException; import org.minidns.dnsserverlookup.AbstractDnsServerLookupMechanism; @@ -127,9 +129,10 @@ public class DnsHelper { try { ResolverApi resolver = DnssecResolverApi.INSTANCE; + AbstractDnsClient client = resolver.getClient(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) - resolver.getClient().setDataSource(new AbstractDnsDataSource() { + client.setDataSource(new AbstractDnsDataSource() { private IOException ex; private DnsQueryResult result; @@ -196,7 +199,7 @@ public class DnsHelper { } }); - resolver.getClient().getDataSource().setTimeout(timeout * 1000); + client.getDataSource().setTimeout(timeout * 1000); List servers = getDnsServers(context); Log.i("DNS servers=" + TextUtils.join(",", servers)); @@ -214,6 +217,10 @@ public class DnsHelper { } }); + // https://github.com/MiniDNS/minidns/issues/102 + if (client instanceof DnssecClient && !BuildConfig.PLAY_STORE_RELEASE) + ((DnssecClient) client).setUseHardcodedDnsServers(false); + Log.i("DNS query name=" + type + ":" + name); ResolverResult data = resolver.resolve(name, clazz); data.throwIfErrorResponse();