lists.torproject.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

tbb-commits

Thread Start a new thread
Download
Threads by month
  • ----- 2025 -----
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2021 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2020 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2019 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2018 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2017 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2016 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2015 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2014 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
tbb-commits@lists.torproject.org

December 2023

  • 1 participants
  • 125 discussions
[Git][tpo/applications/tor-browser][tor-browser-115.6.0esr-13.5-1] Add built-in bridge lines for Android.
by Pier Angelo Vendrame (@pierov) 21 Dec '23

21 Dec '23
Pier Angelo Vendrame pushed to branch tor-browser-115.6.0esr-13.5-1 at The Tor Project / Applications / Tor Browser Commits: 8d3d178e by Pier Angelo Vendrame at 2023-12-21T23:23:57+01:00 Add built-in bridge lines for Android. Temporary workaround for 13.5a3. We chould revert once tor-browser!877 is merged. - - - - - 1 changed file: - mobile/android/app/000-tor-browser-android.js Changes: ===================================== mobile/android/app/000-tor-browser-android.js ===================================== @@ -35,3 +35,68 @@ pref("security.webauth.webauthn_enable_android_fido2", false); // Disable the External App Blocker on Android pref("extensions.torbutton.launch_warning", false); + +// Temporarily add the built-in bridges here. + +pref("extensions.torlauncher.default_bridge_recommended_type", "obfs4"); + +// Default bridges. +pref( + "extensions.torlauncher.default_bridge.obfs4.1", + "obfs4 192.95.36.142:443 CDF2E852BF539B82BD10E27E9115A31734E378C2 cert=qUVQ0srL1JI/vO6V6m/24anYXiJD3QP2HgzUKQtQ7GRqqUvs7P+tG43RtAqdhLOALP7DJQ iat-mode=1" +); +pref( + "extensions.torlauncher.default_bridge.obfs4.2", + "obfs4 37.218.245.14:38224 D9A82D2F9C2F65A18407B1D2B764F130847F8B5D cert=bjRaMrr1BRiAW8IE9U5z27fQaYgOhX1UCmOpg2pFpoMvo6ZgQMzLsaTzzQNTlm7hNcb+Sg iat-mode=0" +); +pref( + "extensions.torlauncher.default_bridge.obfs4.3", + "obfs4 85.31.186.98:443 011F2599C0E9B27EE74B353155E244813763C3E5 cert=ayq0XzCwhpdysn5o0EyDUbmSOx3X/oTEbzDMvczHOdBJKlvIdHHLJGkZARtT4dcBFArPPg iat-mode=0" +); +pref( + "extensions.torlauncher.default_bridge.obfs4.4", + "obfs4 85.31.186.26:443 91A6354697E6B02A386312F68D82CF86824D3606 cert=PBwr+S8JTVZo6MPdHnkTwXJPILWADLqfMGoVvhZClMq/Urndyd42BwX9YFJHZnBB3H0XCw iat-mode=0" +); +pref( + "extensions.torlauncher.default_bridge.obfs4.5", + "obfs4 193.11.166.194:27015 2D82C2E354D531A68469ADF7F878FA6060C6BACA cert=4TLQPJrTSaDffMK7Nbao6LC7G9OW/NHkUwIdjLSS3KYf0Nv4/nQiiI8dY2TcsQx01NniOg iat-mode=0" +); +pref( + "extensions.torlauncher.default_bridge.obfs4.6", + "obfs4 193.11.166.194:27020 86AC7B8D430DAC4117E9F42C9EAED18133863AAF cert=0LDeJH4JzMDtkJJrFphJCiPqKx7loozKN7VNfuukMGfHO0Z8OGdzHVkhVAOfo1mUdv9cMg iat-mode=0" +); +pref( + "extensions.torlauncher.default_bridge.obfs4.7", + "obfs4 193.11.166.194:27025 1AE2C08904527FEA90C4C4F8C1083EA59FBC6FAF cert=ItvYZzW5tn6v3G4UnQa6Qz04Npro6e81AP70YujmK/KXwDFPTs3aHXcHp4n8Vt6w/bv8cA iat-mode=0" +); +pref( + "extensions.torlauncher.default_bridge.obfs4.8", + "obfs4 209.148.46.65:443 74FAD13168806246602538555B5521A0383A1875 cert=ssH+9rP8dG2NLDN2XuFw63hIO/9MNNinLmxQDpVa+7kTOa9/m+tGWT1SmSYpQ9uTBGa6Hw iat-mode=0" +); +pref( + "extensions.torlauncher.default_bridge.obfs4.9", + "obfs4 146.57.248.225:22 10A6CD36A537FCE513A322361547444B393989F0 cert=K1gDtDAIcUfeLqbstggjIw2rtgIKqdIhUlHp82XRqNSq/mtAjp1BIC9vHKJ2FAEpGssTPw iat-mode=0" +); +pref( + "extensions.torlauncher.default_bridge.obfs4.10", + "obfs4 45.145.95.6:27015 C5B7CD6946FF10C5B3E89691A7D3F2C122D2117C cert=TD7PbUO0/0k6xYHMPW3vJxICfkMZNdkRrb63Zhl5j9dW3iRGiCx0A7mPhe5T2EDzQ35+Zw iat-mode=0" +); +pref( + "extensions.torlauncher.default_bridge.obfs4.11", + "obfs4 51.222.13.177:80 5EDAC3B810E12B01F6FD8050D2FD3E277B289A08 cert=2uplIpLQ0q9+0qMFrK5pkaYRDOe460LL9WHBvatgkuRr/SL31wBOEupaMMJ6koRE6Ld0ew iat-mode=0" +); + +pref( + "extensions.torlauncher.default_bridge.meek-azure.1", + "meek_lite 192.0.2.18:80 BE776A53492E1E044A26F17306E1BC46A55A1625 url=https://meek.azureedge.net/ front=ajax.aspnetcdn.com" +); + +pref( + "extensions.torlauncher.default_bridge.snowflake.1", + "snowflake 192.0.2.3:80 2B280B23E1107BB62ABFC40DDCC8824814F80A72 fingerprint=2B280B23E1107BB62ABFC40DDCC8824814F80A72 url=https://snowflake-broker.torproject.net.global.prod.fastly.net/ front=cdn.sstatic.net ice=stun:stun.l.google.com:19302,stun:stun.antisip.com:3478,stun:stun.bluesip.net:3478,stun:stun.dus.net:3478,stun:stun.epygi.com:3478,stun:stun.sonetel.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.voys.nl:3478 utls-imitate=hellorandomizedalpn" +); + +pref( + "extensions.torlauncher.default_bridge.snowflake.2", + "snowflake 192.0.2.4:80 8838024498816A039FCBBAB14E6F40A0843051FA fingerprint=8838024498816A039FCBBAB14E6F40A0843051FA url=https://snowflake-broker.torproject.net.global.prod.fastly.net/ front=cdn.sstatic.net ice=stun:stun.l.google.com:19302,stun:stun.antisip.com:3478,stun:stun.bluesip.net:3478,stun:stun.dus.net:3478,stun:stun.epygi.com:3478,stun:stun.sonetel.net:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.voys.nl:3478 utls-imitate=hellorandomizedalpn" +); View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/8d3d178… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/8d3d178… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/firefox-android][firefox-android-115.2.1-13.5-1] Enable the connect assist experiments on alpha
by Pier Angelo Vendrame (@pierov) 21 Dec '23

21 Dec '23
Pier Angelo Vendrame pushed to branch firefox-android-115.2.1-13.5-1 at The Tor Project / Applications / firefox-android Commits: 48593938 by clairehurst at 2023-12-21T14:48:46-07:00 Enable the connect assist experiments on alpha - - - - - 13 changed files: - android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt - android-components/components/concept/engine/src/main/java/mozilla/components/concept/engine/Settings.kt - fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt - fenix/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt - fenix/app/src/main/java/org/mozilla/fenix/components/Core.kt - fenix/app/src/main/java/org/mozilla/fenix/settings/TorNetworkSettingsFragment.kt - + fenix/app/src/main/java/org/mozilla/fenix/tor/TorBetaConnectionFeaturesFragment.kt - fenix/app/src/main/java/org/mozilla/fenix/tor/TorBootstrapFragment.kt - fenix/app/src/main/java/org/mozilla/fenix/utils/Settings.kt - + fenix/app/src/main/res/layout/tor_network_settings_beta_connection_features.xml - fenix/app/src/main/res/navigation/nav_graph.xml - fenix/app/src/main/res/values/preference_keys.xml - fenix/app/src/main/res/xml/tor_network_settings_preferences.xml Changes: ===================================== android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt ===================================== @@ -799,6 +799,11 @@ class GeckoEngine( override var prioritizeOnions: Boolean get() = runtime.settings.prioritizeOnions set(value) { runtime.settings.prioritizeOnions = value } + override var useNewBootstrap: Boolean + get() = runtime.settings.useNewBootstrap + set(value) { + runtime.settings.useNewBootstrap = value + } }.apply { defaultSettings?.let { this.javascriptEnabled = it.javascriptEnabled @@ -824,6 +829,7 @@ class GeckoEngine( this.torSecurityLevel = it.torSecurityLevel this.spoofEnglish = it.spoofEnglish this.prioritizeOnions = it.prioritizeOnions + this.useNewBootstrap = it.useNewBootstrap } } @@ -929,6 +935,8 @@ class GeckoEngine( unBlockedBySmartBlock = this.blockingData.any { it.unBlockedBySmartBlock() }, ) } + + fun getTorIntegrationController() = runtime.getTorIntegrationController() } internal fun ContentBlockingController.LogEntry.BlockingData.hasBlockedCookies(): Boolean { ===================================== android-components/components/concept/engine/src/main/java/mozilla/components/concept/engine/Settings.kt ===================================== @@ -214,6 +214,8 @@ abstract class Settings { open var spoofEnglish: Boolean by UnsupportedSetting() open var prioritizeOnions: Boolean by UnsupportedSetting() + + open var useNewBootstrap: Boolean by UnsupportedSetting() } /** @@ -259,6 +261,7 @@ data class DefaultSettings( override var torSecurityLevel: Int = 4, override var spoofEnglish: Boolean = false, override var prioritizeOnions: Boolean = false, + override var useNewBootstrap: Boolean = false, ) : Settings() class UnsupportedSetting<T> { ===================================== fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt ===================================== @@ -164,6 +164,11 @@ import org.mozilla.fenix.utils.Settings import java.lang.ref.WeakReference import java.util.Locale +import androidx.navigation.fragment.findNavController +import mozilla.components.browser.engine.gecko.GeckoEngine +import mozilla.components.browser.state.selector.findCustomTab +import org.mozilla.geckoview.TorIntegrationAndroid + /** * The main activity of the application. The application is primarily a single Activity (this one) * with fragments switching out to display different views. The most important views shown here are the: @@ -171,7 +176,7 @@ import java.util.Locale * - browser screen */ @SuppressWarnings("TooManyFunctions", "LargeClass", "LongParameterList", "LongMethod") -open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { +open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity, TorIntegrationAndroid.BootstrapStateChangeListener { // DO NOT MOVE ANYTHING ABOVE THIS, GETTING INIT TIME IS CRITICAL // we need to store startup timestamp for warm startup. we cant directly store // inside AppStartupTelemetry since that class lives inside components and @@ -201,7 +206,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { private var inflater: LayoutInflater? = null - private val navHost by lazy { + val navHost by lazy { supportFragmentManager.findFragmentById(R.id.container) as NavHostFragment } @@ -396,6 +401,12 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { components.notificationsDelegate.bindToActivity(this) + val engine = components.core.engine + if (engine is GeckoEngine) { + val torIntegration = engine.getTorIntegrationController() + torIntegration.registerBootstrapStateChangeListener(this) + } + StartupTimeline.onActivityCreateEndHome(this) // DO NOT MOVE ANYTHING BELOW HERE. } @@ -609,6 +620,12 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { // underlying Application, as well. (application as FenixApplication).terminate() } + + val engine = components.core.engine + if (engine is GeckoEngine) { + val torIntegration = engine.getTorIntegrationController() + torIntegration.unregisterBootstrapStateChangeListener(this) + } } override fun onConfigurationChanged(newConfig: Configuration) { @@ -1163,7 +1180,20 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { } open fun navigateToHome() { - navHost.navController.navigate(NavGraphDirections.actionStartupTorbootstrap()) + if (settings().useNewBootstrap) { + if (settings().useNewBootstrapNativeUi) { + navHost.navController.navigate(NavGraphDirections.actionStartupTorConnectionAssist()) + } else { + navHost.navController.navigate(NavGraphDirections.actionStartupHome()) + openToBrowserAndLoad( + searchTermOrURL = "about:torconnect", + newTab = true, + from = BrowserDirection.FromHome, + ) + } + } else { + navHost.navController.navigate(NavGraphDirections.actionStartupTorbootstrap()) + } } override fun attachBaseContext(base: Context) { @@ -1341,4 +1371,15 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { // telemetry purposes. const val PWA_RECENTLY_USED_THRESHOLD = DateUtils.DAY_IN_MILLIS * 30L } + + override fun onBootstrapStateChange(state: String) = Unit + override fun onBootstrapProgress(progress: Double, status: String, hasWarnings: Boolean) = Unit + override fun onBootstrapComplete() { + components.useCases.tabsUseCases.removeAllTabs() + navHost.navController.navigate(NavGraphDirections.actionStartupHome()) + } + override fun onBootstrapError(message: String, details: String) = Unit + override fun onSettingsRequested() { + navHost.navController.navigate(NavGraphDirections.actionGlobalSettingsFragment()) + } } ===================================== fenix/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt ===================================== @@ -1189,6 +1189,9 @@ abstract class BaseBrowserFragment : val context = requireContext() resumeDownloadDialogState(selectedTab.id, context.components.core.store, context, toolbarHeight) it.announceForAccessibility(selectedTab.toDisplayTitle()) + if (getCurrentTab()?.content?.url == "about:torconnect") { + browserToolbarView.view.visibility = View.GONE + } } } else { view?.let { view -> initializeUI(view) } @@ -1206,6 +1209,24 @@ abstract class BaseBrowserFragment : components.useCases.sessionUseCases.reload() } hideToolbar() + handleBetaHtmlTorConnect() + } + + private fun handleBetaHtmlTorConnect() { + if (getCurrentTab()?.content?.url == "about:torconnect") { + if (!requireActivity().settings().useNewBootstrap) { + requireContext().components.useCases.tabsUseCases.removeAllTabs() + (requireActivity() as HomeActivity).navHost.navController.navigate( + NavGraphDirections.actionStartupTorbootstrap(), + ) + } else if (!requireActivity().settings().useNewBootstrapHtmlUi) { + requireContext().components.useCases.tabsUseCases.removeAllTabs() + (requireActivity() as HomeActivity).navigateToHome() + } else { + // This just makes it not flash (be visible for a split second) before handleTabSelected() hides it again + browserToolbarView.view.visibility = View.GONE + } + } } @CallSuper ===================================== fenix/app/src/main/java/org/mozilla/fenix/components/Core.kt ===================================== @@ -146,6 +146,7 @@ class Core( torSecurityLevel = context.settings().torSecurityLevel().intRepresentation, spoofEnglish = context.settings().spoofEnglish, prioritizeOnions = context.settings().prioritizeOnions, + useNewBootstrap = context.settings().useNewBootstrap, ) GeckoEngine( ===================================== fenix/app/src/main/java/org/mozilla/fenix/settings/TorNetworkSettingsFragment.kt ===================================== @@ -76,6 +76,15 @@ class TorNetworkSettingsFragment : PreferenceFragmentCompat(), TorEvents { } } + requirePreference<Preference>(R.string.pref_key_use_new_bootstrap).apply { + setOnPreferenceClickListener { + val directions = + TorNetworkSettingsFragmentDirections.actionTorNetworkSettingsFragmentToBetaConnectionFeaturesFragment() + requireView().findNavController().navigate(directions) + true + } + } + setStatus() } ===================================== fenix/app/src/main/java/org/mozilla/fenix/tor/TorBetaConnectionFeaturesFragment.kt ===================================== @@ -0,0 +1,69 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix.tor + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.core.view.children +import androidx.fragment.app.Fragment +import org.mozilla.fenix.databinding.TorNetworkSettingsBetaConnectionFeaturesBinding +import org.mozilla.fenix.ext.components +import org.mozilla.fenix.ext.settings + +/** + * Lets the user customize beta connection features mode. + */ +class TorBetaConnectionFeaturesFragment : Fragment() { + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle?, + ): View { + val binding = TorNetworkSettingsBetaConnectionFeaturesBinding.inflate(inflater) + + binding.enableBetaConnectionFeaturesSwitch.run { + isChecked = context.settings().useNewBootstrap + setConnectionAssistUI(binding, isChecked) + + setOnCheckedChangeListener { _, isConnectionAssistEnabled -> + context.settings().useNewBootstrap = isConnectionAssistEnabled + setConnectionAssistUI(binding, isConnectionAssistEnabled) + updateEngineConnectionAssistMode() + } + } + + // Since the beta connection features modes are in a RadioGroup we only need one listener to know of all their changes. + binding.useNewBootstrapWithNativeUiRadioButton.setOnCheckedChangeListener { _, _ -> + updateEngineConnectionAssistMode() + } + + return binding.root + } + + private fun setConnectionAssistUI( + binding: TorNetworkSettingsBetaConnectionFeaturesBinding, + isBetaConnectionAssistEnabled: Boolean, + ) { + if (!isBetaConnectionAssistEnabled) { + binding.enableBetaConnectionFeaturesModes.apply { + clearCheck() + children.forEach { it.isEnabled = false } + } + } else { + // Do not enable the native UI until it is actually available. + // binding.enableBetaConnectionFeaturesModes.children.forEach { it.isEnabled = true } + binding.useNewBootstrapWithHtmlUiRadioButton.isEnabled = true + binding.useNewBootstrapWithNativeUiRadioButton.isEnabled = false + } + } + + private fun updateEngineConnectionAssistMode() { + requireContext().components.core.engine.settings.useNewBootstrap = + requireContext().settings().useNewBootstrap + } + +} ===================================== fenix/app/src/main/java/org/mozilla/fenix/tor/TorBootstrapFragment.kt ===================================== @@ -20,8 +20,10 @@ import org.mozilla.fenix.tor.interactor.DefaultTorBootstrapInteractor import org.mozilla.fenix.tor.interactor.TorBootstrapInteractor import androidx.navigation.fragment.findNavController import com.google.android.material.appbar.AppBarLayout +import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.hideToolbar +import org.mozilla.fenix.ext.settings import org.mozilla.fenix.tor.controller.DefaultTorBootstrapController import org.mozilla.fenix.tor.view.TorBootstrapView @@ -169,6 +171,9 @@ class TorBootstrapFragment : Fragment() { // triggered to cause an automatic update on warm start (no tab selection occurs). So we // update it manually here. requireComponents.useCases.sessionUseCases.updateLastAccess() + if (requireContext().settings().useNewBootstrap){ + (requireActivity() as HomeActivity).navigateToHome() + } } private fun handleTorBootstrapConnect() { ===================================== fenix/app/src/main/java/org/mozilla/fenix/utils/Settings.kt ===================================== @@ -1859,4 +1859,19 @@ class Settings(private val appContext: Context) : PreferencesHolder { * Indicates if the new Search settings UI is enabled. */ var enableUnifiedSearchSettingsUI: Boolean = showUnifiedSearchFeature && FeatureFlags.unifiedSearchSettings + + var useNewBootstrap by booleanPreference( + appContext.getPreferenceKey(R.string.pref_key_use_new_bootstrap), + default = false, + ) + + var useNewBootstrapNativeUi by booleanPreference( + appContext.getPreferenceKey(R.string.pref_key_use_new_bootstrap_with_android_native), + default = false, + ) + + var useNewBootstrapHtmlUi by booleanPreference( + appContext.getPreferenceKey(R.string.pref_key_use_new_bootstrap_with_html), + default = true + ) } ===================================== fenix/app/src/main/res/layout/tor_network_settings_beta_connection_features.xml ===================================== @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="utf-8"?><!-- This Source Code Form is subject to the terms of the Mozilla Public + - License, v. 2.0. If a copy of the MPL was not distributed with this + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <TextView + android:id="@+id/enable_beta_connection_features_title" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginTop="16dp" + android:layout_marginBottom="2dp" + android:clickable="false" + android:text="Enable beta connection features" + android:textAppearance="@style/ListItemTextStyle" + android:textSize="16sp" + app:layout_constraintBottom_toTopOf="@id/enable_beta_connection_features_summary" + app:layout_constraintEnd_toStartOf="@id/enable_beta_connection_features_switch" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:lineHeight="24.sp" /> + + <TextView + android:id="@+id/enable_beta_connection_features_summary" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:text="Help us test our new connection assist features which focuses on a streamlined connection with better integration with bridges" + android:textColor="?attr/textSecondary" + android:textColorLink="?attr/textSecondary" + android:textSize="12sp" + app:layout_constraintBottom_toTopOf="@id/enable_beta_connection_features_modes" + app:layout_constraintEnd_toEndOf="@id/enable_beta_connection_features_title" + app:layout_constraintStart_toStartOf="@id/enable_beta_connection_features_title" + app:layout_constraintTop_toBottomOf="@id/enable_beta_connection_features_title" + app:lineHeight="16.sp" /> + + <androidx.appcompat.widget.SwitchCompat + android:id="@+id/enable_beta_connection_features_switch" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:minHeight="48dp" + android:paddingStart="18dp" + android:paddingEnd="18dp" + android:textColor="@color/state_list_text_color" + android:textOff="@string/studies_off" + android:textOn="@string/studies_on" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="@id/enable_beta_connection_features_title" /> + + <RadioGroup + android:id="@+id/enable_beta_connection_features_modes" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/enable_beta_connection_features_summary"> + + <org.mozilla.fenix.settings.PreferenceBackedRadioButton + android:id="@+id/use_new_bootstrap_with_html_ui_radio_button" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="?android:attr/selectableItemBackground" + android:button="@null" + android:drawablePadding="@dimen/radio_button_preference_drawable_padding" + android:paddingStart="@dimen/radio_button_preference_horizontal" + android:paddingTop="@dimen/radio_button_preference_vertical" + android:paddingEnd="@dimen/radio_button_preference_horizontal" + android:paddingBottom="@dimen/radio_button_preference_vertical" + android:text="HTML UI" + android:textAppearance="?android:attr/textAppearanceListItem" + android:textSize="16sp" + app:drawableStartCompat="?android:attr/listChoiceIndicatorSingle" + app:preferenceKey="@string/pref_key_use_new_bootstrap_with_html" + app:preferenceKeyDefaultValue="true" /> + + <org.mozilla.fenix.settings.PreferenceBackedRadioButton + android:id="@+id/use_new_bootstrap_with_native_ui_radio_button" + android:layout_width="match_parent" + android:layout_height="48dp" + android:background="?android:attr/selectableItemBackground" + android:button="@null" + android:drawablePadding="@dimen/radio_button_preference_drawable_padding" + android:enabled="false" + android:paddingStart="@dimen/radio_button_preference_horizontal" + android:paddingTop="@dimen/radio_button_preference_vertical" + android:paddingEnd="@dimen/radio_button_preference_horizontal" + android:paddingBottom="@dimen/radio_button_preference_vertical" + android:text="Native Android UI" + android:textAppearance="?android:attr/textAppearanceListItem" + android:textSize="16sp" + app:drawableStartCompat="?android:attr/listChoiceIndicatorSingle" + app:preferenceKey="@string/pref_key_use_new_bootstrap_with_android_native" + app:preferenceKeyDefaultValue="false" /> + </RadioGroup> + +</androidx.constraintlayout.widget.ConstraintLayout> ===================================== fenix/app/src/main/res/navigation/nav_graph.xml ===================================== @@ -27,6 +27,12 @@ app:popUpTo="@id/startupFragment" app:popUpToInclusive="true" /> + <action + android:id="@+id/action_startup_tor_connection_assist" + app:destination="@+id/torConnectionAssistFragment" + app:popUpTo="@id/startupFragment" + app:popUpToInclusive="true" /> + <action android:id="@+id/action_global_home" app:destination="@id/homeFragment" @@ -941,12 +947,25 @@ app:exitAnim="@anim/slide_out_left" app:popEnterAnim="@anim/slide_in_left" app:popExitAnim="@anim/slide_out_right" /> + <action + android:id="@+id/action_torNetworkSettingsFragment_to_BetaConnectionFeaturesFragment" + app:destination="@+id/torBetaConnectionFeaturesFragment" + app:enterAnim="@anim/slide_in_right" + app:exitAnim="@anim/slide_out_left" + app:popEnterAnim="@anim/slide_in_left" + app:popExitAnim="@anim/slide_out_right" /> </fragment> <fragment android:id="@+id/torBridgeConfigFragment" android:name="org.mozilla.fenix.settings.TorBridgeConfigFragment" android:label="@string/preferences_tor_network_settings_bridge_config" tools:layout="@layout/fragment_tor_bridge_config" /> + <fragment + android:id="@+id/torBetaConnectionFeaturesFragment" + android:name="org.mozilla.fenix.tor.TorBetaConnectionFeaturesFragment" + android:label="Enable beta connection features" + tools:layout="@layout/tor_network_settings_beta_connection_features" /> + <fragment android:id="@+id/trackingProtectionFragment" android:name="org.mozilla.fenix.settings.TrackingProtectionFragment"> ===================================== fenix/app/src/main/res/values/preference_keys.xml ===================================== @@ -376,6 +376,9 @@ <string name="pref_key_tor_network_settings" translatable="false">pref_key_tor_network_settings</string> <string name="pref_key_tor_network_settings_explanation" translatable="false">pref_key_tor_network_settings_explanation</string> <string name="pref_key_tor_network_settings_bridge_config" translatable="false">pref_key_tor_network_settings_bridge_config</string> + <string name="pref_key_use_new_bootstrap" translatable="false">pref_key_use_new_bootstrap</string> + <string name="pref_key_use_new_bootstrap_with_android_native" translatable="false">pref_key_use_new_bootstrap_with_android_native</string> + <string name="pref_key_use_new_bootstrap_with_html" translatable="false">pref_key_use_new_bootstrap_with_html</string> <string name="pref_key_tor_network_settings_bridge_config_explanation" translatable="false">pref_key_tor_network_settings_bridge_config_explanation</string> <string name="pref_key_tor_network_settings_bridge_config_toggle" translatable="false">pref_key_tor_network_settings_bridge_config_toggle</string> <string name="pref_key_tor_network_settings_bridge_config_builtin_bridge_obfs4" translatable="false">pref_key_tor_network_settings_bridge_config_builtin_bridge_obfs4</string> ===================================== fenix/app/src/main/res/xml/tor_network_settings_preferences.xml ===================================== @@ -27,4 +27,9 @@ android:title="@string/preferences_tor_network_settings_bridge_config" android:summary="@string/preferences_tor_network_settings_bridge_config_description" app:allowDividerAbove="true" /> + <Preference + android:key="@string/pref_key_use_new_bootstrap" + android:title="Enable beta connection features" + app:allowDividerAbove="true" /> + </androidx.preference.PreferenceScreen> View it on GitLab: https://gitlab.torproject.org/tpo/applications/firefox-android/-/commit/485… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/firefox-android/-/commit/485… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser][tor-browser-115.6.0esr-13.5-1] fixup! Bug 42247: Android helpers for the TorProvider
by Pier Angelo Vendrame (@pierov) 21 Dec '23

21 Dec '23
Pier Angelo Vendrame pushed to branch tor-browser-115.6.0esr-13.5-1 at The Tor Project / Applications / Tor Browser Commits: f422c485 by Dan Ballard at 2023-12-21T11:51:26-08:00 fixup! Bug 42247: Android helpers for the TorProvider Fix settings loading issues and saving - - - - - 2 changed files: - mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorIntegrationAndroid.java - toolkit/modules/TorAndroidIntegration.sys.mjs Changes: ===================================== mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorIntegrationAndroid.java ===================================== @@ -7,6 +7,7 @@ package org.mozilla.geckoview; import android.content.Context; +import android.os.AsyncTask; import android.util.Log; import androidx.annotation.AnyThread; @@ -131,7 +132,11 @@ public class TorIntegrationAndroid implements BundleEventListener { } else if (EVENT_MEEK_STOP.equals(event)) { stopMeek(message, callback); } else if (EVENT_SETTINGS_READY.equals(event)) { - loadSettings(message); + try { + new SettingsLoader().execute(message); + } catch(Exception e) { + Log.e(TAG, "SettingsLoader error: "+ e.toString()); + } } else if (EVENT_BOOTSTRAP_STATE_CHANGED.equals(event)) { String state = message.getString("state"); for (BootstrapStateChangeListener listener: mBootstrapStateListeners) { @@ -161,14 +166,24 @@ public class TorIntegrationAndroid implements BundleEventListener { } } - private void loadSettings(GeckoBundle message) { - if (TorLegacyAndroidSettings.unmigrated()) { - mSettings = TorLegacyAndroidSettings.loadTorSettings(); - setSettings(mSettings); - TorLegacyAndroidSettings.setMigrated(); - } else { - GeckoBundle bundle = message.getBundle("settings"); - mSettings = new TorSettings(bundle); + private class SettingsLoader extends AsyncTask<GeckoBundle, Void, TorSettings> { + protected TorSettings doInBackground(GeckoBundle... messages) { + GeckoBundle message = messages[0]; + TorSettings settings; + if (TorLegacyAndroidSettings.unmigrated()) { + settings = TorLegacyAndroidSettings.loadTorSettings(); + setSettings(settings, true, true); + TorLegacyAndroidSettings.setMigrated(); + } else { + GeckoBundle bundle = message.getBundle("settings"); + settings = new TorSettings(bundle); + } + return settings; + } + + @Override + protected void onPostExecute(TorSettings torSettings) { + mSettings = torSettings; } } @@ -515,8 +530,12 @@ public class TorIntegrationAndroid implements BundleEventListener { return EventDispatcher.getInstance().queryBundle(EVENT_SETTINGS_GET); } - public @NonNull GeckoResult<Void> setSettings(final TorSettings settings) { - return EventDispatcher.getInstance().queryVoid(EVENT_SETTINGS_SET, settings.asGeckoBundle()); + public @NonNull GeckoResult<Void> setSettings(final TorSettings settings, boolean save, boolean apply) { + GeckoBundle bundle = new GeckoBundle(3); + bundle.putBoolean("save", save); + bundle.putBoolean("apply", apply); + bundle.putBundle("settings", settings.asGeckoBundle()); + return EventDispatcher.getInstance().queryVoid(EVENT_SETTINGS_SET, bundle); } public @NonNull GeckoResult<Void> applySettings() { ===================================== toolkit/modules/TorAndroidIntegration.sys.mjs ===================================== @@ -136,13 +136,19 @@ class TorAndroidIntegrationImpl { return; case ListenedEvents.settingsSet: // This does not throw, so we do not have any way to report the error! - lazy.TorSettings.setSettings(data); + lazy.TorSettings.setSettings(data.settings); + if (data.save) { + lazy.TorSettings.saveToPrefs(); + } + if (data.apply) { + lazy.TorSettings.applySettings(); + } break; case ListenedEvents.settingsApply: await lazy.TorSettings.applySettings(); break; case ListenedEvents.settingsSave: - await lazy.TorSettings.saveSettings(); + await lazy.TorSettings.saveToPrefs(); break; case ListenedEvents.bootstrapBegin: lazy.TorConnect.beginBootstrap(); View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/f422c48… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/f422c48… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser-build][main] Bug 41057: Also fetch mullvad-browser.git in `make fetch`
by boklm (@boklm) 21 Dec '23

21 Dec '23
boklm pushed to branch main at The Tor Project / Applications / tor-browser-build Commits: 264191d6 by Nicolas Vigier at 2023-12-21T13:09:58+01:00 Bug 41057: Also fetch mullvad-browser.git in `make fetch` - - - - - 1 changed file: - Makefile Changes: ===================================== Makefile ===================================== @@ -709,6 +709,7 @@ mullvadbrowser-kick-devmole-build: submodule-update fetch: submodule-update $(rbm) fetch + $(rbm) fetch firefox --target mullvadbrowser clean: submodule-update ./tools/clean-old View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/2… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/2… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/firefox-android][firefox-android-115.2.1-13.5-1] fixup! Add Tor integration and UI
by Pier Angelo Vendrame (@pierov) 21 Dec '23

21 Dec '23
Pier Angelo Vendrame pushed to branch firefox-android-115.2.1-13.5-1 at The Tor Project / Applications / firefox-android Commits: a61486e2 by Pier Angelo Vendrame at 2023-12-21T17:15:26+00:00 fixup! Add Tor integration and UI Bug 42324: Onion location does not work after a browser restart - - - - - 2 changed files: - android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt - fenix/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt Changes: ===================================== android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt ===================================== @@ -798,11 +798,7 @@ class GeckoEngine( } override var prioritizeOnions: Boolean get() = runtime.settings.prioritizeOnions - set(value) { - value.let { - runtime.settings.prioritizeOnions = it - } - } + set(value) { runtime.settings.prioritizeOnions = value } }.apply { defaultSettings?.let { this.javascriptEnabled = it.javascriptEnabled ===================================== fenix/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt ===================================== @@ -485,7 +485,9 @@ class SettingsFragment : PreferenceFragmentCompat() { } preferencePrioritizeOnions?.setOnPreferenceChangeListener<Boolean> { preference, newValue -> - preference.context.components.core.engine.settings.prioritizeOnions = newValue + preference.context.settings().preferences.edit() + .putBoolean(preference.key, newValue).apply() + requireComponents.core.engine.settings.prioritizeOnions = newValue true } View it on GitLab: https://gitlab.torproject.org/tpo/applications/firefox-android/-/commit/a61… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/firefox-android/-/commit/a61… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser-update-responses][main] release: new version, 13.0.8
by richard (@richard) 21 Dec '23

21 Dec '23
richard pushed to branch main at The Tor Project / Applications / Tor Browser update responses Commits: 94d633a9 by Richard Pospesel at 2023-12-21T13:34:35+00:00 release: new version, 13.0.8 - - - - - 30 changed files: - update_3/release/.htaccess - − update_3/release/13.0.1-13.0.7-linux-i686-ALL.xml - − update_3/release/13.0.1-13.0.7-linux-x86_64-ALL.xml - − update_3/release/13.0.1-13.0.7-macos-ALL.xml - − update_3/release/13.0.1-13.0.7-windows-i686-ALL.xml - − update_3/release/13.0.1-13.0.7-windows-x86_64-ALL.xml - − update_3/release/13.0.5-13.0.7-linux-i686-ALL.xml - − update_3/release/13.0.5-13.0.7-linux-x86_64-ALL.xml - − update_3/release/13.0.5-13.0.7-macos-ALL.xml - − update_3/release/13.0.5-13.0.7-windows-i686-ALL.xml - − update_3/release/13.0.5-13.0.7-windows-x86_64-ALL.xml - + update_3/release/13.0.5-13.0.8-linux-i686-ALL.xml - + update_3/release/13.0.5-13.0.8-linux-x86_64-ALL.xml - + update_3/release/13.0.5-13.0.8-macos-ALL.xml - + update_3/release/13.0.5-13.0.8-windows-i686-ALL.xml - + update_3/release/13.0.5-13.0.8-windows-x86_64-ALL.xml - − update_3/release/13.0.6-13.0.7-linux-i686-ALL.xml - − update_3/release/13.0.6-13.0.7-linux-x86_64-ALL.xml - − update_3/release/13.0.6-13.0.7-macos-ALL.xml - − update_3/release/13.0.6-13.0.7-windows-i686-ALL.xml - − update_3/release/13.0.6-13.0.7-windows-x86_64-ALL.xml - + update_3/release/13.0.6-13.0.8-linux-i686-ALL.xml - + update_3/release/13.0.6-13.0.8-linux-x86_64-ALL.xml - + update_3/release/13.0.6-13.0.8-macos-ALL.xml - + update_3/release/13.0.6-13.0.8-windows-i686-ALL.xml - + update_3/release/13.0.6-13.0.8-windows-x86_64-ALL.xml - + update_3/release/13.0.7-13.0.8-linux-i686-ALL.xml - + update_3/release/13.0.7-13.0.8-linux-x86_64-ALL.xml - + update_3/release/13.0.7-13.0.8-macos-ALL.xml - + update_3/release/13.0.7-13.0.8-windows-i686-ALL.xml The diff was not included because it is too large. View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-update-responses… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-update-responses… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser-build][maint-13.0] 2 commits: Bug 41056: Make it possible to use templates in var/torbrowser_incremental_from
by boklm (@boklm) 21 Dec '23

21 Dec '23
boklm pushed to branch maint-13.0 at The Tor Project / Applications / tor-browser-build Commits: f086ab55 by Nicolas Vigier at 2023-12-21T08:36:41+01:00 Bug 41056: Make it possible to use templates in var/torbrowser_incremental_from - - - - - 6733294b by Nicolas Vigier at 2023-12-21T08:40:11+01:00 Bug 41056: Use single var/torbrowser_incremental_from list - - - - - 2 changed files: - projects/release/update_responses_config.yml - rbm.conf Changes: ===================================== projects/release/update_responses_config.yml ===================================== @@ -43,9 +43,12 @@ versions: [% END -%] incremental_from: [% SET incr_from = c("var/nightly") ? c("var_p/nightly_torbrowser_incremental_from") : c("var/torbrowser_incremental_from"); - FOREACH v IN incr_from -%] - - [% v %] -[% END -%] + FOREACH v IN incr_from; + SET ver = tmpl(v); + IF ver -%] + - [% ver %] +[% END; + END -%] # for example, osx32: osx64 migrate_archs: # for example, pt-PT: pt-BR ===================================== rbm.conf ===================================== @@ -86,7 +86,7 @@ var: torbrowser_incremental_from: - '13.0.7' - '13.0.6' - - '13.0.5' + - '13.0.[% IF c("var/tor-browser") %]5[% ELSE %]4[% END %]' updater_enabled: 1 build_mar: 1 mar_channel_id: '[% c("var/projectname") %]-torproject-[% c("var/channel") %]' @@ -304,10 +304,6 @@ targets: - tr - zh-CN - zh-TW - torbrowser_incremental_from: - - '13.0.6' - - '13.0.4' - - '13.0.1' torbrowser-testbuild: - testbuild View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/compare/… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/compare/… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser-build][main] Bug 41056: Make it possible to use templates in var/torbrowser_incremental_from
by boklm (@boklm) 21 Dec '23

21 Dec '23
boklm pushed to branch main at The Tor Project / Applications / tor-browser-build Commits: 6858c6bd by Nicolas Vigier at 2023-12-20T16:40:56+01:00 Bug 41056: Make it possible to use templates in var/torbrowser_incremental_from - - - - - 1 changed file: - projects/release/update_responses_config.yml Changes: ===================================== projects/release/update_responses_config.yml ===================================== @@ -43,9 +43,12 @@ versions: [% END -%] incremental_from: [% SET incr_from = c("var/nightly") ? c("var_p/nightly_torbrowser_incremental_from") : c("var/torbrowser_incremental_from"); - FOREACH v IN incr_from -%] - - [% v %] -[% END -%] + FOREACH v IN incr_from; + SET ver = tmpl(v); + IF ver -%] + - [% ver %] +[% END; + END -%] # for example, osx32: osx64 migrate_archs: # for example, pt-PT: pt-BR View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/6… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/6… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser][tor-browser-115.6.0esr-13.5-1] 3 commits: fixup! Bug 40933: Add tor-launcher functionality
by Pier Angelo Vendrame (@pierov) 20 Dec '23

20 Dec '23
Pier Angelo Vendrame pushed to branch tor-browser-115.6.0esr-13.5-1 at The Tor Project / Applications / Tor Browser Commits: 8649662e by Pier Angelo Vendrame at 2023-12-20T19:16:35+01:00 fixup! Bug 40933: Add tor-launcher functionality Removed a redundant wrappedJSObject that broke stuff. - - - - - 7cb6472f by Pier Angelo Vendrame at 2023-12-20T21:49:35+01:00 fixup! Bug 42247: Android helpers for the TorProvider Bug 42251: Wired bootstrap updates. - - - - - d980086a by Pier Angelo Vendrame at 2023-12-20T21:49:46+01:00 fixup! Temporary changes to about:torconnect for Android. Temporary message to open Android settings from about:torconnect - - - - - 4 changed files: - mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorIntegrationAndroid.java - toolkit/components/tor-launcher/TorProvider.sys.mjs - toolkit/modules/TorAndroidIntegration.sys.mjs - toolkit/modules/TorConnect.sys.mjs Changes: ===================================== mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorIntegrationAndroid.java ===================================== @@ -46,6 +46,11 @@ public class TorIntegrationAndroid implements BundleEventListener { private static final String EVENT_TOR_STOP = "GeckoView:Tor:StopTor"; private static final String EVENT_MEEK_START = "GeckoView:Tor:StartMeek"; private static final String EVENT_MEEK_STOP = "GeckoView:Tor:StopMeek"; + private static final String EVENT_BOOTSTRAP_STATE_CHANGED = "GeckoView:Tor:BootstrapStateChanged"; + private static final String EVENT_BOOTSTRAP_PROGRESS = "GeckoView:Tor:BootstrapProgress"; + private static final String EVENT_BOOTSTRAP_COMPLETE = "GeckoView:Tor:BootstrapComplete"; + private static final String EVENT_BOOTSTRAP_ERROR = "GeckoView:Tor:BootstrapError"; + private static final String EVENT_SETTINGS_OPEN = "GeckoView:Tor:OpenSettings"; // Events we emit private static final String EVENT_SETTINGS_GET = "GeckoView:Tor:SettingsGet"; @@ -106,7 +111,12 @@ public class TorIntegrationAndroid implements BundleEventListener { EVENT_TOR_START, EVENT_MEEK_START, EVENT_MEEK_STOP, - EVENT_SETTINGS_READY); + EVENT_SETTINGS_READY, + EVENT_BOOTSTRAP_STATE_CHANGED, + EVENT_BOOTSTRAP_PROGRESS, + EVENT_BOOTSTRAP_COMPLETE, + EVENT_BOOTSTRAP_ERROR, + EVENT_SETTINGS_OPEN); } @Override // BundleEventListener @@ -122,6 +132,32 @@ public class TorIntegrationAndroid implements BundleEventListener { stopMeek(message, callback); } else if (EVENT_SETTINGS_READY.equals(event)) { loadSettings(message); + } else if (EVENT_BOOTSTRAP_STATE_CHANGED.equals(event)) { + String state = message.getString("state"); + for (BootstrapStateChangeListener listener: mBootstrapStateListeners) { + listener.onBootstrapStateChange(state); + } + } else if (EVENT_BOOTSTRAP_PROGRESS.equals(event)) { + double progress = message.getDouble("progress"); + String status = message.getString("status"); + boolean hasWarnings = message.getBoolean("hasWarnings"); + for (BootstrapStateChangeListener listener: mBootstrapStateListeners) { + listener.onBootstrapProgress(progress, status, hasWarnings); + } + } else if (EVENT_BOOTSTRAP_COMPLETE.equals(event)) { + for (BootstrapStateChangeListener listener: mBootstrapStateListeners) { + listener.onBootstrapComplete(); + } + } else if (EVENT_BOOTSTRAP_ERROR.equals(event)) { + String msg = message.getString("message"); + String details = message.getString("details"); + for (BootstrapStateChangeListener listener: mBootstrapStateListeners) { + listener.onBootstrapError(msg, details); + } + } else if (EVENT_SETTINGS_OPEN.equals(event)) { + for (BootstrapStateChangeListener listener: mBootstrapStateListeners) { + listener.onSettingsRequested(); + } } } @@ -467,17 +503,12 @@ public class TorIntegrationAndroid implements BundleEventListener { } } - public static class BootstrapState { - // FIXME: We can do better than this :) - public GeckoBundle mBundle; - - BootstrapState(GeckoBundle bundle) { - mBundle = bundle; - } - } - public interface BootstrapStateChangeListener { - void onBootstrapStateChange(BootstrapState state); + void onBootstrapStateChange(String state); + void onBootstrapProgress(double progress, String status, boolean hasWarnings); + void onBootstrapComplete(); + void onBootstrapError(String message, String details); + void onSettingsRequested(); } public @NonNull GeckoResult<GeckoBundle> getSettings() { @@ -514,16 +545,6 @@ public class TorIntegrationAndroid implements BundleEventListener { return EventDispatcher.getInstance().queryVoid(EVENT_BOOTSTRAP_CANCEL); } - public @NonNull GeckoResult<BootstrapState> getBootstrapState() { - return EventDispatcher.getInstance().queryBundle(EVENT_BOOTSTRAP_GET_STATE).map(new GeckoResult.OnValueMapper<>() { - @AnyThread - @Nullable - public BootstrapState onValue(@Nullable GeckoBundle value) throws Throwable { - return new BootstrapState(value); - } - }); - } - public void registerBootstrapStateChangeListener(BootstrapStateChangeListener listener) { mBootstrapStateListeners.add(listener); } ===================================== toolkit/components/tor-launcher/TorProvider.sys.mjs ===================================== @@ -875,10 +875,7 @@ export class TorProvider { */ #processBootstrapStatus(statusObj, isNotification) { // Notify observers - Services.obs.notifyObservers( - { wrappedJSObject: statusObj }, - TorProviderTopics.BootstrapStatus - ); + Services.obs.notifyObservers(statusObj, TorProviderTopics.BootstrapStatus); if (statusObj.PROGRESS === 100) { this.#isBootstrapDone = true; ===================================== toolkit/modules/TorAndroidIntegration.sys.mjs ===================================== @@ -25,9 +25,13 @@ const logger = new ConsoleAPI({ prefix: "TorAndroidIntegration", }); -const EmittedEvents = Object.freeze( { +const EmittedEvents = Object.freeze({ settingsReady: "GeckoView:Tor:SettingsReady", settingsChanged: "GeckoView:Tor:SettingsChanged", + bootstrapStateChanged: "GeckoView:Tor:BootstrapStateChanged", + bootstrapProgress: "GeckoView:Tor:BootstrapProgress", + bootstrapComplete: "GeckoView:Tor:BootstrapComplete", + bootstrapError: "GeckoView:Tor:BootstrapError", }); const ListenedEvents = Object.freeze({ @@ -89,6 +93,30 @@ class TorAndroidIntegrationImpl { } break; case lazy.TorConnectTopics.StateChange: + lazy.EventDispatcher.instance.sendRequest({ + type: EmittedEvents.bootstrapStateChanged, + state: subj.wrappedJSObject.state ?? "", + }); + break; + case lazy.TorConnectTopics.BootstrapProgress: + lazy.EventDispatcher.instance.sendRequest({ + type: EmittedEvents.bootstrapProgress, + progress: subj.wrappedJSObject.progress ?? "", + status: subj.wrappedJSObject.status ?? 0, + hasWarnings: subj.wrappedJSObject.hasWarnings ?? false, + }); + break; + case lazy.TorConnectTopics.BootstrapComplete: + lazy.EventDispatcher.instance.sendRequest({ + type: EmittedEvents.bootstrapComplete, + }); + break; + case lazy.TorConnectTopics.BootstrapError: + lazy.EventDispatcher.instance.sendRequest({ + type: EmittedEvents.bootstrapError, + message: subj.wrappedJSObject.message ?? "", + details: subj.wrappedJSObject.details ?? "", + }); break; case lazy.TorSettingsTopics.Ready: lazy.EventDispatcher.instance.sendRequest({ ===================================== toolkit/modules/TorConnect.sys.mjs ===================================== @@ -7,6 +7,7 @@ import { setTimeout, clearTimeout } from "resource://gre/modules/Timer.sys.mjs"; const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { + EventDispatcher: "resource://gre/modules/Messaging.sys.mjs", MoatRPC: "resource://gre/modules/Moat.sys.mjs", TorBootstrapRequest: "resource://gre/modules/TorBootstrapRequest.sys.mjs", }); @@ -1092,6 +1093,12 @@ export const TorConnect = (() => { Further external commands and helper methods */ openTorPreferences() { + if (TorLauncherUtil.isAndroid) { + lazy.EventDispatcher.instance.sendRequest({ + type: "GeckoView:Tor:OpenSettings", + }); + return; + } const win = lazy.BrowserWindowTracker.getTopWindow(); win.switchToTabHavingURI("about:preferences#connection", true); }, View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/e9cc48… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/e9cc48… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser][tor-browser-115.6.0esr-13.5-1] 2 commits: fixup! Bug 42247: Android helpers for the TorProvider
by Pier Angelo Vendrame (@pierov) 20 Dec '23

20 Dec '23
Pier Angelo Vendrame pushed to branch tor-browser-115.6.0esr-13.5-1 at The Tor Project / Applications / Tor Browser Commits: 1edf6cd0 by Pier Angelo Vendrame at 2023-12-20T17:50:17+00:00 fixup! Bug 42247: Android helpers for the TorProvider Some wiring for TorSettings and TorConnect stuff and fixes to the one I created previously. - - - - - e9cc4840 by Dan Ballard at 2023-12-20T17:50:17+00:00 fixup! Bug 42247: Android helpers for the TorProvider Bug 42301: fix and implement loading settings and saving them to TorSettings.sys.mjs from Java - - - - - 6 changed files: - mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java - mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorIntegrationAndroid.java - + mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorSettings.java - + mobile/android/geckoview/src/main/java/org/mozilla/geckoview/androidlegacysettings/Prefs.java - + mobile/android/geckoview/src/main/java/org/mozilla/geckoview/androidlegacysettings/TorLegacyAndroidSettings.java - toolkit/modules/TorAndroidIntegration.sys.mjs Changes: ===================================== mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java ===================================== @@ -1008,6 +1008,14 @@ public final class GeckoRuntime implements Parcelable { return mPushController; } + /** + * Get the Tor integration controller for this runtime. + */ + @UiThread + public @NonNull TorIntegrationAndroid getTorIntegrationController() { + return mTorIntegration; + } + /** * Appends notes to crash report. * ===================================== mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorIntegrationAndroid.java ===================================== @@ -9,6 +9,10 @@ package org.mozilla.geckoview; import android.content.Context; import android.util.Log; +import androidx.annotation.AnyThread; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -22,9 +26,9 @@ import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermissions; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.UUID; import org.mozilla.gecko.EventDispatcher; import org.mozilla.gecko.GeckoAppShell; @@ -32,13 +36,27 @@ import org.mozilla.gecko.util.BundleEventListener; import org.mozilla.gecko.util.EventCallback; import org.mozilla.gecko.util.GeckoBundle; -/* package */ class TorIntegrationAndroid implements BundleEventListener { +import org.mozilla.geckoview.androidlegacysettings.TorLegacyAndroidSettings; + +public class TorIntegrationAndroid implements BundleEventListener { private static final String TAG = "TorIntegrationAndroid"; - private static final String TOR_EVENT_START = "GeckoView:Tor:StartTor"; - private static final String TOR_EVENT_STOP = "GeckoView:Tor:StopTor"; - private static final String MEEK_EVENT_START = "GeckoView:Tor:StartMeek"; - private static final String MEEK_EVENT_STOP = "GeckoView:Tor:StopMeek"; + // Events we listen to + private static final String EVENT_TOR_START = "GeckoView:Tor:StartTor"; + private static final String EVENT_TOR_STOP = "GeckoView:Tor:StopTor"; + private static final String EVENT_MEEK_START = "GeckoView:Tor:StartMeek"; + private static final String EVENT_MEEK_STOP = "GeckoView:Tor:StopMeek"; + + // Events we emit + private static final String EVENT_SETTINGS_GET = "GeckoView:Tor:SettingsGet"; + private static final String EVENT_SETTINGS_SET = "GeckoView:Tor:SettingsSet"; + private static final String EVENT_SETTINGS_APPLY = "GeckoView:Tor:SettingsApply"; + private static final String EVENT_SETTINGS_SAVE = "GeckoView:Tor:SettingsSave"; + private static final String EVENT_BOOTSTRAP_BEGIN = "GeckoView:Tor:BootstrapBegin"; + private static final String EVENT_BOOTSTRAP_BEGIN_AUTO = "GeckoView:Tor:BootstrapBeginAuto"; + private static final String EVENT_BOOTSTRAP_CANCEL = "GeckoView:Tor:BootstrapCancel"; + private static final String EVENT_BOOTSTRAP_GET_STATE = "GeckoView:Tor:BootstrapGetState"; + private static final String EVENT_SETTINGS_READY = "GeckoView:Tor:SettingsReady"; private static final String CONTROL_PORT_FILE = "/control-ipc"; private static final String SOCKS_FILE = "/socks-ipc"; @@ -63,7 +81,9 @@ import org.mozilla.gecko.util.GeckoBundle; private final HashMap<Integer, MeekTransport> mMeeks = new HashMap<>(); private int mMeekCounter; - public TorIntegrationAndroid(Context context) { + private TorSettings mSettings = null; + + /* package */ TorIntegrationAndroid(Context context) { mLibraryDir = context.getApplicationInfo().nativeLibraryDir; mCacheDir = context.getCacheDir().toPath(); mIpcDirectory = mCacheDir + "/tor-private"; @@ -71,7 +91,7 @@ import org.mozilla.gecko.util.GeckoBundle; registerListener(); } - public synchronized void shutdown() { + /* package */ synchronized void shutdown() { // FIXME: It seems this never gets called if (mTorProcess != null) { mTorProcess.shutdown(); @@ -83,22 +103,36 @@ import org.mozilla.gecko.util.GeckoBundle; EventDispatcher.getInstance() .registerUiThreadListener( this, - TOR_EVENT_START, - MEEK_EVENT_START, - MEEK_EVENT_STOP); + EVENT_TOR_START, + EVENT_MEEK_START, + EVENT_MEEK_STOP, + EVENT_SETTINGS_READY); } @Override // BundleEventListener public synchronized void handleMessage( final String event, final GeckoBundle message, final EventCallback callback) { - if (TOR_EVENT_START.equals(event)) { + if (EVENT_TOR_START.equals(event)) { startDaemon(message, callback); - } else if (TOR_EVENT_STOP.equals(event)) { + } else if (EVENT_TOR_STOP.equals(event)) { stopDaemon(message, callback); - } else if (MEEK_EVENT_START.equals(event)) { + } else if (EVENT_MEEK_START.equals(event)) { startMeek(message, callback); - } else if (MEEK_EVENT_STOP.equals(event)) { + } else if (EVENT_MEEK_STOP.equals(event)) { stopMeek(message, callback); + } else if (EVENT_SETTINGS_READY.equals(event)) { + loadSettings(message); + } + } + + private void loadSettings(GeckoBundle message) { + if (TorLegacyAndroidSettings.unmigrated()) { + mSettings = TorLegacyAndroidSettings.loadTorSettings(); + setSettings(mSettings); + TorLegacyAndroidSettings.setMigrated(); + } else { + GeckoBundle bundle = message.getBundle("settings"); + mSettings = new TorSettings(bundle); } } @@ -145,9 +179,9 @@ import org.mozilla.gecko.util.GeckoBundle; } class TorProcess extends Thread { - private static final String TOR_EVENT_STARTED = "GeckoView:Tor:TorStarted"; - private static final String TOR_EVENT_START_FAILED = "GeckoView:Tor:TorStartFailed"; - private static final String TOR_EVENT_EXITED = "GeckoView:Tor:TorExited"; + private static final String EVENT_TOR_STARTED = "GeckoView:Tor:TorStarted"; + private static final String EVENT_TOR_START_FAILED = "GeckoView:Tor:TorStartFailed"; + private static final String EVENT_TOR_EXITED = "GeckoView:Tor:TorExited"; private final String mHandle; private Process mProcess = null; @@ -202,14 +236,14 @@ import org.mozilla.gecko.util.GeckoBundle; final GeckoBundle data = new GeckoBundle(2); data.putString("handle", mHandle); data.putString("error", e.getMessage()); - EventDispatcher.getInstance().dispatch(TOR_EVENT_START_FAILED, data); + EventDispatcher.getInstance().dispatch(EVENT_TOR_START_FAILED, data); return; } Log.i(TAG, "Tor process " + mHandle + " started."); { final GeckoBundle data = new GeckoBundle(1); data.putString("handle", mHandle); - EventDispatcher.getInstance().dispatch(TOR_EVENT_STARTED, data); + EventDispatcher.getInstance().dispatch(EVENT_TOR_STARTED, data); } try { BufferedReader reader = new BufferedReader(new InputStreamReader(mProcess.getInputStream())); @@ -232,7 +266,7 @@ import org.mozilla.gecko.util.GeckoBundle; // FIXME: We usually don't reach this when the application is killed! // So, we don't do our cleanup. Log.i(TAG, "Tor process " + mHandle + " has exited."); - EventDispatcher.getInstance().dispatch(TOR_EVENT_EXITED, data); + EventDispatcher.getInstance().dispatch(EVENT_TOR_EXITED, data); } private void cleanIpcDirectory() { @@ -432,4 +466,71 @@ import org.mozilla.gecko.util.GeckoBundle; } } } + + public static class BootstrapState { + // FIXME: We can do better than this :) + public GeckoBundle mBundle; + + BootstrapState(GeckoBundle bundle) { + mBundle = bundle; + } + } + + public interface BootstrapStateChangeListener { + void onBootstrapStateChange(BootstrapState state); + } + + public @NonNull GeckoResult<GeckoBundle> getSettings() { + return EventDispatcher.getInstance().queryBundle(EVENT_SETTINGS_GET); + } + + public @NonNull GeckoResult<Void> setSettings(final TorSettings settings) { + return EventDispatcher.getInstance().queryVoid(EVENT_SETTINGS_SET, settings.asGeckoBundle()); + } + + public @NonNull GeckoResult<Void> applySettings() { + return EventDispatcher.getInstance().queryVoid(EVENT_SETTINGS_APPLY); + } + + public @NonNull GeckoResult<Void> saveSettings() { + return EventDispatcher.getInstance().queryVoid(EVENT_SETTINGS_SAVE); + } + + public @NonNull GeckoResult<Void> beginBootstrap() { + return EventDispatcher.getInstance().queryVoid(EVENT_BOOTSTRAP_BEGIN); + } + + public @NonNull GeckoResult<Void> beginAutoBootstrap(final String countryCode) { + final GeckoBundle bundle = new GeckoBundle(1); + bundle.putString("countryCode", countryCode); + return EventDispatcher.getInstance().queryVoid(EVENT_BOOTSTRAP_BEGIN_AUTO, bundle); + } + + public @NonNull GeckoResult<Void> beginAutoBootstrap() { + return beginAutoBootstrap(null); + } + + public @NonNull GeckoResult<Void> cancelBootstrap() { + return EventDispatcher.getInstance().queryVoid(EVENT_BOOTSTRAP_CANCEL); + } + + public @NonNull GeckoResult<BootstrapState> getBootstrapState() { + return EventDispatcher.getInstance().queryBundle(EVENT_BOOTSTRAP_GET_STATE).map(new GeckoResult.OnValueMapper<>() { + @AnyThread + @Nullable + public BootstrapState onValue(@Nullable GeckoBundle value) throws Throwable { + return new BootstrapState(value); + } + }); + } + + public void registerBootstrapStateChangeListener(BootstrapStateChangeListener listener) { + mBootstrapStateListeners.add(listener); + } + + public void unregisterBootstrapStateChangeListener(BootstrapStateChangeListener listener) { + mBootstrapStateListeners.remove(listener); + } + + private final HashSet<BootstrapStateChangeListener> mBootstrapStateListeners = new HashSet<>(); } ===================================== mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorSettings.java ===================================== @@ -0,0 +1,172 @@ +package org.mozilla.geckoview; + +import android.util.Log; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.mozilla.gecko.util.GeckoBundle; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.io.SequenceInputStream; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.stream.Collectors; + +public class TorSettings { + + public enum BridgeSource { + Invalid(-1), + BuiltIn(0), + BridgeDB(1), + UserProvided(2); + + private int source; + + BridgeSource(final int source) { + this.source = source; + } + + public static BridgeSource fromInt(int i) { + switch (i) { + case -1: return Invalid; + case 0: return BuiltIn; + case 1: return BridgeDB; + case 2: return UserProvided; + } + return Invalid; + } + + public int toInt() { + return this.source; + } + } + + public enum ProxyType { + Invalid(-1), + Socks4(0), + Socks5(1), + HTTPS(2); + + private int type; + + ProxyType(final int type) { + this.type = type; + } + + public int toInt() { + return type; + } + + public static ProxyType fromInt(int i) { + switch (i) { + case -1: return Invalid; + case 0: return Socks4; + case 1: return Socks5; + case 2: return HTTPS; + } + return Invalid; + } + } + + private boolean loaded = false; + + public boolean enabled = true; + + public boolean quickstart = false; + + // bridges section + public boolean bridgesEnabled = false; + public BridgeSource bridgesSource = BridgeSource.Invalid; + public String bridgesBuiltinType = ""; + public String[] bridgeBridgeStrings; + + // proxy section + public boolean proxyEnabled = false; + public ProxyType proxyType = ProxyType.Invalid; + public String proxyAddress = ""; + public int proxyPort = 0; + public String proxyUsername = ""; + public String proxyPassword = ""; + + // firewall section + public boolean firewallEnabled = false; + public int[] firewallAllowedPorts; + + public TorSettings() { + } + + public TorSettings(GeckoBundle bundle) { + try { + GeckoBundle qs = bundle.getBundle("quickstart"); + GeckoBundle bridges = bundle.getBundle("bridges"); + GeckoBundle proxy = bundle.getBundle("proxy"); + GeckoBundle firewall = bundle.getBundle("firewall"); + + bridgesEnabled = bridges.getBoolean("enabled"); + bridgesSource = BridgeSource.fromInt(bridges.getInt("source")); + bridgesBuiltinType = bridges.getString("builtin_type"); + bridgeBridgeStrings = bridges.getStringArray("bridge_strings"); + + quickstart = qs.getBoolean("enabled"); + + firewallEnabled = firewall.getBoolean("enabled"); + firewallAllowedPorts = firewall.getIntArray("allowed_ports"); + + proxyEnabled = proxy.getBoolean("enabled"); + proxyAddress = proxy.getString("address"); + proxyUsername = proxy.getString("username"); + proxyPassword = proxy.getString("password"); + proxyPort = proxy.getInt("port"); + proxyType = ProxyType.fromInt(proxy.getInt("type")); + + loaded = true; + } catch (Exception e) { + Log.e("TorSettings", "bundle access error: " + e.toString(), e); + } + } + + public GeckoBundle asGeckoBundle() { + GeckoBundle bundle = new GeckoBundle(); + + GeckoBundle qs = new GeckoBundle(); + GeckoBundle bridges = new GeckoBundle(); + GeckoBundle proxy = new GeckoBundle(); + GeckoBundle firewall = new GeckoBundle(); + + bridges.putBoolean("enabled", bridgesEnabled); + bridges.putInt("source", bridgesSource.toInt()); + bridges.putString("builtin_type", bridgesBuiltinType); + bridges.putStringArray("bridge_strings", bridgeBridgeStrings); + + qs.putBoolean("enabled", quickstart); + + firewall.putBoolean("enabled", firewallEnabled); + firewall.putIntArray("allowed_ports", firewallAllowedPorts); + + proxy.putBoolean("enabled", proxyEnabled); + proxy.putString("address", proxyAddress); + proxy.putString("username", proxyUsername); + proxy.putString("password", proxyPassword); + proxy.putInt("port", proxyPort); + proxy.putInt("type", proxyType.toInt()); + + bundle.putBundle("quickstart", qs); + bundle.putBundle("bridges", bridges); + bundle.putBundle("proxy", proxy); + bundle.putBundle("firewall", firewall); + + return bundle; + } + + public boolean isLoaded() { + return this.loaded; + } +} ===================================== mobile/android/geckoview/src/main/java/org/mozilla/geckoview/androidlegacysettings/Prefs.java ===================================== @@ -0,0 +1,64 @@ +package org.mozilla.geckoview.androidlegacysettings; + +import android.content.Context; +import android.content.SharedPreferences; +import org.mozilla.gecko.GeckoAppShell; + +import java.util.Locale; + +// tor-android-service utils/Prefs.java + +/* package */ class Prefs { + private final static String PREF_BRIDGES_ENABLED = "pref_bridges_enabled"; + private final static String PREF_BRIDGES_LIST = "pref_bridges_list"; + + private static SharedPreferences prefs; + + // OrbotConstants + private final static String PREF_TOR_SHARED_PREFS = "org.torproject.android_preferences"; + + + // tor-android-service utils/TorServiceUtil.java + + private static void setContext() { + if (prefs == null) { + prefs = GeckoAppShell.getApplicationContext().getSharedPreferences(PREF_TOR_SHARED_PREFS, + Context.MODE_MULTI_PROCESS); + } + } + + public static boolean getBoolean(String key, boolean def) { + setContext(); + return prefs.getBoolean(key, def); + } + + public static void putBoolean(String key, boolean value) { + setContext(); + prefs.edit().putBoolean(key, value).apply(); + } + + public static void putString(String key, String value) { + setContext(); + prefs.edit().putString(key, value).apply(); + } + + public static String getString(String key, String def) { + setContext(); + return prefs.getString(key, def); + } + + public static boolean bridgesEnabled() { + setContext(); + return prefs.getBoolean(PREF_BRIDGES_ENABLED, false); + } + + public static String getBridgesList() { + setContext(); + // was "meek" for (Locale.getDefault().getLanguage().equals("fa")) and "obfs4" for the rest from a 2019 commit + // but that has stopped representing a good default sometime since so not importing for new users + String list = prefs.getString(PREF_BRIDGES_LIST, ""); + return list; + } + + +} ===================================== mobile/android/geckoview/src/main/java/org/mozilla/geckoview/androidlegacysettings/TorLegacyAndroidSettings.java ===================================== @@ -0,0 +1,84 @@ +package org.mozilla.geckoview.androidlegacysettings; + +import java.io.IOException; + +import android.content.SharedPreferences; + +import org.mozilla.gecko.GeckoAppShell; + +import org.mozilla.geckoview.TorSettings; + +public class TorLegacyAndroidSettings { + + private static String PREF_USE_MOZ_PREFS = "tor_use_moz_prefs"; + + public static boolean unmigrated() { + return !Prefs.getBoolean(PREF_USE_MOZ_PREFS, false); + } + + public static void setUnmigrated() { + Prefs.putBoolean(PREF_USE_MOZ_PREFS, false); + } + + public static void setMigrated() { + Prefs.putBoolean(PREF_USE_MOZ_PREFS, true); + } + + public static TorSettings loadTorSettings() { + TorSettings settings = new TorSettings(); + + // always true, tor is enabled in TB + settings.enabled = true; + + // firefox-android disconnected quick start a while ago so it's untracked + settings.quickstart = false; + + settings.bridgesEnabled = Prefs.bridgesEnabled(); + + // tor-android-service CustomTorInstaller.java +/* + BridgesList is an overloaded field, which can cause some confusion. + The list can be: + 1) a filter like obfs4, meek, or snowflake OR + 2) it can be a custom bridge + For (1), we just pass back all bridges, the filter will occur + elsewhere in the library. + For (2) we return the bridge list as a raw stream. + If length is greater than 9, then we know this is a custom bridge + */ + String userDefinedBridgeList = Prefs.getBridgesList(); + boolean userDefinedBridge = userDefinedBridgeList.length() > 9; + // Terrible hack. Must keep in sync with topl::addBridgesFromResources. + if (!userDefinedBridge) { + settings.bridgesSource = TorSettings.BridgeSource.BuiltIn; + switch (userDefinedBridgeList) { + case "obfs4": + settings.bridgesBuiltinType = "objs4"; + break; + case "meek": + settings.bridgesBuiltinType = "meek_azure"; + break; + case "snowflake": + settings.bridgesBuiltinType = "snowflake"; + break; + default: + settings.bridgesSource = TorSettings.BridgeSource.Invalid; + break; + } + } else { + settings.bridgesSource = TorSettings.BridgeSource.UserProvided; // user provided + settings.bridgeBridgeStrings = userDefinedBridgeList.split("\r\n"); + } + + // Tor Browser Android doesn't take proxy and firewall settings + settings.proxyEnabled = false; + + settings.firewallEnabled = false; + settings.firewallAllowedPorts = new int[0]; + + return settings; + } +} + + + ===================================== toolkit/modules/TorAndroidIntegration.sys.mjs ===================================== @@ -8,6 +8,8 @@ const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { EventDispatcher: "resource://gre/modules/Messaging.sys.mjs", TorConnect: "resource://gre/modules/TorConnect.sys.mjs", + TorConnectTopics: "resource://gre/modules/TorConnect.sys.mjs", + TorSettingsTopics: "resource://gre/modules/TorSettings.sys.mjs", TorProviderBuilder: "resource://gre/modules/TorProviderBuilder.sys.mjs", TorSettings: "resource://gre/modules/TorSettings.sys.mjs", }); @@ -23,11 +25,22 @@ const logger = new ConsoleAPI({ prefix: "TorAndroidIntegration", }); +const EmittedEvents = Object.freeze( { + settingsReady: "GeckoView:Tor:SettingsReady", + settingsChanged: "GeckoView:Tor:SettingsChanged", +}); + const ListenedEvents = Object.freeze({ settingsGet: "GeckoView:Tor:SettingsGet", + // The data is passed directly to TorSettings. settingsSet: "GeckoView:Tor:SettingsSet", settingsApply: "GeckoView:Tor:SettingsApply", settingsSave: "GeckoView:Tor:SettingsSave", + bootstrapBegin: "GeckoView:Tor:BootstrapBegin", + // Optionally takes a countryCode, as data.countryCode. + bootstrapBeginAuto: "GeckoView:Tor:BootstrapBeginAuto", + bootstrapCancel: "GeckoView:Tor:BootstrapCancel", + bootstrapGetState: "GeckoView:Tor:BootstrapGetState", }); class TorAndroidIntegrationImpl { @@ -41,6 +54,14 @@ class TorAndroidIntegrationImpl { this.#bootstrapMethodReset(); Services.prefs.addObserver(Prefs.useNewBootstrap, this); + + for (const topic in lazy.TorConnectTopics) { + Services.obs.addObserver(this, lazy.TorConnectTopics[topic]); + } + + for (const topic in lazy.TorSettingsTopics) { + Services.obs.addObserver(this, lazy.TorSettingsTopics[topic]); + } } async #initNewBootstrap() { @@ -67,6 +88,14 @@ class TorAndroidIntegrationImpl { this.#bootstrapMethodReset(); } break; + case lazy.TorConnectTopics.StateChange: + break; + case lazy.TorSettingsTopics.Ready: + lazy.EventDispatcher.instance.sendRequest({ + type: EmittedEvents.settingsReady, + settings: lazy.TorSettings.getSettings(), + }); + break; } } @@ -74,24 +103,36 @@ class TorAndroidIntegrationImpl { logger.debug(`Received event ${event}`, data); try { switch (event) { - case settingsGet: + case ListenedEvents.settingsGet: callback?.onSuccess(lazy.TorSettings.getSettings()); return; - case settingsSet: + case ListenedEvents.settingsSet: // This does not throw, so we do not have any way to report the error! lazy.TorSettings.setSettings(data); break; - case settingsApply: + case ListenedEvents.settingsApply: await lazy.TorSettings.applySettings(); break; - case settingsSave: + case ListenedEvents.settingsSave: await lazy.TorSettings.saveSettings(); break; + case ListenedEvents.bootstrapBegin: + lazy.TorConnect.beginBootstrap(); + break; + case ListenedEvents.bootstrapBeginAuto: + lazy.TorConnect.beginAutoBootstrap(data.countryCode); + break; + case ListenedEvents.bootstrapCancel: + lazy.TorConnect.cancelBootstrap(); + break; + case ListenedEvents.bootstrapGetState: + callback?.onSuccess(lazy.TorConnect.state); + return; } callback?.onSuccess(); } catch (e) { - logger.error(); - callback?.sendError(e); + logger.error(`Error while handling event ${event}`, e); + callback?.onError(e); } } View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/d823a7… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/d823a7… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
  • ← Newer
  • 1
  • 2
  • 3
  • 4
  • 5
  • ...
  • 13
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.