|
|
@ -101,7 +101,7 @@ public class DnsHelper {
|
|
|
|
String domain = UriHelper.getEmailDomain(email);
|
|
|
|
String domain = UriHelper.getEmailDomain(email);
|
|
|
|
if (domain == null)
|
|
|
|
if (domain == null)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
DnsRecord[] records = _lookup(context, domain, "mx", CHECK_TIMEOUT, false);
|
|
|
|
DnsRecord[] records = _lookup(context, domain, "mx", CHECK_TIMEOUT);
|
|
|
|
if (records.length == 0)
|
|
|
|
if (records.length == 0)
|
|
|
|
throw new UnknownHostException(domain);
|
|
|
|
throw new UnknownHostException(domain);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -109,11 +109,25 @@ public class DnsHelper {
|
|
|
|
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
@NonNull
|
|
|
|
static DnsRecord[] lookup(Context context, String name, String type) {
|
|
|
|
static DnsRecord[] lookup(Context context, String name, String type) {
|
|
|
|
return _lookup(context, name, type, LOOKUP_TIMEOUT, false);
|
|
|
|
return _lookup(context, name, type, LOOKUP_TIMEOUT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
@NonNull
|
|
|
|
private static DnsRecord[] _lookup(Context context, String name, String type, int timeout, boolean dnssec) {
|
|
|
|
private static DnsRecord[] _lookup(Context context, String name, String type, int timeout) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
return _lookup(context, name, type, timeout, false);
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
if (ex instanceof MultipleIoException ||
|
|
|
|
|
|
|
|
ex instanceof ResolutionUnsuccessfulException)
|
|
|
|
|
|
|
|
Log.i(ex);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
|
|
|
return new DnsRecord[0];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
|
|
|
|
private static DnsRecord[] _lookup(Context context, String name, String type, int timeout, boolean dnssec) throws IOException {
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
boolean dns_custom = prefs.getBoolean("dns_custom", false);
|
|
|
|
boolean dns_custom = prefs.getBoolean("dns_custom", false);
|
|
|
|
|
|
|
|
|
|
|
@ -148,7 +162,6 @@ public class DnsHelper {
|
|
|
|
throw new IllegalArgumentException(type);
|
|
|
|
throw new IllegalArgumentException(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
ResolverApi resolver = DnssecResolverApi.INSTANCE;
|
|
|
|
ResolverApi resolver = DnssecResolverApi.INSTANCE;
|
|
|
|
AbstractDnsClient client = resolver.getClient();
|
|
|
|
AbstractDnsClient client = resolver.getClient();
|
|
|
|
|
|
|
|
|
|
|
@ -273,16 +286,6 @@ public class DnsHelper {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return result.toArray(new DnsRecord[0]);
|
|
|
|
return result.toArray(new DnsRecord[0]);
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
if (ex instanceof MultipleIoException ||
|
|
|
|
|
|
|
|
ex instanceof ResolutionUnsuccessfulException ||
|
|
|
|
|
|
|
|
ex instanceof DnssecValidationFailedException ||
|
|
|
|
|
|
|
|
ex instanceof DnssecResultNotAuthenticException)
|
|
|
|
|
|
|
|
Log.i(ex);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
|
|
|
return new DnsRecord[0];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static InetAddress getByName(Context context, String host) throws UnknownHostException {
|
|
|
|
static InetAddress getByName(Context context, String host) throws UnknownHostException {
|
|
|
@ -316,7 +319,7 @@ public class DnsHelper {
|
|
|
|
List<InetAddress> result = new ArrayList<>();
|
|
|
|
List<InetAddress> result = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
boolean[] has46 = ConnectionHelper.has46(context);
|
|
|
|
boolean[] has46 = ConnectionHelper.has46(context);
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (has46[0])
|
|
|
|
if (has46[0])
|
|
|
|
for (DnsRecord a : _lookup(context, host, "a", LOOKUP_TIMEOUT, dnssec))
|
|
|
|
for (DnsRecord a : _lookup(context, host, "a", LOOKUP_TIMEOUT, dnssec))
|
|
|
|
result.add(a.address);
|
|
|
|
result.add(a.address);
|
|
|
@ -329,6 +332,9 @@ public class DnsHelper {
|
|
|
|
throw new UnknownHostException(host);
|
|
|
|
throw new UnknownHostException(host);
|
|
|
|
|
|
|
|
|
|
|
|
return result.toArray(new InetAddress[0]);
|
|
|
|
return result.toArray(new InetAddress[0]);
|
|
|
|
|
|
|
|
} catch (IOException ex) {
|
|
|
|
|
|
|
|
throw new UnknownHostException(ex.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void verifyDane(X509Certificate[] chain, String server, int port) throws CertificateException {
|
|
|
|
static void verifyDane(X509Certificate[] chain, String server, int port) throws CertificateException {
|
|
|
|