| ... |
... |
@@ -22,7 +22,9 @@ ChromeUtils.defineESModuleGetters(lazy, { |
|
22
|
22
|
AddonManager: "resource://gre/modules/AddonManager.sys.mjs",
|
|
23
|
23
|
AsyncShutdown: "resource://gre/modules/AsyncShutdown.sys.mjs",
|
|
24
|
24
|
DeferredTask: "resource://gre/modules/DeferredTask.sys.mjs",
|
|
25
|
|
- TorProviderBuilder: "resource://gre/modules/TorProviderBuilder.sys.mjs",
|
|
|
25
|
+ TorConnect: "resource://gre/modules/TorConnect.sys.mjs",
|
|
|
26
|
+ TorConnectStage: "resource://gre/modules/TorConnect.sys.mjs",
|
|
|
27
|
+ TorConnectTopics: "resource://gre/modules/TorConnect.sys.mjs",
|
|
26
|
28
|
UpdateLog: "resource://gre/modules/UpdateLog.sys.mjs",
|
|
27
|
29
|
UpdateUtils: "resource://gre/modules/UpdateUtils.sys.mjs",
|
|
28
|
30
|
WindowsRegistry: "resource://gre/modules/WindowsRegistry.sys.mjs",
|
| ... |
... |
@@ -372,15 +374,6 @@ export function testResetIsBackgroundTaskMode() { |
|
372
|
374
|
resetIsBackgroundTaskMode();
|
|
373
|
375
|
}
|
|
374
|
376
|
|
|
375
|
|
-async function _shouldRegisterBootstrapObserver() {
|
|
376
|
|
- try {
|
|
377
|
|
- const provider = await lazy.TorProviderBuilder.build();
|
|
378
|
|
- return !provider.isBootstrapDone && provider.ownsTorDaemon;
|
|
379
|
|
- } catch {
|
|
380
|
|
- return false;
|
|
381
|
|
- }
|
|
382
|
|
-}
|
|
383
|
|
-
|
|
384
|
377
|
/**
|
|
385
|
378
|
* Changes `nsIApplicationUpdateService.currentState` and causes
|
|
386
|
379
|
* `nsIApplicationUpdateService.stateTransition` to resolve.
|
| ... |
... |
@@ -2831,7 +2824,7 @@ export class UpdateService { |
|
2831
|
2824
|
case "network:offline-status-changed":
|
|
2832
|
2825
|
await this._offlineStatusChanged(data);
|
|
2833
|
2826
|
break;
|
|
2834
|
|
- case "torconnect:bootstrap-complete":
|
|
|
2827
|
+ case lazy.TorConnectTopics.BootstrapComplete:
|
|
2835
|
2828
|
this._bootstrapComplete();
|
|
2836
|
2829
|
break;
|
|
2837
|
2830
|
case "quit-application":
|
| ... |
... |
@@ -3447,7 +3440,36 @@ export class UpdateService { |
|
3447
|
3440
|
await this._attemptResume();
|
|
3448
|
3441
|
}
|
|
3449
|
3442
|
|
|
|
3443
|
+ /**
|
|
|
3444
|
+ * Whether we should wait for the Tor bootstrap event to try again because we
|
|
|
3445
|
+ * are not yet bootstrapped.
|
|
|
3446
|
+ *
|
|
|
3447
|
+ * If the browser does not monitor the Tor connection state, this will return
|
|
|
3448
|
+ * `false` since the event will never fire.
|
|
|
3449
|
+ *
|
|
|
3450
|
+ * @returns {boolean} - Whether we should wait for the bootstrap event.
|
|
|
3451
|
+ */
|
|
|
3452
|
+ _shouldRegisterBootstrapObserver() {
|
|
|
3453
|
+ return (
|
|
|
3454
|
+ lazy.TorConnect.enabled &&
|
|
|
3455
|
+ lazy.TorConnect.stageName !== lazy.TorConnectStage.Bootstrapped
|
|
|
3456
|
+ );
|
|
|
3457
|
+ }
|
|
|
3458
|
+
|
|
|
3459
|
+ /**
|
|
|
3460
|
+ * Wait for the Tor connection to be bootstrapped before trying again.
|
|
|
3461
|
+ */
|
|
3450
|
3462
|
_registerBootstrapObserver() {
|
|
|
3463
|
+ // Double check that we haven't since become bootstrapped between the call
|
|
|
3464
|
+ // to _shouldRegisterBootstrapObserver and _registerBootstrapObserver, which
|
|
|
3465
|
+ // may be delayed. If so, we do not wait for the BootstrapComplete signal
|
|
|
3466
|
+ // since it has already fired.
|
|
|
3467
|
+ if (lazy.TorConnect.stageName === lazy.TorConnectStage.Bootstrapped) {
|
|
|
3468
|
+ LOG("UpdateService:_registerBootstrapObserver - already bootstrapped");
|
|
|
3469
|
+ this._bootstrapComplete();
|
|
|
3470
|
+ return;
|
|
|
3471
|
+ }
|
|
|
3472
|
+
|
|
3451
|
3473
|
if (this._registeredBootstrapObserver) {
|
|
3452
|
3474
|
LOG(
|
|
3453
|
3475
|
"UpdateService:_registerBootstrapObserver - observer already registered"
|
| ... |
... |
@@ -3460,13 +3482,22 @@ export class UpdateService { |
|
3460
|
3482
|
"to be complete, then forcing another check"
|
|
3461
|
3483
|
);
|
|
3462
|
3484
|
|
|
3463
|
|
- Services.obs.addObserver(this, "torconnect:bootstrap-complete");
|
|
|
3485
|
+ Services.obs.addObserver(this, lazy.TorConnectTopics.BootstrapComplete);
|
|
3464
|
3486
|
this._registeredBootstrapObserver = true;
|
|
3465
|
3487
|
}
|
|
3466
|
3488
|
|
|
|
3489
|
+ /**
|
|
|
3490
|
+ * Called when the Tor connection becomes bootstrapped. This will trigger a
|
|
|
3491
|
+ * retry.
|
|
|
3492
|
+ */
|
|
3467
|
3493
|
_bootstrapComplete() {
|
|
3468
|
|
- Services.obs.removeObserver(this, "torconnect:bootstrap-complete");
|
|
3469
|
|
- this._registeredBootstrapObserver = false;
|
|
|
3494
|
+ if (this._registeredBootstrapObserver) {
|
|
|
3495
|
+ Services.obs.removeObserver(
|
|
|
3496
|
+ this,
|
|
|
3497
|
+ lazy.TorConnectTopics.BootstrapComplete
|
|
|
3498
|
+ );
|
|
|
3499
|
+ this._registeredBootstrapObserver = false;
|
|
|
3500
|
+ }
|
|
3470
|
3501
|
|
|
3471
|
3502
|
LOG(
|
|
3472
|
3503
|
"UpdateService:_bootstrapComplete - bootstrapping complete, forcing " +
|
| ... |
... |
@@ -3511,7 +3542,7 @@ export class UpdateService { |
|
3511
|
3542
|
return;
|
|
3512
|
3543
|
} else if (
|
|
3513
|
3544
|
update.errorCode === PROXY_SERVER_CONNECTION_REFUSED &&
|
|
3514
|
|
- (await _shouldRegisterBootstrapObserver())
|
|
|
3545
|
+ this._shouldRegisterBootstrapObserver()
|
|
3515
|
3546
|
) {
|
|
3516
|
3547
|
// Register boostrap observer to try again, but only when we own the
|
|
3517
|
3548
|
// tor process.
|
| ... |
... |
@@ -7105,7 +7136,7 @@ class Downloader { |
|
7105
|
7136
|
deleteActiveUpdate = false;
|
|
7106
|
7137
|
} else if (
|
|
7107
|
7138
|
status === PROXY_SERVER_CONNECTION_REFUSED &&
|
|
7108
|
|
- (await _shouldRegisterBootstrapObserver())
|
|
|
7139
|
+ this.updateService._shouldRegisterBootstrapObserver()
|
|
7109
|
7140
|
) {
|
|
7110
|
7141
|
// Register a bootstrap observer to try again.
|
|
7111
|
7142
|
// The bootstrap observer will continue the incremental download by
|