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

[tor-commits] [chutney/master] Merge remote-tracking branch 'tor-github/pr/66'



commit 99bd06c7554b9113af8c0877b6eca4ceb95dcbaa
Merge: bc6015c f43449e
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue Jul 7 11:12:41 2020 -0400

    Merge remote-tracking branch 'tor-github/pr/66'

 lib/chutney/TorNet.py | 107 +++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 84 insertions(+), 23 deletions(-)

diff --cc lib/chutney/TorNet.py
index 98ccc45,6f71963..37bef04
--- a/lib/chutney/TorNet.py
+++ b/lib/chutney/TorNet.py
@@@ -869,51 -851,9 +869,53 @@@ class LocalNodeController(NodeControlle
      def __init__(self, env):
          NodeController.__init__(self, env)
          self._env = env
+         self.most_recent_oniondesc_status = None
+         self.most_recent_bootstrap_status = None
  
 +    def _loadEd25519Id(self):
 +        """
 +           Read the ed25519 identity key for this router, encode it using
 +           base64, strip trailing padding, and return it.
 +
 +           If the file does not exist, returns None.
 +
 +           Raises a ValueError if the file appears to be corrupt.
 +        """
 +        datadir = self._env['dir']
 +        key_file = os.path.join(datadir, 'keys',
 +                                "ed25519_master_id_public_key")
 +        # If we're called early during bootstrap, the file won't have been
 +        # created yet. (And some very old tor versions don't have ed25519.)
 +        if not os.path.exists(key_file):
 +            debug(("File {} does not exist. Are you running a very old tor "
 +                   "version?").format(key_file))
 +            return None
 +
 +        EXPECTED_ED25519_FILE_SIZE = 64
 +        key_file_size = os.stat(key_file).st_size
 +        if key_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(key_file_size, EXPECTED_ED25519_FILE_SIZE))
 +
 +        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)
 +            # tor strips trailing base64 padding
 +            ed25519_id = encoded_value.decode('utf-8').replace('=', '')
 +            EXPECTED_ED25519_BASE64_KEY_SIZE = 43
 +            key_base64_size = len(ed25519_id)
 +            if (key_base64_size != EXPECTED_ED25519_BASE64_KEY_SIZE):
 +                raise ValueError(
 +                    ("The current length of the key is {}, which is not "
 +                     "matching the expected length of {}")
 +                    .format(key_base64_size,
 +                            EXPECTED_ED25519_BASE64_KEY_SIZE))
 +            return ed25519_id
 +
      def getNick(self):
          """Return the nickname for this node."""
          return self._env['nick']
@@@ -1045,23 -958,19 +1047,23 @@@
          """Returns the amount of time to wait before verifying, after the
             network has bootstrapped, and the dir info has been distributed.
  
 -           Based on whether this node is an onion service.
 +           Based on whether this node has unchecked directory info, or other
 +           known timing issues.
          """
-         if self.getOnionService():
+         if self.isOnionService():
              return LocalNodeController.HS_WAIT_FOR_UNCHECKED_DIR_INFO
 +        elif self.getBridge():
 +            return LocalNodeController.BRIDGE_WAIT_FOR_UNCHECKED_DIR_INFO
 +        elif self.isLegacyTorVersion():
 +            return LocalNodeController.LEGACY_WAIT_FOR_UNCHECKED_DIR_INFO
          else:
 -            return LocalNodeController.NODE_WAIT_FOR_UNCHECKED_DIR_INFO
 +            return LocalNodeController.DEFAULT_WAIT_FOR_UNCHECKED_DIR_INFO
  
      def getPid(self):
 -        """Assuming that this node has its pidfile in ${dir}/pid, return
 -           the pid of the running process, or None if there is no pid in the
 -           file.
 +        """Read the pidfile, and return the pid of the running process.
 +           Returns None if there is no pid in the file.
          """
 -        pidfile = os.path.join(self._env['dir'], 'pid')
 +        pidfile = self._env['pidfile']
          if not os.path.exists(pidfile):
              return None
  

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