Skip to content
Snippets Groups Projects
Verified Commit fa320027 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern:
Browse files

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.
parent c18bb66a
No related branches found
No related tags found
1 merge request!849Bug 42276: Rebase alpha onto 115.5.0esr
......@@ -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
......
......
......@@ -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
);
}
}
......@@ -15,7 +15,7 @@ export const TorProviderTopics = Object.freeze({
BootstrapError: "TorBootstrapError",
HasWarnOrErr: "TorLogHasWarnOrErr",
BridgeChanged: "TorBridgeChanged",
StreamSucceeded: "TorStreamSucceeded",
CircuitCredentialsMatched: "TorCircuitCredentialsMatched",
});
export const TorProviders = Object.freeze({
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment