Loading toolkit/components/tor-launcher/TorDomainIsolator.jsm +23 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,12 @@ XPCOMUtils.defineLazyServiceGetters(this, { ], }); ChromeUtils.defineModuleGetter( this, "TorProtocolService", "resource://gre/modules/TorProtocolService.jsm" ); const logger = new ConsoleAPI({ prefix: "TorDomainIsolator", maxLogLevel: "warn", Loading @@ -31,6 +37,9 @@ const CATCHALL_DOMAIN = "--unknown--"; // disabled. const NON_TOR_PROXY_PREF = "extensions.torbutton.use_nontor_proxy"; // The topic of new identity, to observe to cleanup all the nonces. const NEW_IDENTITY_TOPIC = "new-identity-requested"; class TorDomainIsolatorImpl { // A mutable map that records what nonce we are using for each domain. #noncesForDomains = new Map(); Loading Loading @@ -58,6 +67,7 @@ class TorDomainIsolatorImpl { this.#setupProxyFilter(); Services.prefs.addObserver(NON_TOR_PROXY_PREF, this); Services.obs.addObserver(this, NEW_IDENTITY_TOPIC); } /** Loading @@ -65,6 +75,7 @@ class TorDomainIsolatorImpl { */ uninit() { Services.prefs.removeObserver(NON_TOR_PROXY_PREF, this); Services.obs.removeObserver(this, NEW_IDENTITY_TOPIC); } enable() { Loading Loading @@ -152,13 +163,24 @@ class TorDomainIsolatorImpl { this.#catchallDirtySince = 0; } observe(subject, topic, data) { async observe(subject, topic, data) { if (topic === "nsPref:changed" && data === NON_TOR_PROXY_PREF) { if (Services.prefs.getBoolPref(NON_TOR_PROXY_PREF)) { this.disable(); } else { this.enable(); } } else if (topic === NEW_IDENTITY_TOPIC) { logger.info( "New identity has been requested, clearing isolation tokens." ); this.clearIsolation(); try { await TorProtocolService.newnym(); } catch (e) { logger.error("Could not send the newnym command", e); // TODO: What UX to use here? See tor-browser#41708 } } } Loading Loading
toolkit/components/tor-launcher/TorDomainIsolator.jsm +23 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,12 @@ XPCOMUtils.defineLazyServiceGetters(this, { ], }); ChromeUtils.defineModuleGetter( this, "TorProtocolService", "resource://gre/modules/TorProtocolService.jsm" ); const logger = new ConsoleAPI({ prefix: "TorDomainIsolator", maxLogLevel: "warn", Loading @@ -31,6 +37,9 @@ const CATCHALL_DOMAIN = "--unknown--"; // disabled. const NON_TOR_PROXY_PREF = "extensions.torbutton.use_nontor_proxy"; // The topic of new identity, to observe to cleanup all the nonces. const NEW_IDENTITY_TOPIC = "new-identity-requested"; class TorDomainIsolatorImpl { // A mutable map that records what nonce we are using for each domain. #noncesForDomains = new Map(); Loading Loading @@ -58,6 +67,7 @@ class TorDomainIsolatorImpl { this.#setupProxyFilter(); Services.prefs.addObserver(NON_TOR_PROXY_PREF, this); Services.obs.addObserver(this, NEW_IDENTITY_TOPIC); } /** Loading @@ -65,6 +75,7 @@ class TorDomainIsolatorImpl { */ uninit() { Services.prefs.removeObserver(NON_TOR_PROXY_PREF, this); Services.obs.removeObserver(this, NEW_IDENTITY_TOPIC); } enable() { Loading Loading @@ -152,13 +163,24 @@ class TorDomainIsolatorImpl { this.#catchallDirtySince = 0; } observe(subject, topic, data) { async observe(subject, topic, data) { if (topic === "nsPref:changed" && data === NON_TOR_PROXY_PREF) { if (Services.prefs.getBoolPref(NON_TOR_PROXY_PREF)) { this.disable(); } else { this.enable(); } } else if (topic === NEW_IDENTITY_TOPIC) { logger.info( "New identity has been requested, clearing isolation tokens." ); this.clearIsolation(); try { await TorProtocolService.newnym(); } catch (e) { logger.error("Could not send the newnym command", e); // TODO: What UX to use here? See tor-browser#41708 } } } Loading