Skip to content
Snippets Groups Projects
Verified Commit a3211b87 authored by Richard Pospesel's avatar Richard Pospesel Committed by ma1
Browse files

Bug 40597: Implement TorSettings module

- migrated in-page settings read/write implementation from about:preferences#tor
  to the TorSettings module
- TorSettings initially loads settings from the tor daemon, and saves them to
  firefox prefs
- TorSettings notifies observers when a setting has changed; currently only
  QuickStart notification is implemented for parity with previous preference
  notify logic in about:torconnect and about:preferences#tor
- about:preferences#tor, and about:torconnect now read and write settings
  thorugh the TorSettings module
- all tor settings live in the torbrowser.settings.* preference branch
- removed unused pref modify permission for about:torconnect content page from
  AsyncPrefs.jsm

Bug 40645: Migrate Moat APIs to Moat.jsm module
parent ad848683
No related branches found
No related tags found
1 merge request!957Bug 42474: Rebase stable browser on 115.9.1
/* 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/. */
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
MoatRPC: "resource:///modules/Moat.sys.mjs",
});
export var BridgeDB = {
_moatRPC: null,
_challenge: null,
_image: null,
_bridges: null,
get currentCaptchaImage() {
return this._image;
},
get currentBridges() {
return this._bridges;
},
async submitCaptchaGuess(solution) {
if (!this._moatRPC) {
this._moatRPC = new lazy.MoatRPC();
await this._moatRPC.init();
}
const response = await this._moatRPC.check(
"obfs4",
this._challenge,
solution,
false
);
this._bridges = response?.bridges;
return this._bridges;
},
async requestNewCaptchaImage() {
try {
if (!this._moatRPC) {
this._moatRPC = new lazy.MoatRPC();
await this._moatRPC.init();
}
const response = await this._moatRPC.fetch(["obfs4"]);
this._challenge = response.challenge;
this._image =
"data:image/jpeg;base64," + encodeURIComponent(response.image);
} catch (err) {
console.error("Could not request a captcha image", err);
}
return this._image;
},
close() {
this._moatRPC?.uninit();
this._moatRPC = null;
this._challenge = null;
this._image = null;
this._bridges = null;
},
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -123,6 +123,7 @@ XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"]
EXTRA_JS_MODULES += [
"AboutNewTab.jsm",
"AsyncTabSwitcher.jsm",
"BridgeDB.sys.mjs",
"BrowserUIUtils.jsm",
"BrowserUsageTelemetry.jsm",
"BrowserWindowTracker.jsm",
......@@ -134,6 +135,7 @@ EXTRA_JS_MODULES += [
"FeatureCallout.sys.mjs",
"HomePage.jsm",
"LaterRun.jsm",
"Moat.sys.mjs",
"NewTabPagePreloading.jsm",
"OpenInTabsUtils.jsm",
"PageActions.jsm",
......@@ -147,6 +149,8 @@ EXTRA_JS_MODULES += [
"SitePermissions.sys.mjs",
"TabsList.jsm",
"TabUnloader.jsm",
"TorConnect.sys.mjs",
"TorSettings.sys.mjs",
"TorStrings.jsm",
"TransientPrefs.jsm",
"URILoadingHelper.sys.mjs",
......
......@@ -3,8 +3,10 @@ const lazy = {};
// We will use the modules only when the profile is loaded, so prefer lazy
// loading
ChromeUtils.defineESModuleGetters(lazy, {
TorConnect: "resource:///modules/TorConnect.sys.mjs",
TorLauncherUtil: "resource://gre/modules/TorLauncherUtil.sys.mjs",
TorProviderBuilder: "resource://gre/modules/TorProviderBuilder.sys.mjs",
TorSettings: "resource:///modules/TorSettings.sys.mjs",
});
/* Browser observer topis */
......@@ -36,6 +38,9 @@ export class TorStartupService {
// block there, instead.
lazy.TorProviderBuilder.init();
await lazy.TorSettings.init();
lazy.TorConnect.init();
gInited = true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment