Пример #1
0
 def __do_send(self):
     while True:
         data = self.__send_buffer.get_data(self.__send_marker)
         if data is None:
             # send complete; clear the internal buffer for next possible
             # send.
             logger.debug(logger.DBGLVL_TRACE_DETAIL,
                          PYSERVER_COMMON_DNS_TCP_SEND_DONE,
                          ClientFormatter(self.__remote_addr),
                          self.__send_marker)
             self.__send_buffer = None
             self.__send_marker = 0
             return self.SEND_DONE
         try:
             cc = self.__sock.send(data)
         except socket.error as ex:
             total_len = self.__send_buffer.get_total_len()
             if ex.errno == errno.EAGAIN:
                 logger.debug(logger.DBGLVL_TRACE_DETAIL,
                              PYSERVER_COMMON_DNS_TCP_SEND_PENDING,
                              ClientFormatter(self.__remote_addr),
                              self.__send_marker, total_len)
                 return self.SENDING
             logger.warn(PYSERVER_COMMON_DNS_TCP_SEND_ERROR,
                         ClientFormatter(self.__remote_addr),
                         self.__send_marker, total_len, ex)
             self.__sock.close()
             self.__sock = None
             return self.CLOSED
         self.__send_marker += cc
Пример #2
0
 def deinit(self):
     """
     Unregister from getting updates. The object will not be
     usable any more after this.
     """
     logger.debug(logger.DBGLVL_TRACE_BASIC,
                  PYSERVER_COMMON_TSIG_KEYRING_DEINIT)
     self.__session.remove_remote_config('tsig_keys')
Пример #3
0
    def _command_handler(self, cmd, args):
        logger.debug(logger.DBGLVL_TRACE_BASIC, PYSERVER_COMMON_COMMAND,
                     self.__module_name, cmd)
        if cmd == 'shutdown':
            self._trigger_shutdown()
            answer = isc.config.create_answer(0)
        else:
            answer = self._mod_command_handler(cmd, args)

        return answer
Пример #4
0
 def __init__(self, session):
     """
     Constructor. Pass the ccsession object so the key ring can be
     downloaded.
     """
     logger.debug(logger.DBGLVL_TRACE_BASIC,
                  PYSERVER_COMMON_TSIG_KEYRING_INIT)
     self.__session = session
     self.__keyring = isc.dns.TSIGKeyRing()
     session.add_remote_config_by_name('tsig_keys', self.__update)
     self.__update()
Пример #5
0
    def __update(self, value=None, module_cfg=None):
        """
        Update the key ring by the configuration.

        Note that this function is used as a callback, but can raise
        on bad data. The bad data is expected to be handled by the
        configuration plugin and not be allowed as far as here.

        The parameters are there just to match the signature which
        the callback should have (i.e. they are ignored).
        """
        logger.debug(logger.DBGLVL_TRACE_BASIC,
                     PYSERVER_COMMON_TSIG_KEYRING_UPDATE)
        (data, _) = self.__session.get_remote_config_value('tsig_keys', 'keys')
        if data is not None: # There's an update
            keyring = isc.dns.TSIGKeyRing()
            for key_data in data:
                key = isc.dns.TSIGKey(key_data)
                if keyring.add(key) != isc.dns.TSIGKeyRing.SUCCESS:
                    raise AddError("Can't add key " + str(key))
            self.__keyring = keyring