DNS retry custom

This commit is contained in:
M66B 2024-01-30 11:02:06 +01:00
parent 346c125125
commit 689c557a02
1 changed files with 15 additions and 3 deletions

View File

@ -55,6 +55,7 @@ import org.minidns.record.Record;
import org.minidns.record.SRV;
import org.minidns.record.TXT;
import org.minidns.source.AbstractDnsDataSource;
import org.minidns.source.DnsDataSource;
import org.minidns.util.MultipleIoException;
import java.io.ByteArrayOutputStream;
@ -184,6 +185,8 @@ public class DnsHelper {
ResolverApi resolver = DnssecResolverApi.INSTANCE;
AbstractDnsClient client = resolver.getClient();
DnsDataSource dataSource = client.getDataSource();
if (false) {
String private_dns = ConnectionHelper.getPrivateDnsServerName(context);
Log.w("DNS private=" + private_dns);
@ -199,7 +202,17 @@ public class DnsHelper {
((DnssecClient) client).setUseHardcodedDnsServers(false);
Log.i("DNS query name=" + type + ":" + name);
ResolverResult<? extends Data> data = resolver.resolve(name, clazz);
ResolverResult<? extends Data> data;
try {
data = resolver.resolve(name, clazz);
} catch (Throwable ex) {
Log.w(ex);
if (dataSource == null || dataSource == client.getDataSource())
throw ex;
Log.i("DNS retry custom");
client.setDataSource(dataSource);
data = resolver.resolve(name, clazz);
}
Log.i("DNS resolved name=" + type + ":" + name +
" success=" + data.wasSuccessful() +
" rcode=" + data.getResponseCode());
@ -207,8 +220,7 @@ public class DnsHelper {
try {
data.throwIfErrorResponse();
} catch (Throwable ex) {
Log.e("DNS error message=" + ex.getMessage());
Log.e(ex);
Log.w("DNS error message=" + ex.getMessage());
throw ex;
}