Check owner domain, not email server

pull/199/head
M66B 4 years ago
parent 97ec6f0bbf
commit 2df607dac8

@ -59,6 +59,7 @@ import androidx.core.util.PatternsCompat;
import androidx.preference.PreferenceManager;
import java.net.IDN;
import java.net.InetAddress;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@ -296,7 +297,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
Bundle args = new Bundle();
args.putParcelable("uri", uri);
new SimpleTask<Pair<String, IPInfo.Organization>>() {
new SimpleTask<Pair<InetAddress, IPInfo.Organization>>() {
@Override
protected void onPreExecute(Bundle args) {
btnOwner.setEnabled(false);
@ -312,14 +313,14 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
}
@Override
protected Pair<String, IPInfo.Organization> onExecute(Context context, Bundle args) throws Throwable {
protected Pair<InetAddress, IPInfo.Organization> onExecute(Context context, Bundle args) throws Throwable {
Uri uri = args.getParcelable("uri");
return IPInfo.getOrganization(uri, context);
}
@Override
protected void onExecuted(Bundle args, Pair<String, IPInfo.Organization> data) {
tvHost.setText(data.first);
protected void onExecuted(Bundle args, Pair<InetAddress, IPInfo.Organization> data) {
tvHost.setText(data.first.toString());
tvOwner.setText(data.second.name == null ? "?" : data.second.name);
ApplicationEx.getMainHandler().post(new Runnable() {
@Override

@ -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));
}
}

Loading…
Cancel
Save