1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-03 21:55:13 +00:00

Auto disable protocol logging

This commit is contained in:
M66B 2021-10-28 18:08:11 +02:00
parent e8d775184b
commit fad4aaea3f
2 changed files with 12 additions and 1 deletions

View file

@ -65,6 +65,7 @@ import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedHashMap;
@ -129,6 +130,7 @@ public class EmailService implements AutoCloseable {
private final static int FETCH_SIZE = 1024 * 1024; // bytes, default 16K
private final static int POOL_SIZE = 1; // connections
private final static int POOL_TIMEOUT = 60 * 1000; // milliseconds, default 45 sec
private final static long PROTOCOL_LOG_DURATION = 12 * 3600 * 1000L;
private final static int MAX_IPV4 = 2;
private final static int MAX_IPV6 = 1;
@ -166,7 +168,13 @@ public class EmailService implements AutoCloseable {
properties = MessageHelper.getSessionProperties();
long now = new Date().getTime();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
long protocol_since = prefs.getLong("protocol_since", 0);
if (protocol_since == 0)
prefs.edit().putLong("protocol_since", now).apply();
else if (protocol_since + PROTOCOL_LOG_DURATION < now)
prefs.edit().putBoolean("protocol", false).apply();
this.log = prefs.getBoolean("protocol", false);
this.harden = prefs.getBoolean("ssl_harden", false);

View file

@ -78,6 +78,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.SortedMap;
@ -809,7 +810,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("protocol", checked).apply();
if (!checked)
if (checked)
prefs.edit().putLong("protocol_since", new Date().getTime()).apply();
else
EntityLog.clear(compoundButton.getContext());
}
});