[tbb-commits] [torbutton/master] Bug 30237: Control port module improvements for v3 client authentication

sysrqb at torproject.org sysrqb at torproject.org
Tue Feb 4 23:58:53 UTC 2020


commit 9dbc7d20a0efbe6d6d085950c937ed223176e6fa
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Wed Dec 4 09:41:18 2019 -0500

    Bug 30237: Control port module improvements for v3 client authentication
    
    Modify the Tor controller onionAuthAdd() function to remove support
    for the nickname parameter (not supported by tor) and add some
    missing parameter validation.
---
 modules/tor-control-port.js | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/modules/tor-control-port.js b/modules/tor-control-port.js
index 1b0a79ad..815df473 100644
--- a/modules/tor-control-port.js
+++ b/modules/tor-control-port.js
@@ -580,15 +580,21 @@ info.getConf = function (aControlSocket, key) {
 // A namespace for functions related to tor's ONION_CLIENT_AUTH_* commands.
 let onionAuth = {};
 
-// __onionAuth.add(controlSocket, hsAddress, b64PrivateKey, nickname, isPermanent)__.
+// __onionAuth.add(controlSocket, hsAddress, b64PrivateKey, isPermanent)__.
 // Sends a ONION_CLIENT_AUTH_ADD command to add a private key to the
 // Tor configuration.
 onionAuth.add = function (aControlSocket, hsAddress, b64PrivateKey,
-                          nickname, isPermanent) {
+                          isPermanent) {
+  if (!utils.isString(hsAddress)) {
+    return utils.rejectPromise("hsAddress argument should be a string");
+  }
+
+  if (!utils.isString(b64PrivateKey)) {
+    return utils.rejectPromise("b64PrivateKey argument should be a string");
+  }
+
   const keyType = "x25519";
   let cmd = `onion_client_auth_add ${hsAddress} ${keyType}:${b64PrivateKey}`;
-  if (nickname)
-    cmd += ` ClientName=${nickname}`;
   if (isPermanent)
     cmd += " Flags=Permanent";
   return aControlSocket.sendCommand(cmd);
@@ -649,9 +655,9 @@ tor.controller = function (ipcFile, host, port, password, onError) {
       isOpen = true;
   return { getInfo : key => info.getInfo(socket, key),
            getConf : key => info.getConf(socket, key),
-           onionAuthAdd : (hsAddress, b64PrivateKey, nickname, isPermanent) =>
+           onionAuthAdd : (hsAddress, b64PrivateKey, isPermanent) =>
                             onionAuth.add(socket, hsAddress, b64PrivateKey,
-                                          nickname, isPermanent),
+                                          isPermanent),
            watchEvent : (type, filter, onData) =>
                           event.watchEvent(socket, type, filter, onData),
            isOpen : () => isOpen,



More information about the tbb-commits mailing list