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

[tor-commits] [chutney/master] moving the function _setEdd25519ID in LocalNodeController



commit 6ca1d79cc25efc971a50f1f0ab8a4aa1da2a578b
Author: ANURADHAJHA99 <anuradha750871@xxxxxxxxx>
Date:   Thu Apr 9 18:16:55 2020 +0530

    moving the function _setEdd25519ID in LocalNodeController
---
 lib/chutney/TorNet.py | 54 +++++++++++++++++++++++++--------------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py
index f6e44b4..706027a 100644
--- a/lib/chutney/TorNet.py
+++ b/lib/chutney/TorNet.py
@@ -666,7 +666,7 @@ class LocalNodeBuilder(NodeBuilder):
             self._genAuthorityKey()
         if self._env['relay']:
             self._genRouterKey()
-            self._setEd25519Id()
+            #self._setEd25519Id()
         if self._env['hs']:
             self._makeHiddenServiceDir()
 
@@ -763,31 +763,6 @@ class LocalNodeBuilder(NodeBuilder):
             sys.exit(1)
         self._env['fingerprint'] = fingerprint
         
-    def _setEd25519Id(self):
-        """Read the ed25519 identity key for this router, and set up the 'ed25519-id' entry in the Environ"""
-        datadir = self._env['dir']
-        key_file = os.path.join(datadir, 'keys', "ed25519_master_id_public_key")
-        EXPECTED_ED25519_FILE_SIZE = 64
-        CURRENT_FILE_SIZE = os.stat(key_file).st_size
-        if not os.path.exists(key_file):
-            print("File {} does not exist. Are you running a very old tor version?".format(key_file))
-            return
-        elif CURRENT_FILE_SIZE != EXPECTED_ED25519_FILE_SIZE:
-            raise ValueError("The current size of the file is {} bytes, which is not matching the expected value of {} bytes".format(CURRENT_FILE_SIZE, EXPECTED_ED25519_FILE_SIZE))
-        else:
-            with open(key_file, 'rb') as f:
-                ED25519_KEY_POSITION = 32
-                f.seek(ED25519_KEY_POSITION)
-                rest_file = f.read()
-                encoded_value = base64.b64encode(rest_file)
-                ed25519_id = encoded_value.decode('utf-8').replace('=', '')
-                EXPECTED_ED25519_BASE64_KEY_SIZE = 43
-                CURRENT_ED25519_BASE64_KEY_SIZE = len(ed25519_id)
-                if CURRENT_ED25519_BASE64_KEY_SIZE != EXPECTED_ED25519_BASE64_KEY_SIZE:
-                    raise ValueError("The current length of the key is {}, which is not matching the expected length of {}".format(CURRENT_ED25519_BASE64_KEY_SIZE, EXPECTED_ED25519_BASE64_KEY_SIZE))
-                else:
-                    self._env['ed25519_id'] = ed25519_id
-    
     def _getAltAuthLines(self, hasbridgeauth=False):
         """Return a combination of AlternateDirAuthority,
         and AlternateBridgeAuthority lines for
@@ -871,7 +846,32 @@ class LocalNodeBuilder(NodeBuilder):
 
 
 class LocalNodeController(NodeController):
-
+    
+    def _setEd25519Id(self):
+        """Read the ed25519 identity key for this router, and set up the 'ed25519-id' entry in the Environ"""
+        datadir = self._env['dir']
+        key_file = os.path.join(datadir, 'keys', "ed25519_master_id_public_key")
+        EXPECTED_ED25519_FILE_SIZE = 64
+        CURRENT_FILE_SIZE = os.stat(key_file).st_size
+        if not os.path.exists(key_file):
+            print("File {} does not exist. Are you running a very old tor version?".format(key_file))
+            return
+        elif CURRENT_FILE_SIZE != EXPECTED_ED25519_FILE_SIZE:
+            raise ValueError("The current size of the file is {} bytes, which is not matching the expected value of {} bytes".format(CURRENT_FILE_SIZE, EXPECTED_ED25519_FILE_SIZE))
+        else:
+            with open(key_file, 'rb') as f:
+                ED25519_KEY_POSITION = 32
+                f.seek(ED25519_KEY_POSITION)
+                rest_file = f.read()
+                encoded_value = base64.b64encode(rest_file)
+                ed25519_id = encoded_value.decode('utf-8').replace('=', '')
+                EXPECTED_ED25519_BASE64_KEY_SIZE = 43
+                CURRENT_ED25519_BASE64_KEY_SIZE = len(ed25519_id)
+                if CURRENT_ED25519_BASE64_KEY_SIZE != EXPECTED_ED25519_BASE64_KEY_SIZE:
+                    raise ValueError("The current length of the key is {}, which is not matching the expected length of {}".format(CURRENT_ED25519_BASE64_KEY_SIZE, EXPECTED_ED25519_BASE64_KEY_SIZE))
+                else:
+                    self._env['ed25519_id'] = ed25519_id
+    
     def __init__(self, env):
         NodeController.__init__(self, env)
         self._env = env



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