Replaced getByName/getAllByName

This commit is contained in:
M66B
2024-01-01 22:30:34 +01:00
parent b5f19f9e2d
commit 94c6fca5dc
6 changed files with 46 additions and 14 deletions

View File

@@ -617,7 +617,7 @@ public class EmailService implements AutoCloseable {
String key = "dns." + host;
try {
main = InetAddress.getByName(host);
main = DnsHelper.getByName(context, host);
EntityLog.log(context, EntityLog.Type.Network, "Main address=" + main);
prefs.edit().putString(key, main.getHostAddress()).apply();
} catch (UnknownHostException ex) {
@@ -626,7 +626,7 @@ public class EmailService implements AutoCloseable {
throw ex;
else {
EntityLog.log(context, EntityLog.Type.Network, "Using " + key + "=" + last);
main = InetAddress.getByName(last);
main = DnsHelper.getByName(context, last);
}
}
@@ -635,7 +635,7 @@ public class EmailService implements AutoCloseable {
boolean[] has46 = ConnectionHelper.has46(context);
if (has46[0])
try {
for (InetAddress iaddr : InetAddress.getAllByName(host))
for (InetAddress iaddr : DnsHelper.getAllByName(context, host))
if (iaddr instanceof Inet4Address) {
main = iaddr;
EntityLog.log(context, EntityLog.Type.Network, "Preferring=" + main);
@@ -723,7 +723,7 @@ public class EmailService implements AutoCloseable {
ex + "\n" + android.util.Log.getStackTraceString(ex));
try {
// Some devices resolve IPv6 addresses while not having IPv6 connectivity
InetAddress[] iaddrs = InetAddress.getAllByName(host);
InetAddress[] iaddrs = DnsHelper.getAllByName(context, host);
int ip4 = (main instanceof Inet4Address ? 1 : 0);
int ip6 = (main instanceof Inet6Address ? 1 : 0);