From f2502b181e6a454c9179a5d71cfc0a2c0ef1d4db Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 21 Jun 2024 16:19:29 +0200 Subject: [PATCH] Removed app DNS cache --- .../main/java/eu/faircode/email/DnsHelper.java | 9 --------- .../java/eu/faircode/email/EmailService.java | 18 ++---------------- .../email/FragmentOptionsConnection.java | 1 - 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DnsHelper.java b/app/src/main/java/eu/faircode/email/DnsHelper.java index 0aafa8d861..abba732508 100644 --- a/app/src/main/java/eu/faircode/email/DnsHelper.java +++ b/app/src/main/java/eu/faircode/email/DnsHelper.java @@ -465,15 +465,6 @@ public class DnsHelper { return result; } - static void clear(Context context) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - SharedPreferences.Editor editor = prefs.edit(); - for (String key : prefs.getAll().keySet()) - if (key != null && key.startsWith("dns.")) - editor.remove(key); - editor.apply(); - } - static boolean hasDnsSec() { if (BuildConfig.PLAY_STORE_RELEASE) return false; diff --git a/app/src/main/java/eu/faircode/email/EmailService.java b/app/src/main/java/eu/faircode/email/EmailService.java index aeb1f3025f..c2c2bc8775 100644 --- a/app/src/main/java/eu/faircode/email/EmailService.java +++ b/app/src/main/java/eu/faircode/email/EmailService.java @@ -425,8 +425,6 @@ public class EmailService implements AutoCloseable { String certificate, String fingerprint) throws MessagingException { properties.put("fairemail.server", host); - DnsHelper.clear(context); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean bind_socket = prefs.getBoolean("bind_socket", false); if (bind_socket && @@ -639,20 +637,8 @@ public class EmailService implements AutoCloseable { // throw new MailConnectException( // new SocketConnectException("Debug", new IOException("Test"), host, port, 0)); - String key = "dns." + host; - try { - main = DnsHelper.getByName(context, host, dnssec); - EntityLog.log(context, EntityLog.Type.Network, "Main address=" + main); - prefs.edit().putString(key, main.getHostAddress()).apply(); - } catch (UnknownHostException ex) { - String last = prefs.getString(key, null); - if (TextUtils.isEmpty(last)) - throw ex; - else { - EntityLog.log(context, EntityLog.Type.Network, "Using " + key + "=" + last); - main = DnsHelper.getByName(context, last, dnssec); - } - } + main = DnsHelper.getByName(context, host, dnssec); + EntityLog.log(context, EntityLog.Type.Network, "Main address=" + main); boolean prefer_ip4 = prefs.getBoolean("prefer_ip4", true); if (prefer_ip4 && main instanceof Inet6Address) { diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java b/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java index 8b70c77e3e..30176c583f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java @@ -352,7 +352,6 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre swDnsCustom.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean checked) { - DnsHelper.clear(buttonView.getContext()); prefs.edit().putBoolean("dns_custom", checked).apply(); tvDnsExtra.setEnabled(checked || Build.VERSION.SDK_INT < Build.VERSION_CODES.Q); etDnsExtra.setEnabled(checked || Build.VERSION.SDK_INT < Build.VERSION_CODES.Q);