Improved check MX error handling

pull/199/head
M66B 4 years ago
parent d639665011
commit eb4b3ed06a

@ -66,7 +66,6 @@ public class DnsHelper {
if (domain == null) if (domain == null)
continue; continue;
boolean found = true;
try { try {
SimpleResolver resolver = new SimpleResolver(getDnsServer(context)); SimpleResolver resolver = new SimpleResolver(getDnsServer(context));
resolver.setTimeout(CHECK_TIMEOUT); resolver.setTimeout(CHECK_TIMEOUT);
@ -75,17 +74,20 @@ public class DnsHelper {
lookup.run(); lookup.run();
Log.i("Check name=" + domain + " @" + resolver.getAddress() + " result=" + lookup.getResult()); Log.i("Check name=" + domain + " @" + resolver.getAddress() + " result=" + lookup.getResult());
if (lookup.getResult() == Lookup.SUCCESSFUL)
continue;
String error = "Error " + lookup.getResult() + ": " + lookup.getErrorString();
if (lookup.getResult() == Lookup.HOST_NOT_FOUND || if (lookup.getResult() == Lookup.HOST_NOT_FOUND ||
lookup.getResult() == Lookup.TYPE_NOT_FOUND) lookup.getResult() == Lookup.TYPE_NOT_FOUND)
found = false; throw new UnknownHostException(error);
else if (lookup.getResult() != Lookup.SUCCESSFUL) else
throw new UnknownHostException("DNS error=" + lookup.getErrorString()); Log.e(error);
} catch (UnknownHostException ex) {
throw ex;
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(ex); Log.e(ex);
} }
if (!found)
throw new UnknownHostException(context.getString(R.string.title_no_server, domain));
} }
} }

Loading…
Cancel
Save