Dan Ballard pushed to branch firefox-android-115.2.1-13.5-1 at The Tor Project / Applications / firefox-android
Commits: 8cc03c8e by Dan Ballard at 2024-04-17T14:08:42-07:00 fixup! Add Tor integration and UI
Bug 42486: Fixing controller use of TorSettings so cleanupSettings doesn't reject partial states
- - - - -
1 changed file:
- fenix/app/src/main/java/org/mozilla/fenix/tor/TorControllerGV.kt
Changes:
===================================== fenix/app/src/main/java/org/mozilla/fenix/tor/TorControllerGV.kt ===================================== @@ -88,15 +88,21 @@ class TorControllerGV( return getTorIntegration().getSettings() }
+ + // Bridges Enabled is a cache variable. The TorController interface we are locked into at the + // moment to support the TAS backend calls setting `bridgesEnabled = true` and setting + // the bridge type seperately so to support that, + // while at the same time it being invalid states to not submit them together to the TorSettings + // backend where TorSettings.sys.mjs's #cleanupSettings will remove a lone bridgeEnabled + // we thus have to hold it here to support the UI but not submit to the backend until + // bridgeTransport is also set (below) + private var _bridgesEnabled: Boolean? = null override var bridgesEnabled: Boolean get() { - return getTorSettings()?.bridgesEnabled ?: false + return _bridgesEnabled ?: getTorSettings()?.bridgesEnabled ?: false } set(value) { - getTorSettings()?.let { - it.bridgesEnabled = value - getTorIntegration().setSettings(it, true, true) - } + _bridgesEnabled = value }
@@ -119,9 +125,13 @@ class TorControllerGV( } set(value) { getTorSettings()?.let { + it.bridgesEnabled = true if (value == TorBridgeTransportConfig.USER_PROVIDED) { - it.bridgesSource = BridgeSource.BuiltIn + // NOOP: all settings will be set in call to set userProvidedBridges and submited + // at the same time to clear TorSettings.sys.mjs #cleanupSettings + return } else { + it.bridgesSource = BridgeSource.BuiltIn val bbt: BridgeBuiltinType = when (value) { TorBridgeTransportConfig.BUILTIN_OBFS4 -> BridgeBuiltinType.Obfs4 TorBridgeTransportConfig.BUILTIN_MEEK_AZURE -> BridgeBuiltinType.MeekAzure @@ -135,12 +145,16 @@ class TorControllerGV( }
+ // Currently the UI takes a user provided string and sets this in one step so there is where we + // actually set it.bridgesSource = BridgeSource.UserProvided, not above, as TorSettings.sys.mjs #cleanupSettings + // could reject BridgeSource.UserProvided with no bridge strings override var userProvidedBridges: String? get() { return getTorSettings()?.bridgeBridgeStrings?.joinToString("\r\n") } set(value) { getTorSettings()?.let { + it.bridgesSource = BridgeSource.UserProvided it.bridgeBridgeStrings = value?.split("\r\n")?.toTypedArray() ?: arrayOf<String>() getTorIntegration().setSettings(it, true, true) }
View it on GitLab: https://gitlab.torproject.org/tpo/applications/firefox-android/-/commit/8cc0...
tbb-commits@lists.torproject.org