Refactoring

pull/178/head
M66B 6 years ago
parent 67d621450d
commit 1f8079e773

@ -2284,7 +2284,7 @@ class Core {
boolean check_mx = prefs.getBoolean("check_mx", false);
if (check_mx)
try {
if (DNSHelper.lookupMx(
if (DnsHelper.lookupMx(
context, message.reply == null || message.reply.length == 0
? message.from : message.reply))
message.mx = true;
@ -2347,12 +2347,12 @@ class Core {
String r = ((InternetAddress) reply).getAddress();
int rat = (r == null ? -1 : r.indexOf('@'));
if (rat > 0) {
String rdomain = DNSHelper.getParentDomain(r.substring(rat + 1));
String rdomain = DnsHelper.getParentDomain(r.substring(rat + 1));
for (Address from : message.from) {
String f = ((InternetAddress) from).getAddress();
int fat = (f == null ? -1 : f.indexOf('@'));
if (fat > 0) {
String fdomain = DNSHelper.getParentDomain(f.substring(fat + 1));
String fdomain = DnsHelper.getParentDomain(f.substring(fat + 1));
if (!rdomain.equalsIgnoreCase(fdomain)) {
if (message.warning == null)
message.warning = context.getString(R.string.title_reply_domain, fdomain, rdomain);

@ -43,7 +43,7 @@ import java.util.List;
import javax.mail.Address;
import javax.mail.internet.InternetAddress;
public class DNSHelper {
public class DnsHelper {
// https://dns.watch/
private static final String DEFAULT_DNS = "84.200.69.80";
@ -179,7 +179,7 @@ public class DNSHelper {
String domain = "gmail.com";
boolean ok = lookupMx(context, new Address[]{Log.myAddress()});
InetAddress iaddr = lookupMx(context, domain);
Record[] records = DNSHelper.lookup(context, "_imaps._tcp." + domain, Type.SRV);
Record[] records = DnsHelper.lookup(context, "_imaps._tcp." + domain, Type.SRV);
SRVRecord srv = (SRVRecord) records[0];
Log.i("DNS ok=" + ok + " iaddr=" + iaddr + " srv=" + srv.getTarget().toString());
} catch (Throwable ex) {

@ -226,7 +226,7 @@ public class EmailProvider {
try {
// Retry at MX server addresses
Record[] records = DNSHelper.lookup(context, domain, Type.MX);
Record[] records = DnsHelper.lookup(context, domain, Type.MX);
for (Record record : records) {
String target = ((MXRecord) record).getTarget().toString(true);
while (autoconfig == null && target != null && target.indexOf('.') > 0) {
@ -505,7 +505,7 @@ public class EmailProvider {
if (discover == Discover.ALL || discover == Discover.IMAP) {
try {
// Identifies an IMAP server where TLS is initiated directly upon connection to the IMAP server.
Record[] records = DNSHelper.lookup(context, "_imaps._tcp." + domain, Type.SRV);
Record[] records = DnsHelper.lookup(context, "_imaps._tcp." + domain, Type.SRV);
// ... service is not supported at all at a particular domain by setting the target of an SRV RR to "."
SRVRecord srv = (SRVRecord) records[0];
provider.imap.host = srv.getTarget().toString(true);
@ -513,7 +513,7 @@ public class EmailProvider {
provider.imap.starttls = false;
} catch (UnknownHostException ex) {
// Identifies an IMAP server that MAY ... require the MUA to use the "STARTTLS" command
Record[] records = DNSHelper.lookup(context, "_imap._tcp." + domain, Type.SRV);
Record[] records = DnsHelper.lookup(context, "_imap._tcp." + domain, Type.SRV);
SRVRecord srv = (SRVRecord) records[0];
provider.imap.host = srv.getTarget().toString(true);
provider.imap.port = srv.getPort();
@ -523,7 +523,7 @@ public class EmailProvider {
if (discover == Discover.ALL || discover == Discover.SMTP) {
// Note that this covers connections both with and without Transport Layer Security (TLS)
Record[] records = DNSHelper.lookup(context, "_submission._tcp." + domain, Type.SRV);
Record[] records = DnsHelper.lookup(context, "_submission._tcp." + domain, Type.SRV);
SRVRecord srv = (SRVRecord) records[0];
provider.smtp.host = srv.getTarget().toString(true);
provider.smtp.port = srv.getPort();

@ -1077,7 +1077,7 @@ public class FragmentAccount extends FragmentBase {
db.beginTransaction();
if (account != null && !account.password.equals(password)) {
String domain = DNSHelper.getParentDomain(account.host);
String domain = DnsHelper.getParentDomain(account.host);
String match = (Objects.equals(account.host, domain) ? account.host : "%." + domain);
int count = db.identity().setIdentityPassword(account.id, account.user, password, match);
Log.i("Updated passwords=" + count + " match=" + match);

@ -3818,7 +3818,7 @@ public class FragmentCompose extends FragmentBase {
for (InternetAddress address : ato)
address.validate();
if (lookup_mx)
DNSHelper.lookupMx(context, ato);
DnsHelper.lookupMx(context, ato);
}
} catch (AddressException ex) {
throw new AddressException(context.getString(R.string.title_address_parse_error,
@ -3832,7 +3832,7 @@ public class FragmentCompose extends FragmentBase {
for (InternetAddress address : acc)
address.validate();
if (lookup_mx)
DNSHelper.lookupMx(context, acc);
DnsHelper.lookupMx(context, acc);
}
} catch (AddressException ex) {
throw new AddressException(context.getString(R.string.title_address_parse_error,
@ -3846,7 +3846,7 @@ public class FragmentCompose extends FragmentBase {
for (InternetAddress address : abcc)
address.validate();
if (lookup_mx)
DNSHelper.lookupMx(context, abcc);
DnsHelper.lookupMx(context, abcc);
}
} catch (AddressException ex) {
throw new AddressException(context.getString(R.string.title_address_parse_error,

@ -349,7 +349,7 @@ public class FragmentPop extends FragmentBase {
db.beginTransaction();
if (account != null && !account.password.equals(password)) {
String domain = DNSHelper.getParentDomain(account.host);
String domain = DnsHelper.getParentDomain(account.host);
String match = (Objects.equals(account.host, domain) ? account.host : "%." + domain);
int count = db.identity().setIdentityPassword(account.id, account.user, password, match);
Log.i("Updated passwords=" + count + " match=" + match);

@ -47,7 +47,7 @@ public class IPInfo {
if (to == null || !to.contains("@"))
throw new UnknownHostException();
String domain = to.substring(to.indexOf('@') + 1);
InetAddress address = DNSHelper.lookupMx(context, domain);
InetAddress address = DnsHelper.lookupMx(context, domain);
if (address == null)
throw new UnknownHostException();
return new Pair<>(domain, getOrganization(address));

Loading…
Cancel
Save