iredapd / src / iredapd-rr.py

Diff from to

src/iredapd-rr.py

 from libs import __version__, SMTP_ACTIONS
 
 class apd_channel(asynchat.async_chat):
-    def __init__(self, conn, remoteaddr):
+    def __init__(self, conn, remote_addr):
         asynchat.async_chat.__init__(self, conn)
+        self.remote_addr = remote_addr
         self.buffer = []
         self.map = {}
         self.set_terminator('\n')
-        logging.debug("Connect from " + remoteaddr[0])
+        logging.debug("Connect from %s, port %s." % self.remote_addr)
 
     def push(self, msg):
         asynchat.async_chat.push(self, msg + '\n')
                 logging.debug('Error: %s. Use default action instead: %s' %
                         (str(e), str(action)))
 
-            logging.info('%s -> %s, %s' %
-                    (self.map['sender'], self.map['recipient'], action))
-            self.push('action=' + action)
-            self.push('')
+            # Log final action.
+            logging.info('[%s] %s -> %s, %s' % (self.map['client_address'],
+                                                self.map['sender'],
+                                                self.map['recipient'],
+                                                action,
+                                               ))
+
+            self.push('action=' + action + '\n')
             asynchat.async_chat.handle_close(self)
             logging.debug("Connection closed")
         else:
             action = SMTP_ACTIONS['defer']
             logging.debug("replying: " + action)
-            self.push(action)
-            self.push('')
+            self.push(action + '\n')
             asynchat.async_chat.handle_close(self)
             logging.debug("Connection closed")
 
                 (__version__, os.getpid(), ip, str(port)))
 
     def handle_accept(self):
-        conn, remoteaddr = self.accept()
-        channel = apd_channel(conn, remoteaddr)
+        conn, remote_addr = self.accept()
+        channel = apd_channel(conn, remote_addr)
 
 
 class SQLModeler:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.