mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-19 05:38:31 +00:00
Save/restore host/IP
This commit is contained in:
parent
5ce61ef096
commit
99acb26b69
1 changed files with 15 additions and 2 deletions
|
@ -500,9 +500,22 @@ public class EmailService implements AutoCloseable {
|
|||
// throw new MailConnectException(
|
||||
// new SocketConnectException("Debug", new IOException("Test"), host, port, 0));
|
||||
|
||||
main = InetAddress.getByName(host);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
String key = "dns." + host;
|
||||
try {
|
||||
main = InetAddress.getByName(host);
|
||||
prefs.edit().putString(key, main.getHostAddress()).apply();
|
||||
} catch (UnknownHostException ex) {
|
||||
String last = prefs.getString(key, null);
|
||||
if (TextUtils.isEmpty(last))
|
||||
throw new MessagingException(ex.getMessage(), ex);
|
||||
else {
|
||||
Log.w("Using " + key + "=" + last);
|
||||
main = InetAddress.getByName(last);
|
||||
}
|
||||
}
|
||||
|
||||
boolean prefer_ip4 = prefs.getBoolean("prefer_ip4", true);
|
||||
if (prefer_ip4 &&
|
||||
main instanceof Inet6Address)
|
||||
|
|
Loading…
Reference in a new issue