This is an automated email from the git hooks/post-receive script.
richard pushed a change to branch tor-browser-91.9.0esr-11.5-1 in repository tor-browser.
from 8598151d65529 fixup! squash! Bug 27476: Implement about:torconnect captive portal within Tor Browser new d54aeed8c9409 fixup! Bug 40597: Implement TorSettings module new d559a9e30f1d5 fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser
The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
Summary of changes: browser/components/torconnect/TorConnectParent.jsm | 2 ++ .../torconnect/content/aboutTorConnect.js | 34 ++++++++++++++-------- browser/modules/Moat.jsm | 9 ++++-- browser/modules/TorConnect.jsm | 24 +++++++++++---- 4 files changed, 48 insertions(+), 21 deletions(-)
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.9.0esr-11.5-1 in repository tor-browser.
commit d54aeed8c9409036b02c89e28ef0aea7ae0f5652 Author: Pier Angelo Vendrame pierov@torproject.org AuthorDate: Tue May 17 16:38:11 2022 +0200
fixup! Bug 40597: Implement TorSettings module
Bug 40923: Make available the country code detected by Moat --- browser/modules/Moat.jsm | 9 ++++++--- browser/modules/TorConnect.jsm | 24 ++++++++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/browser/modules/Moat.jsm b/browser/modules/Moat.jsm index 35931172f3ee4..90a6ae4e521cc 100644 --- a/browser/modules/Moat.jsm +++ b/browser/modules/Moat.jsm @@ -735,6 +735,7 @@ class MoatRPC { country, }; const response = await this._makeRequest("circumvention/settings", args); + let settings = {}; if ("errors" in response) { const code = response.errors[0].code; const detail = response.errors[0].detail; @@ -748,10 +749,12 @@ class MoatRPC {
throw new Error(`MoatRPC: ${detail} (${code})`); } else if ("settings" in response) { - return this._fixupSettingsList(response.settings); + settings.settings = this._fixupSettingsList(response.settings); } - - return []; + if ("country" in response) { + settings.country = response.country; + } + return settings; }
// Request a list of country codes with available censorship circumvention settings diff --git a/browser/modules/TorConnect.jsm b/browser/modules/TorConnect.jsm index 711134326a14d..0edbb7d70c47f 100644 --- a/browser/modules/TorConnect.jsm +++ b/browser/modules/TorConnect.jsm @@ -317,6 +317,7 @@ const TorConnect = (() => { } return codesNames; })()), + _detectedLocation: "", _errorMessage: null, _errorDetails: null, _logHasWarningOrError: false, @@ -380,6 +381,10 @@ const TorConnect = (() => { }; await debug_sleep(1500); TorConnect._hasBootstrapEverFailed = true; + if (Services.prefs.getIntPref(TorConnectPrefs.censorship_level, 0) === 2) { + const codes = Object.keys(TorConnect._countryNames); + TorConnect._detectedLocation = codes[Math.floor(Math.random() * codes.length)]; + } TorConnect._changeState(TorConnectState.Error, "Bootstrap failed (for debugging purposes)", "Error: Censorship simulation", true); TorProtocolService._torBootstrapDebugSetError(); return; @@ -489,22 +494,25 @@ const TorConnect = (() => {
if (this.transitioning) return;
- this.settings = await this.mrpc.circumvention_settings([...TorBuiltinBridgeTypes, "vanilla"], countryCode); + const settings = await this.mrpc.circumvention_settings([...TorBuiltinBridgeTypes, "vanilla"], countryCode);
if (this.transitioning) return;
- const noCountry = this.settings !== null; - const noLocalizedSettings = this.settings && this.settings.length === 0; - if (noCountry || noLocalizedSettings) { + if (settings?.country) { + TorConnect._detectedLocation = settings.country; + } + if (settings?.settings && settings.settings.length > 0) { + this.settings = settings.settings; + } else { try { this.settings = await this.mrpc.circumvention_defaults([...TorBuiltinBridgeTypes, "vanilla"]); } catch (err) { - console.error("We could not get localized settings, but defaults settings failed as well", err); + console.error("We did not get localized settings, and default settings failed as well", err); } } if (this.settings === null || this.settings.length === 0) { // The fallback has failed as well, so throw the original error - if (noCountry) { + if (!TorConnect._detectedLocation) { // unable to determine country throw_error(TorStrings.torConnect.autoBootstrappingFailed, TorStrings.torConnect.cannotDetermineCountry); } else { @@ -750,6 +758,10 @@ const TorConnect = (() => { return this._countryNames; },
+ get detectedLocation() { + return this._detectedLocation; + }, + get errorMessage() { return this._errorMessage; },
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.9.0esr-11.5-1 in repository tor-browser.
commit d559a9e30f1d5efe17bed733baa49cb54278461d Author: Pier Angelo Vendrame pierov@torproject.org AuthorDate: Tue May 17 16:39:47 2022 +0200
fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser
Bug 40923: Redirect to location confirmation rather than location detection failed when Moat reports a country code but the bootstrap fails anyway. --- browser/components/torconnect/TorConnectParent.jsm | 2 ++ .../torconnect/content/aboutTorConnect.js | 34 ++++++++++++++-------- 2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/browser/components/torconnect/TorConnectParent.jsm b/browser/components/torconnect/TorConnectParent.jsm index 3c2a56934c145..a39f7a07a0ade 100644 --- a/browser/components/torconnect/TorConnectParent.jsm +++ b/browser/components/torconnect/TorConnectParent.jsm @@ -36,6 +36,7 @@ class TorConnectParent extends JSWindowActorParent { BootstrapProgress: TorConnect.bootstrapProgress, BootstrapStatus: TorConnect.bootstrapStatus, InternetStatus: TorConnect.internetStatus, + DetectedLocation: TorConnect.detectedLocation, ShowViewLog: TorConnect.logHasWarningOrError, QuickStartEnabled: TorSettings.quickstart.enabled, UIState: TorConnect.uiState, @@ -81,6 +82,7 @@ class TorConnectParent extends JSWindowActorParent { self.state.ErrorMessage = obj.message; self.state.ErrorDetails = obj.details; self.state.InternetStatus = TorConnect.internetStatus; + self.state.DetectedLocation = TorConnect.detectedLocation; self.state.ShowViewLog = true; break; } diff --git a/browser/components/torconnect/content/aboutTorConnect.js b/browser/components/torconnect/content/aboutTorConnect.js index 28356045525a3..bafbe7c7eeb43 100644 --- a/browser/components/torconnect/content/aboutTorConnect.js +++ b/browser/components/torconnect/content/aboutTorConnect.js @@ -404,12 +404,17 @@ class AboutTorConnect { this.transitionUIState(UIStates.ConnectionAssist, state); } else if (state.PreviousState === TorConnectState.AutoBootstrapping) { if (this.uiState.bootstrapCause === UIStates.ConnectionAssist) { - this.transitionUIState( - this.getLocation() === "automatic" - ? UIStates.CouldNotLocate - : UIStates.LocationConfirm, - state - ); + if (this.getLocation() === "automatic") { + this.uiState.allowAutomaticLocation = false; + if (!state.DetectedLocation) { + this.transitionUIState(UIStates.CouldNotLocate, state); + return; + } + // Change the location only here, to avoid overriding any user change/ + // insisting with the detected location + this.setLocation(state.DetectedLocation); + } + this.transitionUIState(UIStates.LocationConfirm, state); } else { this.transitionUIState(UIStates.FinalError, state); } @@ -629,7 +634,7 @@ class AboutTorConnect { RPMSendQuery("torconnect:get-country-codes").then(codes => { if (codes && codes.length) { this.populateFrequentLocations(codes); - this.setLocationFromState(); + this.setLocation(); } }); let firstOpt = this.elements.locationDropdownSelect.options[0]; @@ -640,7 +645,7 @@ class AboutTorConnect { firstOpt.value = ""; firstOpt.textContent = TorStrings.torConnect.selectCountryRegion; } - this.setLocationFromState(); + this.setLocation(); this.validateLocation(); this.show(this.elements.locationDropdownLabel); this.show(this.elements.locationDropdown); @@ -657,8 +662,13 @@ class AboutTorConnect { return this.elements.locationDropdownSelect.options[selectedIndex].value; }
- setLocationFromState() { - if (this.getLocation() === this.uiState.selectedLocation) { + setLocation(code) { + if (!code) { + code = this.uiState.selectedLocation; + } else { + this.uiState.selectedLocation = code; + } + if (this.getLocation() === code) { return; } const options = this.elements.locationDropdownSelect.options; @@ -666,7 +676,7 @@ class AboutTorConnect { // the .value way to select (which would however require the label, // rather than the code)... for (let i = 0; i < options.length; i++) { - if (options[i].value === this.uiState.selectedLocation) { + if (options[i].value === code) { this.elements.locationDropdownSelect.selectedIndex = i; break; } @@ -777,7 +787,7 @@ class AboutTorConnect { RPMAddMessageListener("torconnect:user-action", ({ data }) => { if (data.location) { this.uiState.selectedLocation = data.location; - this.setLocationFromState(); + this.setLocation(); } if (data.uiState !== undefined) { this.transitionUIState(data.uiState, data.connState);
tor-commits@lists.torproject.org