[tor-commits] [tor-launcher/master] Bug 40012: Watch all requested tor events

sysrqb at torproject.org sysrqb at torproject.org
Wed Sep 15 18:09:27 UTC 2021


commit 1a94ea5f61dd456a5aec395337d030123938e58a
Author: Matthew Finkel <sysrqb at torproject.org>
Date:   Mon Aug 30 20:46:15 2021 +0000

    Bug 40012: Watch all requested tor events
---
 src/components/tl-protocol.js | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/components/tl-protocol.js b/src/components/tl-protocol.js
index ceb5a0c..cdf5894 100644
--- a/src/components/tl-protocol.js
+++ b/src/components/tl-protocol.js
@@ -643,9 +643,7 @@ TorProtocolService.prototype =
     }
 
     // TODO: optionally monitor INFO and DEBUG log messages.
-    var events = "STATUS_CLIENT NOTICE WARN ERR";
-    //var events = "STATUS_CLIENT WARN ERR";
-    var reply = await conn.sendCommand("SETEVENTS " + events);
+    var reply = await conn.sendCommand("SETEVENTS " + this.mEventMonitorEvents.join(' '));
     reply = this.TorParseCommandResponse(reply);
     if (!this.TorCommandSucceeded(reply))
     {
@@ -733,6 +731,7 @@ TorProtocolService.prototype =
   mEventMonitorConnection: null,
   mEventMonitorBuffer: null,
   mEventMonitorInProgressReply: null,
+  mEventMonitorEvents: ["STATUS_CLIENT", "NOTICE", "WARN", "ERR"],
   mTorLog: null,      // Array of objects with date, type, and msg properties.
 
   mCheckPasswordHash: false,  // set to true to perform a unit test
@@ -1287,9 +1286,11 @@ TorProtocolService.prototype =
       return;
 
     var _this = this;
-    this.mEventMonitorConnection.watchEvent("STATUS_CLIENT", null, function (data) { 
-        return _this._processEventData.bind(_this, data)();
-    }, true);
+    for (let torEvent in this.mEventMonitorEvents) {
+      this.mEventMonitorConnection.watchEvent(this.mEventMonitorEvents[torEvent], null, function (data) {
+          return _this._processEventData.bind(_this, data)();
+      }, true);
+    }
   },
 
   _processEventData: function(line)



More information about the tor-commits mailing list