[tor-commits] [torbutton/master] Bug 40046: Support arbitrary watch events
sysrqb at torproject.org
sysrqb at torproject.org
Wed Sep 15 18:10:28 UTC 2021
commit f3fa2a7aa0794f9ca5f6cd24b7e3feb85d3c7e53
Author: Matthew Finkel <sysrqb at torproject.org>
Date: Mon Aug 30 20:38:47 2021 +0000
Bug 40046: Support arbitrary watch events
---
modules/tor-control-port.js | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/modules/tor-control-port.js b/modules/tor-control-port.js
index c372c1ae..ef7bbe69 100644
--- a/modules/tor-control-port.js
+++ b/modules/tor-control-port.js
@@ -645,7 +645,6 @@ let event = {};
// data.
event.parsers = {
"stream" : info.streamStatusParser,
- "status_client" : (data) => data,
// Currently unused:
// "circ" : info.circuitStatusParser,
};
@@ -655,7 +654,7 @@ event.parsers = {
// we only extract streams that look like `"650" SP...`
event.messageToData = function (type, message) {
let dataText = message.match(/^650 \S+?\s(.*)/m)[1];
- return dataText ? event.parsers[type.toLowerCase()](dataText) : null;
+ return (dataText && type.toLowerCase() in event.parsers) ? event.parsers[type.toLowerCase()](dataText) : null;
};
// __event.watchEvent(controlSocket, type, filter, onData)__.
@@ -668,7 +667,7 @@ event.watchEvent = function (controlSocket, type, filter, onData, raw=false) {
function (message) {
let data = event.messageToData(type, message);
if (filter === null || filter(data)) {
- if (raw) {
+ if (raw || !data) {
return onData(message);
}
onData(data);
More information about the tor-commits
mailing list