Skip to content
Snippets Groups Projects
Verified Commit 47b8079d authored by Torsten Grote's avatar Torsten Grote
Browse files

Address seb's review

parent 5ebbaa2d
Branches
No related tags found
1 merge request!169Add setting for opting in or out of Tor bridges
...@@ -18,6 +18,7 @@ import org.briarproject.mailbox.core.settings.SettingsManager ...@@ -18,6 +18,7 @@ import org.briarproject.mailbox.core.settings.SettingsManager
import org.briarproject.mailbox.core.system.LocationUtils import org.briarproject.mailbox.core.system.LocationUtils
import org.briarproject.mailbox.core.tor.NetworkManager import org.briarproject.mailbox.core.tor.NetworkManager
import org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_AUTO import org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_AUTO
import org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_AUTO_DEFAULT
import org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_USE import org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_USE
import org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_USE_MEEK import org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_USE_MEEK
import org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_USE_OBFS4 import org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_USE_OBFS4
...@@ -95,7 +96,7 @@ class SettingsFragment : PreferenceFragmentCompat() { ...@@ -95,7 +96,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
val settings = settingsManager.getSettings(SETTINGS_NAMESPACE) val settings = settingsManager.getSettings(SETTINGS_NAMESPACE)
this@SettingsFragment.settings = settings this@SettingsFragment.settings = settings
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
onAutoChanged(settings.getBoolean(BRIDGE_AUTO, true)) onAutoChanged(settings.getBoolean(BRIDGE_AUTO, BRIDGE_AUTO_DEFAULT))
preferenceManager.preferenceDataStore = torSettingsStore preferenceManager.preferenceDataStore = torSettingsStore
} }
} }
......
...@@ -55,6 +55,7 @@ import static java.util.Arrays.asList; ...@@ -55,6 +55,7 @@ import static java.util.Arrays.asList;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import static kotlinx.coroutines.flow.StateFlowKt.MutableStateFlow; import static kotlinx.coroutines.flow.StateFlowKt.MutableStateFlow;
import static org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_AUTO; import static org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_AUTO;
import static org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_AUTO_DEFAULT;
import static org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_USE; import static org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_USE;
import static org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_USE_MEEK; import static org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_USE_MEEK;
import static org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_USE_OBFS4; import static org.briarproject.mailbox.core.tor.TorConstants.BRIDGE_USE_OBFS4;
...@@ -354,7 +355,8 @@ public abstract class AbstractTorPlugin implements TorPlugin, EventListener { ...@@ -354,7 +355,8 @@ public abstract class AbstractTorPlugin implements TorPlugin, EventListener {
List<BridgeType> bridgeTypes = emptyList(); List<BridgeType> bridgeTypes = emptyList();
boolean bridgesNeeded = boolean bridgesNeeded =
circumventionProvider.doBridgesWork(country); circumventionProvider.doBridgesWork(country);
boolean bridgeAuto = settings.getBoolean(BRIDGE_AUTO, true); boolean bridgeAuto =
settings.getBoolean(BRIDGE_AUTO, BRIDGE_AUTO_DEFAULT);
if (bridgeAuto) { if (bridgeAuto) {
if (bridgesNeeded) { if (bridgesNeeded) {
if (ipv6Only) { if (ipv6Only) {
......
...@@ -29,6 +29,10 @@ public interface TorConstants { ...@@ -29,6 +29,10 @@ public interface TorConstants {
* Whether circumvention bridge handling should be handled automatically. * Whether circumvention bridge handling should be handled automatically.
*/ */
String BRIDGE_AUTO = "bridgeAuto"; String BRIDGE_AUTO = "bridgeAuto";
/**
* Whether automatic circumvention handling is enabled by default or not.
*/
boolean BRIDGE_AUTO_DEFAULT = true;
/** /**
* Whether bridges should be used for circumvention. * Whether bridges should be used for circumvention.
* Only consider when {@link #BRIDGE_AUTO} is false. * Only consider when {@link #BRIDGE_AUTO} is false.
......
...@@ -3,12 +3,16 @@ package org.briarproject.mailbox.core.tor; ...@@ -3,12 +3,16 @@ package org.briarproject.mailbox.core.tor;
import org.briarproject.mailbox.core.db.DbException; import org.briarproject.mailbox.core.db.DbException;
import org.briarproject.mailbox.core.lifecycle.Service; import org.briarproject.mailbox.core.lifecycle.Service;
import org.briarproject.mailbox.core.settings.Settings; import org.briarproject.mailbox.core.settings.Settings;
import org.briarproject.nullsafety.NotNullByDefault;
import org.briarproject.onionwrapper.CircumventionProvider.BridgeType; import org.briarproject.onionwrapper.CircumventionProvider.BridgeType;
import java.util.List; import java.util.List;
import javax.annotation.Nullable;
import kotlinx.coroutines.flow.StateFlow; import kotlinx.coroutines.flow.StateFlow;
@NotNullByDefault
public interface TorPlugin extends Service { public interface TorPlugin extends Service {
StateFlow<TorPluginState> getState(); StateFlow<TorPluginState> getState();
...@@ -23,6 +27,7 @@ public interface TorPlugin extends Service { ...@@ -23,6 +27,7 @@ public interface TorPlugin extends Service {
* This is only available after {@link #startService()} has returned. * This is only available after {@link #startService()} has returned.
* Otherwise returns null. * Otherwise returns null.
*/ */
@Nullable
String getHiddenServiceAddress() throws DbException; String getHiddenServiceAddress() throws DbException;
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment