Pier Angelo Vendrame pushed to branch tor-browser-115.10.0esr-13.5-1 at The Tor Project / Applications / Tor Browser
Commits: 303a1239 by Henry Wilkes at 2024-04-22T17:35:39+01:00 fixup! Lox integration
Bug 42476: Drop unnecessary #window property.
- - - - - 45f5e2d9 by Henry Wilkes at 2024-04-22T17:35:39+01:00 fixup! Bug 31286: Implementation of bridge, proxy, and firewall settings in about:preferences#connection
Bug 42476: Disable the Lox module for the stable release.
- - - - - 94374ba5 by Henry Wilkes at 2024-04-22T18:01:19+01:00 fixup! Lox integration
Bug 42476: Disable the Lox module for the stable release.
- - - - -
3 changed files:
- browser/components/torpreferences/content/connectionPane.js - browser/components/torpreferences/content/provideBridgeDialog.js - toolkit/components/lox/Lox.sys.mjs
Changes:
===================================== browser/components/torpreferences/content/connectionPane.js ===================================== @@ -1284,6 +1284,11 @@ const gLoxStatus = { * Initialize the bridge pass area. */ init() { + if (!Lox.enabled) { + // Area should remain inactive and hidden. + return; + } + this._area = document.getElementById("tor-bridges-lox-status"); this._detailsArea = document.getElementById("tor-bridges-lox-details"); this._nextUnlockCounterEl = document.getElementById( @@ -1333,6 +1338,10 @@ const gLoxStatus = { * Uninitialize the built-in bridges area. */ uninit() { + if (!Lox.enabled) { + return; + } + Services.obs.removeObserver(this, TorSettingsTopics.SettingsChanged); Services.obs.removeObserver(this, LoxTopics.UpdateActiveLoxId); Services.obs.removeObserver(this, LoxTopics.UpdateEvents);
===================================== browser/components/torpreferences/content/provideBridgeDialog.js ===================================== @@ -72,8 +72,7 @@ const gProvideBridgeDialog = {
document.l10n.setAttributes(document.documentElement, titleId);
- // TODO: Make conditional on Lox being enabled. - this._allowLoxInvite = mode !== "edit"; // && Lox.enabled + this._allowLoxInvite = mode !== "edit" && Lox.enabled;
document.l10n.setAttributes( document.getElementById("user-provide-bridge-textarea-label"), @@ -403,33 +402,39 @@ const gProvideBridgeDialog = { return null; }
- let loxInvite = null; - for (let line of this._textarea.value.split(/\r?\n/)) { - line = line.trim(); - if (!line) { - continue; - } - // TODO: Once we have a Lox invite encoding, distinguish between a valid - // invite and something that looks like it should be an invite. - const isLoxInvite = Lox.validateInvitation(line); - if (isLoxInvite) { - if (!this._allowLoxInvite) { - this.updateError({ type: "not-allowed-invite" }); - return null; + // Only check if this looks like a Lox invite when the Lox module is + // enabled. + if (Lox.enabled) { + let loxInvite = null; + for (let line of this._textarea.value.split(/\r?\n/)) { + line = line.trim(); + if (!line) { + continue; } - if (loxInvite) { - this.updateError({ type: "multiple-invites" }); + // TODO: Once we have a Lox invite encoding, distinguish between a valid + // invite and something that looks like it should be an invite. + const isLoxInvite = Lox.validateInvitation(line); + if (isLoxInvite) { + if (!this._allowLoxInvite) { + // Lox is enabled, but not allowed invites when editing bridge + // addresses. + this.updateError({ type: "not-allowed-invite" }); + return null; + } + if (loxInvite) { + this.updateError({ type: "multiple-invites" }); + return null; + } + loxInvite = line; + } else if (loxInvite) { + this.updateError({ type: "mixed" }); return null; } - loxInvite = line; - } else if (loxInvite) { - this.updateError({ type: "mixed" }); - return null; } - }
- if (loxInvite) { - return { loxInvite }; + if (loxInvite) { + return { loxInvite }; + } }
const validation = validateBridgeLines(this._textarea.value);
===================================== toolkit/components/lox/Lox.sys.mjs ===================================== @@ -1,4 +1,5 @@ import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; +import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; import { clearInterval, setInterval, @@ -103,8 +104,24 @@ export class LoxError extends Error { }
class LoxImpl { + /** + * Whether the Lox module has completed initialization. + * + * @type {boolean} + */ #initialized = false; - #window = null; + + /** + * Whether the Lox module is enabled for this Tor Browser instance. + * + * @type {boolean} + */ + #enabled = AppConstants.MOZ_UPDATE_CHANNEL !== "release"; + + get enabled() { + return this.#enabled; + } + #pubKeyPromise = null; #encTablePromise = null; #constantsPromise = null; @@ -218,13 +235,14 @@ class LoxImpl { * Assert that the module is initialized. */ #assertInitialized() { - if (!this.#initialized) { + if (!this.enabled || !this.#initialized) { throw new LoxError("Not initialized"); } }
get #inuse() { return ( + this.enabled && Boolean(this.#activeLoxId) && lazy.TorSettings.bridges.enabled === true && lazy.TorSettings.bridges.source === lazy.TorBridgeSource.Lox @@ -532,16 +550,20 @@ class LoxImpl { }
async init() { + if (!this.enabled) { + lazy.logger.info( + "Skipping initialization since Lox module is not enabled" + ); + return; + } // If lox_id is set, load it Services.obs.addObserver(this, lazy.TorSettingsTopics.SettingsChanged); Services.obs.addObserver(this, lazy.TorSettingsTopics.Ready);
// Hack to make the generated wasm happy - this.#window = { - crypto, - }; - this.#window.window = this.#window; - await lazy.init(this.#window); + const win = { crypto }; + win.window = win; + await lazy.init(win); lazy.set_panic_hook(); if (typeof lazy.open_invite !== "function") { throw new LoxError("Initialization failed"); @@ -551,6 +573,9 @@ class LoxImpl { }
async uninit() { + if (!this.enabled) { + return; + } Services.obs.removeObserver(this, lazy.TorSettingsTopics.SettingsChanged); Services.obs.removeObserver(this, lazy.TorSettingsTopics.Ready); if (this.#domainFrontedRequests !== null) { @@ -561,7 +586,6 @@ class LoxImpl { this.#domainFrontedRequests = null; } this.#initialized = false; - this.#window = null; this.#invites = []; this.#pubKeys = null; this.#encTable = null;
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/07ec581...
tor-commits@lists.torproject.org