Check owner domain, not email server

This commit is contained in:
M66B
2021-07-03 20:36:38 +02:00
parent 97ec6f0bbf
commit 2df607dac8
2 changed files with 12 additions and 10 deletions

View File

@@ -42,22 +42,23 @@ public class IPInfo {
private final static int FETCH_TIMEOUT = 15 * 1000; // milliseconds
static Pair<String, Organization> getOrganization(@NonNull Uri uri, Context context) throws IOException, ParseException {
static Pair<InetAddress, Organization> getOrganization(@NonNull Uri uri, Context context) throws IOException, ParseException {
if ("mailto".equalsIgnoreCase(uri.getScheme())) {
MailTo email = MailTo.parse(uri.toString());
String domain = UriHelper.getEmailDomain(email.getTo());
if (domain == null)
throw new UnknownHostException();
InetAddress address = DnsHelper.lookupMx(context, domain);
if (address == null)
throw new UnknownHostException();
return new Pair<>(domain, getOrganization(address, context));
//InetAddress address = DnsHelper.lookupMx(context, domain);
//if (address == null)
// throw new UnknownHostException();
InetAddress address = InetAddress.getByName(domain);
return new Pair<>(address, getOrganization(address, context));
} else {
String host = uri.getHost();
if (host == null)
throw new UnknownHostException();
InetAddress address = InetAddress.getByName(host);
return new Pair<>(host, getOrganization(address, context));
return new Pair<>(address, getOrganization(address, context));
}
}