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

fixup! Bug 40933: Add tor-launcher functionality

Bug 41844: Added a couple of wrappers for Onion Auth on
TorProtocolService.
parent bdda467f
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -188,6 +188,24 @@ export const TorProtocolService = {
    return TorParsers.parseReply(cmd, keyword, response);
  },

  async onionAuthAdd(hsAddress, b64PrivateKey, isPermanent) {
    return this._withConnection(conn => {
      return conn.onionAuthAdd(hsAddress, b64PrivateKey, isPermanent);
    });
  },

  async onionAuthRemove(hsAddress) {
    return this._withConnection(conn => {
      return conn.onionAuthRemove(hsAddress);
    });
  },

  async onionAuthViewKeys() {
    return this._withConnection(conn => {
      return conn.onionAuthViewKeys();
    });
  },

  // TODO: transform the following 4 functions in getters. At the moment they
  // are also used in torbutton.

@@ -630,6 +648,16 @@ export const TorProtocolService = {
    }
  },

  async _withConnection(func) {
    // TODO: Make more robust?
    const conn = await this._getConnection();
    try {
      return await func(conn);
    } finally {
      this._returnConnection();
    }
  },

  // If aConn is omitted, the cached connection is closed.
  _closeConnection() {
    if (this._controlConnection) {