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

fixup! Bug 40933: Add tor-launcher functionality

Deleted old stuff, unified TorController with ControlSocket, simplified
everything (e.g., do not use the dispatcher anymore, just call stuff
directly or use a much simpler map).
parent 6209a57c
No related branches found
Tags tor-0.1.0.5-rc
No related merge requests found
This diff is collapsed.
......@@ -356,37 +356,32 @@ export const TorMonitorService = {
_monitorEvent(type, callback) {
logger.info(`Watching events of type ${type}.`);
let replyObj = {};
this._connection.watchEvent(
type,
null,
line => {
if (!line) {
return;
}
logger.debug("Event response: ", line);
const isComplete = TorParsers.parseReplyLine(line, replyObj);
if (!isComplete) {
return;
}
const reply = replyObj;
replyObj = {};
if (reply.statusCode !== TorStatuses.EventNotification) {
logger.error("Unexpected event status code:", reply.statusCode);
return;
}
if (!reply.lineArray[0].startsWith(`${type} `)) {
logger.error("Wrong format for the first line:", reply.lineArray[0]);
return;
}
reply.lineArray[0] = reply.lineArray[0].substring(type.length + 1);
try {
callback(type, reply.lineArray);
} catch (e) {
logger.error("Exception while handling an event", reply, e);
}
},
true
);
this._connection.watchEvent(type, line => {
if (!line) {
return;
}
logger.debug("Event response: ", line);
const isComplete = TorParsers.parseReplyLine(line, replyObj);
if (!isComplete) {
return;
}
const reply = replyObj;
replyObj = {};
if (reply.statusCode !== TorStatuses.EventNotification) {
logger.error("Unexpected event status code:", reply.statusCode);
return;
}
if (!reply.lineArray[0].startsWith(`${type} `)) {
logger.error("Wrong format for the first line:", reply.lineArray[0]);
return;
}
reply.lineArray[0] = reply.lineArray[0].substring(type.length + 1);
try {
callback(type, reply.lineArray);
} catch (e) {
logger.error("Exception while handling an event", reply, e);
}
});
},
_processLog(type, lines) {
......
......@@ -181,11 +181,11 @@ export const TorParsers = Object.freeze({
return aStr;
}
const escaped = aStr
.replace("\\", "\\\\")
.replace('"', '\\"')
.replace("\n", "\\n")
.replace("\r", "\\r")
.replace("\t", "\\t")
.replaceAll("\\", "\\\\")
.replaceAll('"', '\\"')
.replaceAll("\n", "\\n")
.replaceAll("\r", "\\r")
.replaceAll("\t", "\\t")
.replace(/[^\x20-\x7e]+/g, text => {
const encoder = new TextEncoder();
return Array.from(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment