Increase DNS timeout

This commit is contained in:
M66B 2020-07-21 09:19:23 +02:00
parent 790530dde8
commit 4e1b170ebe
1 changed files with 3 additions and 0 deletions

View File

@ -47,6 +47,7 @@ import javax.mail.internet.InternetAddress;
public class DnsHelper { public class DnsHelper {
// https://dns.watch/ // https://dns.watch/
private static final String DEFAULT_DNS = "84.200.69.80"; private static final String DEFAULT_DNS = "84.200.69.80";
private static final int DEFAULT_TIMEOUT = 15; // seconds
static void checkMx(Context context, Address[] addresses) throws UnknownHostException { static void checkMx(Context context, Address[] addresses) throws UnknownHostException {
if (addresses == null) if (addresses == null)
@ -66,6 +67,7 @@ public class DnsHelper {
boolean found = true; boolean found = true;
try { try {
SimpleResolver resolver = new SimpleResolver(getDnsServer(context)); SimpleResolver resolver = new SimpleResolver(getDnsServer(context));
resolver.setTimeout(DEFAULT_TIMEOUT);
Lookup lookup = new Lookup(domain, Type.MX); Lookup lookup = new Lookup(domain, Type.MX);
lookup.setResolver(resolver); lookup.setResolver(resolver);
lookup.run(); lookup.run();
@ -113,6 +115,7 @@ public class DnsHelper {
try { try {
SimpleResolver resolver = new SimpleResolver(getDnsServer(context)); SimpleResolver resolver = new SimpleResolver(getDnsServer(context));
resolver.setTimeout(DEFAULT_TIMEOUT);
Lookup lookup = new Lookup(name, rtype); Lookup lookup = new Lookup(name, rtype);
lookup.setResolver(resolver); lookup.setResolver(resolver);
Log.i("Lookup name=" + name + " @" + resolver.getAddress() + " type=" + rtype); Log.i("Lookup name=" + name + " @" + resolver.getAddress() + " type=" + rtype);