Verified Commit b1860c5b authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
Browse files

fixup! Bug 30237: Add v3 onion services client authentication prompt

Bug 41844: Stop using the control port directly
parent d6a6529b
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
XPCOMUtils.defineLazyModuleGetters(this, {
  OnionAuthUtil: "chrome://browser/content/onionservices/authUtil.jsm",
  CommonUtils: "resource://services-common/utils.js",
  TorProtocolService: "resource://gre/modules/TorProtocolService.jsm",
  TorStrings: "resource:///modules/TorStrings.jsm",
});

@@ -192,10 +193,6 @@ const OnionAuthPrompt = (function () {
      let controllerFailureMsg =
        TorStrings.onionServices.authPrompt.failedToSetKey;
      try {
        let { controller } = ChromeUtils.import(
          "resource://torbutton/modules/tor-control-port.js"
        );
        let torController = await controller();
        // ^(subdomain.)*onionserviceid.onion$ (case-insensitive)
        const onionServiceIdRegExp =
          /^(.*\.)*(?<onionServiceId>[a-z2-7]{56})\.onion$/i;
@@ -206,8 +203,7 @@ const OnionAuthPrompt = (function () {

        let checkboxElem = this._getCheckboxElement();
        let isPermanent = checkboxElem && checkboxElem.checked;
        torController
          .onionAuthAdd(onionServiceId, base64key, isPermanent)
        TorProtocolService.onionAuthAdd(onionServiceId, base64key, isPermanent)
          .then(aResponse => {
            // Success! Reload the page.
            this._browser.sendMessageToActor(
+6 −9
Original line number Diff line number Diff line
@@ -10,8 +10,8 @@ ChromeUtils.defineModuleGetter(

ChromeUtils.defineModuleGetter(
  this,
  "controller",
  "resource://torbutton/modules/tor-control-port.js"
  "TorProtocolService",
  "resource://gre/modules/TorProtocolService.jsm"
);

var gOnionServicesSavedKeysDialog = {
@@ -49,11 +49,9 @@ var gOnionServicesSavedKeysDialog = {
      const controllerFailureMsg =
        TorStrings.onionServices.authPreferences.failedToRemoveKey;
      try {
        const torController = await controller();

        // Remove in reverse index order to avoid issues caused by index changes.
        for (let i = indexesToDelete.length - 1; i >= 0; --i) {
          await this._deleteOneKey(torController, indexesToDelete[i]);
          await this._deleteOneKey(indexesToDelete[i]);
        }
      } catch (e) {
        if (e.torMessage) {
@@ -127,8 +125,7 @@ var gOnionServicesSavedKeysDialog = {
    try {
      this._tree.view = this;

      const torController = await controller();
      const keyInfoList = await torController.onionAuthViewKeys();
      const keyInfoList = await TorProtocolService.onionAuthViewKeys();
      if (keyInfoList) {
        // Filter out temporary keys.
        this._keyInfoList = keyInfoList.filter(aKeyInfo => {
@@ -165,9 +162,9 @@ var gOnionServicesSavedKeysDialog = {
  },

  // This method may throw; callers should catch errors.
  async _deleteOneKey(aTorController, aIndex) {
  async _deleteOneKey(aIndex) {
    const keyInfoObj = this._keyInfoList[aIndex];
    await aTorController.onionAuthRemove(keyInfoObj.hsAddress);
    await TorProtocolService.onionAuthRemove(keyInfoObj.hsAddress);
    this._tree.view.selection.clearRange(aIndex, aIndex);
    this._keyInfoList.splice(aIndex, 1);
    this._tree.rowCountChanged(aIndex + 1, -1);