Esempio n. 1
0
 def __init__(self, sock, addr):
     global thread_cnt
     thread_cnt += 1
     self.t0 = time.time()
     print('initing SSS -> %2d      %s' % (thread_cnt, str(addr)))
     #    asynchat.async_chat.__init__(self, *args)
     asynchat.async_chat.__init__(self, sock)
     self.__milter_dispatcher = ppymilterbase.PpyMilterDispatcher(MyHandler)
     self.data = None
     self.set_terminator(MILTER_LEN_BYTES)
     self.milterstate = False
Esempio n. 2
0
    def __init__(self, conn, addr, milter_class):
      """A connection handling class to manage communication on this socket.

      Args:
        conn: The socket connection object.
        addr: The address (port/ip) as returned by socket.accept()
        milter_class: A class (not an instance) that handles callbacks for
                      milter commands (e.g. a child of the PpyMilter class).
      """
      asynchat.async_chat.__init__(self, conn)
      self.__conn = conn
      self.__addr = addr
      self.__milter_dispatcher = ppymilterbase.PpyMilterDispatcher(milter_class)
      self.__input = []
      self.set_terminator(MILTER_LEN_BYTES)
      self.found_terminator = self.read_packetlen
Esempio n. 3
0
 def __init__(self, socket, address, **kw):
     logging.info('vvvv New connection from %s:%s' % address)
     if self.sockfile is not None:
         logging.info(" === closing existing socketfile")
         self.sockfile.close()
     self.sockfile = socket.makefile()
     self._dispatch = ppymilterbase.PpyMilterDispatcher(self.handler)
     try:
         while True:
             data = self._read()
             if data is None or data == '':
                 break;
             response = self._dispatch.Dispatch(data)
             if type(response) == list:
                 for r in response:
                     self._send(r)
             elif response:
                 self._send(response)
     except PpyMilterCloseConnection:
         self.sockfile.close()
         self.sockfile = None
     except Exception, e:
         logging.error('Unhandled Exception %s' % repr(e))
Esempio n. 4
0
 def setup(self):
     self.request.setblocking(True)
     self.__milter_dispatcher = ppymilterbase.PpyMilterDispatcher(
         self.server.milter_class, self.server.handle_error,
         self.server.context)
Esempio n. 5
0
 def setup(self):
   self.request.setblocking(True)
   self.__milter_dispatcher = ppymilterbase.PpyMilterDispatcher(
       self.server.milter_class)