mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-31 14:17:03 +02:00
Refactoring
This commit is contained in:
@@ -25,7 +25,6 @@ import android.net.Uri;
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.net.MailTo;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
@@ -44,28 +43,18 @@ public class IPInfo {
|
||||
private final static int FETCH_TIMEOUT = 15 * 1000; // milliseconds
|
||||
|
||||
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();
|
||||
InetAddress address = InetAddress.getByName(domain);
|
||||
return new Pair<>(address, getOrganization(address, context));
|
||||
} else {
|
||||
String host = uri.getHost();
|
||||
if (host == null)
|
||||
throw new UnknownHostException();
|
||||
try {
|
||||
host = IDN.toASCII(host, IDN.ALLOW_UNASSIGNED);
|
||||
} catch (Throwable ex) {
|
||||
Log.i(ex);
|
||||
}
|
||||
InetAddress address = InetAddress.getByName(host);
|
||||
return new Pair<>(address, getOrganization(address, context));
|
||||
String host = UriHelper.getHost(uri);
|
||||
if (host == null)
|
||||
throw new UnknownHostException();
|
||||
|
||||
try {
|
||||
host = IDN.toASCII(host, IDN.ALLOW_UNASSIGNED);
|
||||
} catch (Throwable ex) {
|
||||
Log.i(ex);
|
||||
}
|
||||
|
||||
InetAddress address = InetAddress.getByName(host);
|
||||
return new Pair<>(address, getOrganization(address, context));
|
||||
}
|
||||
|
||||
static Organization getOrganization(InetAddress address, Context context) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user