mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-01 09:16:00 +00:00
Removed app DNS cache
This commit is contained in:
parent
6494590aff
commit
f2502b181e
3 changed files with 2 additions and 26 deletions
|
@ -465,15 +465,6 @@ public class DnsHelper {
|
||||||
return result;
|
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() {
|
static boolean hasDnsSec() {
|
||||||
if (BuildConfig.PLAY_STORE_RELEASE)
|
if (BuildConfig.PLAY_STORE_RELEASE)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -425,8 +425,6 @@ public class EmailService implements AutoCloseable {
|
||||||
String certificate, String fingerprint) throws MessagingException {
|
String certificate, String fingerprint) throws MessagingException {
|
||||||
properties.put("fairemail.server", host);
|
properties.put("fairemail.server", host);
|
||||||
|
|
||||||
DnsHelper.clear(context);
|
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
boolean bind_socket = prefs.getBoolean("bind_socket", false);
|
boolean bind_socket = prefs.getBoolean("bind_socket", false);
|
||||||
if (bind_socket &&
|
if (bind_socket &&
|
||||||
|
@ -639,20 +637,8 @@ public class EmailService implements AutoCloseable {
|
||||||
// throw new MailConnectException(
|
// throw new MailConnectException(
|
||||||
// new SocketConnectException("Debug", new IOException("Test"), host, port, 0));
|
// new SocketConnectException("Debug", new IOException("Test"), host, port, 0));
|
||||||
|
|
||||||
String key = "dns." + host;
|
|
||||||
try {
|
|
||||||
main = DnsHelper.getByName(context, host, dnssec);
|
main = DnsHelper.getByName(context, host, dnssec);
|
||||||
EntityLog.log(context, EntityLog.Type.Network, "Main address=" + main);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean prefer_ip4 = prefs.getBoolean("prefer_ip4", true);
|
boolean prefer_ip4 = prefs.getBoolean("prefer_ip4", true);
|
||||||
if (prefer_ip4 && main instanceof Inet6Address) {
|
if (prefer_ip4 && main instanceof Inet6Address) {
|
||||||
|
|
|
@ -352,7 +352,6 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
||||||
swDnsCustom.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
swDnsCustom.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
|
||||||
DnsHelper.clear(buttonView.getContext());
|
|
||||||
prefs.edit().putBoolean("dns_custom", checked).apply();
|
prefs.edit().putBoolean("dns_custom", checked).apply();
|
||||||
tvDnsExtra.setEnabled(checked || Build.VERSION.SDK_INT < Build.VERSION_CODES.Q);
|
tvDnsExtra.setEnabled(checked || Build.VERSION.SDK_INT < Build.VERSION_CODES.Q);
|
||||||
etDnsExtra.setEnabled(checked || Build.VERSION.SDK_INT < Build.VERSION_CODES.Q);
|
etDnsExtra.setEnabled(checked || Build.VERSION.SDK_INT < Build.VERSION_CODES.Q);
|
||||||
|
|
Loading…
Reference in a new issue