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

Commits:

6 changed files:

Changes:

  • browser/components/torpreferences/content/builtinBridgeDialog.js
    ... ... @@ -4,9 +4,8 @@ const { TorSettings, TorBridgeSource } = ChromeUtils.importESModule(
    4 4
       "resource://gre/modules/TorSettings.sys.mjs"
    
    5 5
     );
    
    6 6
     
    
    7
    -const { TorConnect, TorConnectTopics } = ChromeUtils.importESModule(
    
    8
    -  "resource://gre/modules/TorConnect.sys.mjs"
    
    9
    -);
    
    7
    +const { TorConnect, TorConnectStage, TorConnectTopics } =
    
    8
    +  ChromeUtils.importESModule("resource://gre/modules/TorConnect.sys.mjs");
    
    10 9
     
    
    11 10
     const gBuiltinBridgeDialog = {
    
    12 11
       init() {
    
    ... ... @@ -96,7 +95,7 @@ const gBuiltinBridgeDialog = {
    96 95
       },
    
    97 96
     
    
    98 97
       onAcceptStateChange() {
    
    99
    -    const connect = TorConnect.canBeginBootstrap;
    
    98
    +    const connect = TorConnect.stageName !== TorConnectStage.Bootstrapped;
    
    100 99
         this._result.connect = connect;
    
    101 100
         this._acceptButton.setAttribute(
    
    102 101
           "data-l10n-id",
    

  • browser/components/torpreferences/content/connectionPane.js
    ... ... @@ -2257,6 +2257,8 @@ const gBridgeSettings = {
    2257 2257
               }
    
    2258 2258
     
    
    2259 2259
               // Wait until the settings are applied before bootstrapping.
    
    2260
    +          // NOTE: Saving the settings should also cancel any existing bootstrap
    
    2261
    +          // attempt first. See tor-browser#41921.
    
    2260 2262
               savedSettings.then(() => {
    
    2261 2263
                 // The bridge dialog button is "connect" when Tor is not
    
    2262 2264
                 // bootstrapped, so do the connect.
    

  • browser/components/torpreferences/content/provideBridgeDialog.js
    ... ... @@ -3,9 +3,8 @@
    3 3
     const { TorSettings, TorBridgeSource, validateBridgeLines } =
    
    4 4
       ChromeUtils.importESModule("resource://gre/modules/TorSettings.sys.mjs");
    
    5 5
     
    
    6
    -const { TorConnect, TorConnectTopics } = ChromeUtils.importESModule(
    
    7
    -  "resource://gre/modules/TorConnect.sys.mjs"
    
    8
    -);
    
    6
    +const { TorConnect, TorConnectStage, TorConnectTopics } =
    
    7
    +  ChromeUtils.importESModule("resource://gre/modules/TorConnect.sys.mjs");
    
    9 8
     
    
    10 9
     const { TorParsers } = ChromeUtils.importESModule(
    
    11 10
       "resource://gre/modules/TorParsers.sys.mjs"
    
    ... ... @@ -190,7 +189,7 @@ const gProvideBridgeDialog = {
    190 189
             "user-provide-bridge-dialog-next-button"
    
    191 190
           );
    
    192 191
         } else {
    
    193
    -      connect = TorConnect.canBeginBootstrap;
    
    192
    +      connect = TorConnect.stageName !== TorConnectStage.Bootstrapped;
    
    194 193
           this._acceptButton.setAttribute(
    
    195 194
             "data-l10n-id",
    
    196 195
             connect ? "bridge-dialog-button-connect" : "bridge-dialog-button-accept"
    

  • browser/components/torpreferences/content/requestBridgeDialog.js
    ... ... @@ -4,9 +4,8 @@ const { BridgeDB } = ChromeUtils.importESModule(
    4 4
       "resource://gre/modules/BridgeDB.sys.mjs"
    
    5 5
     );
    
    6 6
     
    
    7
    -const { TorConnect, TorConnectTopics } = ChromeUtils.importESModule(
    
    8
    -  "resource://gre/modules/TorConnect.sys.mjs"
    
    9
    -);
    
    7
    +const { TorConnect, TorConnectStage, TorConnectTopics } =
    
    8
    +  ChromeUtils.importESModule("resource://gre/modules/TorConnect.sys.mjs");
    
    10 9
     
    
    11 10
     const log = console.createInstance({
    
    12 11
       maxLogLevel: "Warn",
    
    ... ... @@ -102,7 +101,7 @@ const gRequestBridgeDialog = {
    102 101
       },
    
    103 102
     
    
    104 103
       onAcceptStateChange() {
    
    105
    -    const connect = TorConnect.canBeginBootstrap;
    
    104
    +    const connect = TorConnect.stageName !== TorConnectStage.Bootstrapped;
    
    106 105
         this._result.connect = connect;
    
    107 106
         this._submitButton.setAttribute(
    
    108 107
           "data-l10n-id",
    

  • toolkit/modules/TorConnect.sys.mjs
    ... ... @@ -13,6 +13,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
    13 13
       TorProviderTopics: "resource://gre/modules/TorProviderBuilder.sys.mjs",
    
    14 14
       TorLauncherUtil: "resource://gre/modules/TorLauncherUtil.sys.mjs",
    
    15 15
       TorSettings: "resource://gre/modules/TorSettings.sys.mjs",
    
    16
    +  TorSettingsTopics: "resource://gre/modules/TorSettings.sys.mjs",
    
    16 17
     });
    
    17 18
     
    
    18 19
     const TorConnectPrefs = Object.freeze({
    
    ... ... @@ -629,16 +630,6 @@ class AutoBootstrapAttempt {
    629 630
     
    
    630 631
         // Send the new settings directly to the provider. We will save them only
    
    631 632
         // if the bootstrap succeeds.
    
    632
    -    // FIXME: We should somehow signal TorSettings users that we have set
    
    633
    -    // custom settings, and they should not apply theirs until we are done
    
    634
    -    // with trying ours.
    
    635
    -    // Otherwise, the new settings provided by the user while we were
    
    636
    -    // bootstrapping could be the ones that cause the bootstrap to succeed,
    
    637
    -    // but we overwrite them (unless we backup the original settings, and then
    
    638
    -    // save our new settings only if they have not changed).
    
    639
    -    // Another idea (maybe easier to implement) is to disable the settings
    
    640
    -    // UI while *any* bootstrap is going on.
    
    641
    -    // This is also documented in tor-browser#41921.
    
    642 633
         await lazy.TorSettings.applyTemporaryBridges(bridges);
    
    643 634
     
    
    644 635
         if (this.#cancelled || this.#resolved) {
    
    ... ... @@ -1036,6 +1027,7 @@ export const TorConnect = {
    1036 1027
         // register the Tor topics we always care about
    
    1037 1028
         observeTopic(lazy.TorProviderTopics.ProcessExited);
    
    1038 1029
         observeTopic(lazy.TorProviderTopics.HasWarnOrErr);
    
    1030
    +    observeTopic(lazy.TorSettingsTopics.SettingsChanged);
    
    1039 1031
     
    
    1040 1032
         // NOTE: At this point, _requestedStage should still be `null`.
    
    1041 1033
         this._setStage(TorConnectStage.Start);
    
    ... ... @@ -1070,8 +1062,32 @@ export const TorConnect = {
    1070 1062
             Services.prefs.setBoolPref(TorConnectPrefs.prompt_at_startup, true);
    
    1071 1063
             this._makeStageRequest(TorConnectStage.Start, true);
    
    1072 1064
             break;
    
    1073
    -      default:
    
    1074
    -        // ignore
    
    1065
    +      case lazy.TorSettingsTopics.SettingsChanged:
    
    1066
    +        if (
    
    1067
    +          this._stageName !== TorConnectStage.Bootstrapped &&
    
    1068
    +          this._stageName !== TorConnectStage.Loading &&
    
    1069
    +          this._stageName !== TorConnectStage.Start &&
    
    1070
    +          subject.wrappedJSObject.changes.some(propertyName =>
    
    1071
    +            propertyName.startsWith("bridges.")
    
    1072
    +          )
    
    1073
    +        ) {
    
    1074
    +          // A change in bridge settings before we are bootstrapped, we reset
    
    1075
    +          // the stage to Start to:
    
    1076
    +          // + Cancel any ongoing bootstrap attempt. In particular, we
    
    1077
    +          //   definitely do not want to continue with an auto-bootstrap's
    
    1078
    +          //   temporary bridges if the settings have changed.
    
    1079
    +          // + Reset the UI to be ready for normal bootstrapping in case the
    
    1080
    +          //   user returns to about:torconnect.
    
    1081
    +          // See tor-browser#41921.
    
    1082
    +          // NOTE: We do not reset in response to a change in the quickstart,
    
    1083
    +          // firewall or proxy settings.
    
    1084
    +          lazy.logger.warn(
    
    1085
    +            "Resetting to Start stage since bridge settings changed"
    
    1086
    +          );
    
    1087
    +          // Rather than cancel and return to the pre-bootstrap stage, we
    
    1088
    +          // explicitly cancel and return to the start stage.
    
    1089
    +          this._makeStageRequest(TorConnectStage.Start);
    
    1090
    +        }
    
    1075 1091
             break;
    
    1076 1092
         }
    
    1077 1093
       },
    

  • toolkit/modules/TorSettings.sys.mjs
    ... ... @@ -953,6 +953,7 @@ class TorSettingsImpl {
    953 953
         };
    
    954 954
     
    
    955 955
         if ("bridges" in newValues) {
    
    956
    +      const changesLength = changes.length;
    
    956 957
           if ("source" in newValues.bridges) {
    
    957 958
             this.#fixupBridgeSettings(newValues.bridges);
    
    958 959
             changeSetting("bridges", "source", newValues.bridges.source);
    
    ... ... @@ -982,6 +983,19 @@ class TorSettingsImpl {
    982 983
           if ("enabled" in newValues.bridges) {
    
    983 984
             changeSetting("bridges", "enabled", newValues.bridges.enabled);
    
    984 985
           }
    
    986
    +
    
    987
    +      if (this.#temporaryBridgeSettings && changes.length !== changesLength) {
    
    988
    +        // A change in the bridges settings.
    
    989
    +        // We want to clear the temporary bridge settings to ensure that they
    
    990
    +        // cannot be used to overwrite these user-provided settings.
    
    991
    +        // See tor-browser#41921.
    
    992
    +        // NOTE: This should also trigger TorConnect to cancel any ongoing
    
    993
    +        // AutoBootstrap that would have otherwise used these settings.
    
    994
    +        this.#temporaryBridgeSettings = null;
    
    995
    +        lazy.logger.warn(
    
    996
    +          "Cleared temporary bridges since bridge settings were changed"
    
    997
    +        );
    
    998
    +      }
    
    985 999
         }
    
    986 1000
     
    
    987 1001
         if ("proxy" in newValues) {