mirror of https://github.com/M66B/FairEmail.git
DNS retry custom
This commit is contained in:
parent
346c125125
commit
689c557a02
|
@ -55,6 +55,7 @@ import org.minidns.record.Record;
|
||||||
import org.minidns.record.SRV;
|
import org.minidns.record.SRV;
|
||||||
import org.minidns.record.TXT;
|
import org.minidns.record.TXT;
|
||||||
import org.minidns.source.AbstractDnsDataSource;
|
import org.minidns.source.AbstractDnsDataSource;
|
||||||
|
import org.minidns.source.DnsDataSource;
|
||||||
import org.minidns.util.MultipleIoException;
|
import org.minidns.util.MultipleIoException;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -184,6 +185,8 @@ public class DnsHelper {
|
||||||
ResolverApi resolver = DnssecResolverApi.INSTANCE;
|
ResolverApi resolver = DnssecResolverApi.INSTANCE;
|
||||||
AbstractDnsClient client = resolver.getClient();
|
AbstractDnsClient client = resolver.getClient();
|
||||||
|
|
||||||
|
DnsDataSource dataSource = client.getDataSource();
|
||||||
|
|
||||||
if (false) {
|
if (false) {
|
||||||
String private_dns = ConnectionHelper.getPrivateDnsServerName(context);
|
String private_dns = ConnectionHelper.getPrivateDnsServerName(context);
|
||||||
Log.w("DNS private=" + private_dns);
|
Log.w("DNS private=" + private_dns);
|
||||||
|
@ -199,7 +202,17 @@ public class DnsHelper {
|
||||||
((DnssecClient) client).setUseHardcodedDnsServers(false);
|
((DnssecClient) client).setUseHardcodedDnsServers(false);
|
||||||
|
|
||||||
Log.i("DNS query name=" + type + ":" + name);
|
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 +
|
Log.i("DNS resolved name=" + type + ":" + name +
|
||||||
" success=" + data.wasSuccessful() +
|
" success=" + data.wasSuccessful() +
|
||||||
" rcode=" + data.getResponseCode());
|
" rcode=" + data.getResponseCode());
|
||||||
|
@ -207,8 +220,7 @@ public class DnsHelper {
|
||||||
try {
|
try {
|
||||||
data.throwIfErrorResponse();
|
data.throwIfErrorResponse();
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.e("DNS error message=" + ex.getMessage());
|
Log.w("DNS error message=" + ex.getMessage());
|
||||||
Log.e(ex);
|
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue