def _setup_vanguards(self):
     if not envtobool('TOR_ENABLE_VANGUARDS', False):
         return
     self.enable_control_port = True
     self.enable_vanguards = True
     os.environ.setdefault('TOR_CONTROL_PORT', self.control_socket)
     self.kill_tor_on_vanguard_exit = envtobool('VANGUARD_KILL_TOR_ON_EXIT',
                                                True)
     self.vanguards_state_file = os.path.join(self.data_directory,
                                              'vanguards.state')
    def _setup_control_port(self):
        if 'TOR_CONTROL_PORT' not in os.environ:
            return
        self.enable_control_port = True
        self._parse_control_port_variable()

        if os.environ.get('TOR_CONTROL_PASSWORD'):
            self._hash_control_port_password(
                os.environ['TOR_CONTROL_PASSWORD'])
        if envtobool('TOR_DATA_DIRECTORY', False):
            self.data_directory = os.environ['TOR_DATA_DIRECTORY']