Pier Angelo Vendrame pushed to branch tor-browser-115.4.0esr-13.0-1 at The Tor Project / Applications / Tor Browser
Commits: 2f901371 by Pier Angelo Vendrame at 2023-11-13T17:55:50+01:00 fixup! Bug 40933: Add tor-launcher functionality
Bug 42108: Use the sentconnect event to update the circuit display
In this way, the circuit might be updated more often, because some circuits will not work for some sites, but it might be what users want, especially when the browser fails and you would like to know the exit node that has been blocked.
- - - - - 934aa459 by Pier Angelo Vendrame at 2023-11-13T17:55:51+01:00 fixup! Bug 3455: Add DomainIsolator, for isolating circuit by domain.
Bug 42108: Use the sentconnect event to update the circuit display
Use the new topic name in the domain isolator.
- - - - -
4 changed files:
- toolkit/components/tor-launcher/TorControlPort.sys.mjs - toolkit/components/tor-launcher/TorDomainIsolator.sys.mjs - toolkit/components/tor-launcher/TorProvider.sys.mjs - toolkit/components/tor-launcher/TorProviderBuilder.sys.mjs
Changes:
===================================== toolkit/components/tor-launcher/TorControlPort.sys.mjs ===================================== @@ -1043,15 +1043,15 @@ export class TorController { } break; case "STREAM": - const succeeedEvent = - /^(?<StreamID>[a-zA-Z0-9]{1,16})\sSUCCEEDED\s(?<CircuitID>[a-zA-Z0-9]{1,16})/.exec( + const sentConnectEvent = + /^(?<StreamID>[a-zA-Z0-9]{1,16})\sSENTCONNECT\s(?<CircuitID>[a-zA-Z0-9]{1,16})/.exec( data.groups.data ); - if (succeeedEvent) { + if (sentConnectEvent) { const credentials = this.#parseCredentials(data.groups.data); - this.#eventHandler.onStreamSucceeded( - succeeedEvent.groups.StreamID, - succeeedEvent.groups.CircuitID, + this.#eventHandler.onStreamSentConnect( + sentConnectEvent.groups.StreamID, + sentConnectEvent.groups.CircuitID, credentials?.username ?? null, credentials?.password ?? null ); @@ -1190,8 +1190,9 @@ export class TorController { * (i.e., a CIRC event with a BUILT status) * @property {OnCircuitClosed} onCircuitClosed Called when a circuit is closed * (i.e., a CIRC event with a CLOSED status) - * @property {OnStreamSucceeded} onStreamSucceeded Called when a stream receives - * a reply (i.e., a STREAM event with a SUCCEEDED status) + * @property {OnStreamSentConnect} onStreamSentConnect Called when a stream sent + * a connect cell along a circuit (i.e., a STREAM event with a SENTCONNECT + * status) */ /** * @callback OnBootstrapStatus @@ -1217,7 +1218,7 @@ export class TorController { * @param {CircuitID} id The id of the circuit that has been closed */ /** - * @callback OnStreamSucceeded + * @callback OnStreamSentConnect * * @param {StreamID} streamId The id of the stream that switched to the succeeded * state
===================================== toolkit/components/tor-launcher/TorDomainIsolator.sys.mjs ===================================== @@ -146,7 +146,10 @@ class TorDomainIsolatorImpl {
Services.prefs.addObserver(NON_TOR_PROXY_PREF, this); Services.obs.addObserver(this, NEW_IDENTITY_TOPIC); - Services.obs.addObserver(this, lazy.TorProviderTopics.StreamSucceeded); + Services.obs.addObserver( + this, + lazy.TorProviderTopics.CircuitCredentialsMatched + );
this.#cleanupIntervalId = setInterval( this.#clearKnownCircuits.bind(this), @@ -161,7 +164,10 @@ class TorDomainIsolatorImpl { uninit() { Services.prefs.removeObserver(NON_TOR_PROXY_PREF, this); Services.obs.removeObserver(this, NEW_IDENTITY_TOPIC); - Services.obs.removeObserver(this, lazy.TorProviderTopics.StreamSucceeded); + Services.obs.removeObserver( + this, + lazy.TorProviderTopics.CircuitCredentialsMatched + ); clearInterval(this.#cleanupIntervalId); this.#cleanupIntervalId = null; this.clearIsolation(); @@ -266,7 +272,7 @@ class TorDomainIsolatorImpl { logger.error("Could not send the newnym command", e); // TODO: What UX to use here? See tor-browser#41708 } - } else if (topic === lazy.TorProviderTopics.StreamSucceeded) { + } else if (topic === lazy.TorProviderTopics.CircuitCredentialsMatched) { const { username, password, circuit } = subject.wrappedJSObject; this.#updateCircuit(username, password, circuit); }
===================================== toolkit/components/tor-launcher/TorProvider.sys.mjs ===================================== @@ -991,19 +991,19 @@ export class TorProvider { }
/** - * Handle a notification about a stream switching to the succeeded state. + * Handle a notification about a stream switching to the sentconnect status. * * @param {StreamID} streamId The ID of the stream that switched to the - * succeeded state. + * sentconnect status. * @param {CircuitID} circuitId The ID of the circuit used by the stream * @param {string} username The SOCKS username * @param {string} password The SOCKS password */ - async onStreamSucceeded(streamId, circuitId, username, password) { + async onStreamSentConnect(streamId, circuitId, username, password) { if (!username || !password) { return; } - logger.debug("Stream succeeded event", username, password, circuitId); + logger.debug("Stream sentconnect event", username, password, circuitId); let circuit = this.#circuits.get(circuitId); if (!circuit) { circuit = new Promise((resolve, reject) => { @@ -1017,7 +1017,7 @@ export class TorProvider { this.#circuits.set(id, nodes); } logger.error( - `Seen a STREAM SUCCEEDED with circuit ${circuitId}, but Tor did not send information about it.` + `Seen a STREAM SENTCONNECT with circuit ${circuitId}, but Tor did not send information about it.` ); reject(); }); @@ -1037,7 +1037,7 @@ export class TorProvider { circuit, }, }, - TorProviderTopics.StreamSucceeded + TorProviderTopics.CircuitCredentialsMatched ); } }
===================================== toolkit/components/tor-launcher/TorProviderBuilder.sys.mjs ===================================== @@ -15,7 +15,7 @@ export const TorProviderTopics = Object.freeze({ BootstrapError: "TorBootstrapError", HasWarnOrErr: "TorLogHasWarnOrErr", BridgeChanged: "TorBridgeChanged", - StreamSucceeded: "TorStreamSucceeded", + CircuitCredentialsMatched: "TorCircuitCredentialsMatched", });
export const TorProviders = Object.freeze({
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/20f764b...
tbb-commits@lists.torproject.org