Pier Angelo Vendrame pushed to branch tor-browser-115.10.0esr-13.5-1 at The Tor Project / Applications / Tor Browser

Commits:

3 changed files:

Changes:

  • browser/components/torpreferences/content/connectionPane.js
    ... ... @@ -1284,6 +1284,11 @@ const gLoxStatus = {
    1284 1284
        * Initialize the bridge pass area.
    
    1285 1285
        */
    
    1286 1286
       init() {
    
    1287
    +    if (!Lox.enabled) {
    
    1288
    +      // Area should remain inactive and hidden.
    
    1289
    +      return;
    
    1290
    +    }
    
    1291
    +
    
    1287 1292
         this._area = document.getElementById("tor-bridges-lox-status");
    
    1288 1293
         this._detailsArea = document.getElementById("tor-bridges-lox-details");
    
    1289 1294
         this._nextUnlockCounterEl = document.getElementById(
    
    ... ... @@ -1333,6 +1338,10 @@ const gLoxStatus = {
    1333 1338
        * Uninitialize the built-in bridges area.
    
    1334 1339
        */
    
    1335 1340
       uninit() {
    
    1341
    +    if (!Lox.enabled) {
    
    1342
    +      return;
    
    1343
    +    }
    
    1344
    +
    
    1336 1345
         Services.obs.removeObserver(this, TorSettingsTopics.SettingsChanged);
    
    1337 1346
         Services.obs.removeObserver(this, LoxTopics.UpdateActiveLoxId);
    
    1338 1347
         Services.obs.removeObserver(this, LoxTopics.UpdateEvents);
    

  • browser/components/torpreferences/content/provideBridgeDialog.js
    ... ... @@ -72,8 +72,7 @@ const gProvideBridgeDialog = {
    72 72
     
    
    73 73
         document.l10n.setAttributes(document.documentElement, titleId);
    
    74 74
     
    
    75
    -    // TODO: Make conditional on Lox being enabled.
    
    76
    -    this._allowLoxInvite = mode !== "edit"; // && Lox.enabled
    
    75
    +    this._allowLoxInvite = mode !== "edit" && Lox.enabled;
    
    77 76
     
    
    78 77
         document.l10n.setAttributes(
    
    79 78
           document.getElementById("user-provide-bridge-textarea-label"),
    
    ... ... @@ -403,33 +402,39 @@ const gProvideBridgeDialog = {
    403 402
           return null;
    
    404 403
         }
    
    405 404
     
    
    406
    -    let loxInvite = null;
    
    407
    -    for (let line of this._textarea.value.split(/\r?\n/)) {
    
    408
    -      line = line.trim();
    
    409
    -      if (!line) {
    
    410
    -        continue;
    
    411
    -      }
    
    412
    -      // TODO: Once we have a Lox invite encoding, distinguish between a valid
    
    413
    -      // invite and something that looks like it should be an invite.
    
    414
    -      const isLoxInvite = Lox.validateInvitation(line);
    
    415
    -      if (isLoxInvite) {
    
    416
    -        if (!this._allowLoxInvite) {
    
    417
    -          this.updateError({ type: "not-allowed-invite" });
    
    418
    -          return null;
    
    405
    +    // Only check if this looks like a Lox invite when the Lox module is
    
    406
    +    // enabled.
    
    407
    +    if (Lox.enabled) {
    
    408
    +      let loxInvite = null;
    
    409
    +      for (let line of this._textarea.value.split(/\r?\n/)) {
    
    410
    +        line = line.trim();
    
    411
    +        if (!line) {
    
    412
    +          continue;
    
    419 413
             }
    
    420
    -        if (loxInvite) {
    
    421
    -          this.updateError({ type: "multiple-invites" });
    
    414
    +        // TODO: Once we have a Lox invite encoding, distinguish between a valid
    
    415
    +        // invite and something that looks like it should be an invite.
    
    416
    +        const isLoxInvite = Lox.validateInvitation(line);
    
    417
    +        if (isLoxInvite) {
    
    418
    +          if (!this._allowLoxInvite) {
    
    419
    +            // Lox is enabled, but not allowed invites when editing bridge
    
    420
    +            // addresses.
    
    421
    +            this.updateError({ type: "not-allowed-invite" });
    
    422
    +            return null;
    
    423
    +          }
    
    424
    +          if (loxInvite) {
    
    425
    +            this.updateError({ type: "multiple-invites" });
    
    426
    +            return null;
    
    427
    +          }
    
    428
    +          loxInvite = line;
    
    429
    +        } else if (loxInvite) {
    
    430
    +          this.updateError({ type: "mixed" });
    
    422 431
               return null;
    
    423 432
             }
    
    424
    -        loxInvite = line;
    
    425
    -      } else if (loxInvite) {
    
    426
    -        this.updateError({ type: "mixed" });
    
    427
    -        return null;
    
    428 433
           }
    
    429
    -    }
    
    430 434
     
    
    431
    -    if (loxInvite) {
    
    432
    -      return { loxInvite };
    
    435
    +      if (loxInvite) {
    
    436
    +        return { loxInvite };
    
    437
    +      }
    
    433 438
         }
    
    434 439
     
    
    435 440
         const validation = validateBridgeLines(this._textarea.value);
    

  • toolkit/components/lox/Lox.sys.mjs
    1 1
     import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
    
    2
    +import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
    
    2 3
     import {
    
    3 4
       clearInterval,
    
    4 5
       setInterval,
    
    ... ... @@ -103,8 +104,24 @@ export class LoxError extends Error {
    103 104
     }
    
    104 105
     
    
    105 106
     class LoxImpl {
    
    107
    +  /**
    
    108
    +   * Whether the Lox module has completed initialization.
    
    109
    +   *
    
    110
    +   * @type {boolean}
    
    111
    +   */
    
    106 112
       #initialized = false;
    
    107
    -  #window = null;
    
    113
    +
    
    114
    +  /**
    
    115
    +   * Whether the Lox module is enabled for this Tor Browser instance.
    
    116
    +   *
    
    117
    +   * @type {boolean}
    
    118
    +   */
    
    119
    +  #enabled = AppConstants.MOZ_UPDATE_CHANNEL !== "release";
    
    120
    +
    
    121
    +  get enabled() {
    
    122
    +    return this.#enabled;
    
    123
    +  }
    
    124
    +
    
    108 125
       #pubKeyPromise = null;
    
    109 126
       #encTablePromise = null;
    
    110 127
       #constantsPromise = null;
    
    ... ... @@ -218,13 +235,14 @@ class LoxImpl {
    218 235
        * Assert that the module is initialized.
    
    219 236
        */
    
    220 237
       #assertInitialized() {
    
    221
    -    if (!this.#initialized) {
    
    238
    +    if (!this.enabled || !this.#initialized) {
    
    222 239
           throw new LoxError("Not initialized");
    
    223 240
         }
    
    224 241
       }
    
    225 242
     
    
    226 243
       get #inuse() {
    
    227 244
         return (
    
    245
    +      this.enabled &&
    
    228 246
           Boolean(this.#activeLoxId) &&
    
    229 247
           lazy.TorSettings.bridges.enabled === true &&
    
    230 248
           lazy.TorSettings.bridges.source === lazy.TorBridgeSource.Lox
    
    ... ... @@ -532,16 +550,20 @@ class LoxImpl {
    532 550
       }
    
    533 551
     
    
    534 552
       async init() {
    
    553
    +    if (!this.enabled) {
    
    554
    +      lazy.logger.info(
    
    555
    +        "Skipping initialization since Lox module is not enabled"
    
    556
    +      );
    
    557
    +      return;
    
    558
    +    }
    
    535 559
         // If lox_id is set, load it
    
    536 560
         Services.obs.addObserver(this, lazy.TorSettingsTopics.SettingsChanged);
    
    537 561
         Services.obs.addObserver(this, lazy.TorSettingsTopics.Ready);
    
    538 562
     
    
    539 563
         // Hack to make the generated wasm happy
    
    540
    -    this.#window = {
    
    541
    -      crypto,
    
    542
    -    };
    
    543
    -    this.#window.window = this.#window;
    
    544
    -    await lazy.init(this.#window);
    
    564
    +    const win = { crypto };
    
    565
    +    win.window = win;
    
    566
    +    await lazy.init(win);
    
    545 567
         lazy.set_panic_hook();
    
    546 568
         if (typeof lazy.open_invite !== "function") {
    
    547 569
           throw new LoxError("Initialization failed");
    
    ... ... @@ -551,6 +573,9 @@ class LoxImpl {
    551 573
       }
    
    552 574
     
    
    553 575
       async uninit() {
    
    576
    +    if (!this.enabled) {
    
    577
    +      return;
    
    578
    +    }
    
    554 579
         Services.obs.removeObserver(this, lazy.TorSettingsTopics.SettingsChanged);
    
    555 580
         Services.obs.removeObserver(this, lazy.TorSettingsTopics.Ready);
    
    556 581
         if (this.#domainFrontedRequests !== null) {
    
    ... ... @@ -561,7 +586,6 @@ class LoxImpl {
    561 586
           this.#domainFrontedRequests = null;
    
    562 587
         }
    
    563 588
         this.#initialized = false;
    
    564
    -    this.#window = null;
    
    565 589
         this.#invites = [];
    
    566 590
         this.#pubKeys = null;
    
    567 591
         this.#encTable = null;