[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torbutton/master] Bug 40045: Teach the controller about status_client



commit 70ca32ee396a155c213feb2fd38fc97d9f6eab4f
Author: Matthew Finkel <sysrqb@xxxxxxxxxxxxxx>
Date:   Wed Aug 25 15:19:01 2021 +0000

    Bug 40045: Teach the controller about status_client
    
    In addition, the controller now can return raw messages instead of
    parsing them itself.
---
 modules/tor-control-port.js | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/modules/tor-control-port.js b/modules/tor-control-port.js
index 4215c763..c372c1ae 100644
--- a/modules/tor-control-port.js
+++ b/modules/tor-control-port.js
@@ -645,6 +645,7 @@ let event = {};
 // data.
 event.parsers = {
   "stream" : info.streamStatusParser,
+  "status_client" : (data) => data,
   // Currently unused:
   // "circ" : info.circuitStatusParser,
 };
@@ -662,11 +663,14 @@ event.messageToData = function (type, message) {
 // data is passed to the onData callback. Returns a zero arg function that
 // stops watching the event. Note: we only observe `"650" SP...` events
 // currently (no `650+...` or `650-...` events).
-event.watchEvent = function (controlSocket, type, filter, onData) {
+event.watchEvent = function (controlSocket, type, filter, onData, raw=false) {
   return controlSocket.addNotificationCallback(new RegExp("^650 " + type),
     function (message) {
       let data = event.messageToData(type, message);
       if (filter === null || filter(data)) {
+        if (raw) {
+          return onData(message);
+        }
         onData(data);
       }
     });
@@ -696,8 +700,8 @@ tor.controller = function (ipcFile, host, port, password, onError) {
                                           isPermanent),
            onionAuthRemove : (hsAddress) =>
                                onionAuth.remove(socket, hsAddress),
-           watchEvent : (type, filter, onData) =>
-                          event.watchEvent(socket, type, filter, onData),
+           watchEvent : (type, filter, onData, raw=false) =>
+                          event.watchEvent(socket, type, filter, onData, raw),
            isOpen : () => isOpen,
            close : () => { isOpen = false; socket.close(); },
            sendCommand: cmd => socket.sendCommand(cmd),



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits