... |
... |
@@ -612,8 +612,7 @@ class TorSettingsImpl { |
612
|
612
|
this.#settings.bridges.source === TorBridgeSource.Lox
|
613
|
613
|
) {
|
614
|
614
|
// Re-trigger the call to lazy.Lox.getBridges.
|
615
|
|
- // FIXME: This can compete with TorConnect to reach TorProvider.
|
616
|
|
- // tor-browser#42316
|
|
615
|
+ // FIXME: This can cancel a bootstrap. tor-browser#43991.
|
617
|
616
|
this.changeSettings({
|
618
|
617
|
bridges: {
|
619
|
618
|
source: TorBridgeSource.Lox,
|
... |
... |
@@ -767,14 +766,11 @@ class TorSettingsImpl { |
767
|
766
|
}
|
768
|
767
|
|
769
|
768
|
/**
|
770
|
|
- * Save our settings to prefs.
|
|
769
|
+ * Save our bridge settings.
|
771
|
770
|
*/
|
772
|
|
- #saveToPrefs() {
|
773
|
|
- lazy.logger.debug("saveToPrefs()");
|
|
771
|
+ #saveBridgeSettings() {
|
|
772
|
+ lazy.logger.debug("Saving bridge settings");
|
774
|
773
|
|
775
|
|
- this.#checkIfInitialized();
|
776
|
|
-
|
777
|
|
- /* Bridges */
|
778
|
774
|
Services.prefs.setBoolPref(
|
779
|
775
|
TorSettingsPrefs.bridges.enabled,
|
780
|
776
|
this.#settings.bridges.enabled
|
... |
... |
@@ -812,7 +808,14 @@ class TorSettingsImpl { |
812
|
808
|
);
|
813
|
809
|
});
|
814
|
810
|
}
|
815
|
|
- /* Proxy */
|
|
811
|
+ }
|
|
812
|
+
|
|
813
|
+ /**
|
|
814
|
+ * Save our proxy settings.
|
|
815
|
+ */
|
|
816
|
+ #saveProxySettings() {
|
|
817
|
+ lazy.logger.debug("Saving proxy settings");
|
|
818
|
+
|
816
|
819
|
Services.prefs.setBoolPref(
|
817
|
820
|
TorSettingsPrefs.proxy.enabled,
|
818
|
821
|
this.#settings.proxy.enabled
|
... |
... |
@@ -845,7 +848,14 @@ class TorSettingsImpl { |
845
|
848
|
Services.prefs.clearUserPref(TorSettingsPrefs.proxy.username);
|
846
|
849
|
Services.prefs.clearUserPref(TorSettingsPrefs.proxy.password);
|
847
|
850
|
}
|
848
|
|
- /* Firewall */
|
|
851
|
+ }
|
|
852
|
+
|
|
853
|
+ /**
|
|
854
|
+ * Save our firewall settings.
|
|
855
|
+ */
|
|
856
|
+ #saveFirewallSettings() {
|
|
857
|
+ lazy.logger.debug("Saving firewall settings");
|
|
858
|
+
|
849
|
859
|
Services.prefs.setBoolPref(
|
850
|
860
|
TorSettingsPrefs.firewall.enabled,
|
851
|
861
|
this.#settings.firewall.enabled
|
... |
... |
@@ -1403,7 +1413,32 @@ class TorSettingsImpl { |
1403
|
1413
|
|
1404
|
1414
|
// No errors so far, so save and commit.
|
1405
|
1415
|
this.#settings = completeSettings;
|
1406
|
|
- this.#saveToPrefs();
|
|
1416
|
+ // NOTE: We want to avoid overwriting saved preference values unless the
|
|
1417
|
+ // user actually makes a change in their settings.
|
|
1418
|
+ // In particular, if we fail to load a setting at startup due to a bug, the
|
|
1419
|
+ // #settings object for that group will point to the #defaultSettings value
|
|
1420
|
+ // instead. We do not want to write these #defaultSettings to the user's
|
|
1421
|
+ // settings unless the user actually makes a change in one of the groups.
|
|
1422
|
+ // E.g. we do not want a change in the proxy settings to overwrite the
|
|
1423
|
+ // saved bridge settings. Hence, we only save the groups that have changes.
|
|
1424
|
+ // See tor-browser#43766.
|
|
1425
|
+ // NOTE: We could go more fine-grained and only save the preference values
|
|
1426
|
+ // that actually change. E.g. only save the bridges.enabled pref when the
|
|
1427
|
+ // user switches the toggle, and leave the bridges.bridge_strings as they
|
|
1428
|
+ // are. However, at the time of implementation there is no known benefit to
|
|
1429
|
+ // doing this, since the #defaultSettings will not allow for any changes
|
|
1430
|
+ // that don't require changing the group entirely. E.g. to change
|
|
1431
|
+ // bridges.enabled when starting with the #defaultSettings.bridges,
|
|
1432
|
+ // bridges.bridge_strings must necessarily be set.
|
|
1433
|
+ if (apply.bridges) {
|
|
1434
|
+ this.#saveBridgeSettings();
|
|
1435
|
+ }
|
|
1436
|
+ if (apply.proxy) {
|
|
1437
|
+ this.#saveProxySettings();
|
|
1438
|
+ }
|
|
1439
|
+ if (apply.firewall) {
|
|
1440
|
+ this.#saveFirewallSettings();
|
|
1441
|
+ }
|
1407
|
1442
|
|
1408
|
1443
|
if (changes.length) {
|
1409
|
1444
|
Services.obs.notifyObservers(
|