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

[minion-cvs] Untested) support for REJECTED MMTP response



Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv23067/src/minion/lib/mixminion/server

Modified Files:
	MMTPServer.py 
Log Message:
(Untested) support for REJECTED MMTP response

Index: MMTPServer.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/MMTPServer.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- MMTPServer.py	18 Apr 2003 18:32:36 -0000	1.23
+++ MMTPServer.py	22 Apr 2003 01:45:22 -0000	1.24
@@ -510,6 +510,8 @@
 JUNK_CONTROL         = "JUNK\r\n"
 # Control line for acknowledging a message
 RECEIVED_CONTROL     = "RECEIVED\r\n"
+# Control line for refusing a message
+REJECTED_CONTROL     = "REJECTED\r\n"
 SEND_CONTROL_LEN     = len(SEND_CONTROL)
 RECEIVED_CONTROL_LEN = len(RECEIVED_CONTROL)
 SEND_RECORD_LEN      = len(SEND_CONTROL) + MESSAGE_LEN + DIGEST_LEN
@@ -775,10 +777,12 @@
                 self.beginNextMessage()
                 return
             self.expectedDigest = sha1(msg+"RECEIVED JUNK")
+            self.rejectDigest = sha1(msg+"REJECTED") 
             msg = JUNK_CONTROL+msg+sha1(msg+"JUNK")
             self.isJunk = 1
         else:
             self.expectedDigest = sha1(msg+"RECEIVED")
+            self.rejectDigest = sha1(msg+"REJECTED") 
             msg = SEND_CONTROL+msg+sha1(msg+"SEND")
             self.isJunk = 0
 
@@ -806,20 +810,27 @@
        trace("received ack (fd %s)", self.fd)
        # FFFF Rehandshake
        inp = self.getInput()
-       if inp != (RECEIVED_CONTROL+self.expectedDigest):
+       rejected = 0
+       if inp == REJECTED_CONTROL+self.rejectDigest:
+           debug("Message rejected from %s (fd %s)", self.address, self.fd)
+           rejected = 1
+       elif inp != (RECEIVED_CONTROL+self.expectedDigest):
            # We only get bad ACKs if an adversary somehow subverts TLS's
            # checksumming.  That's not fixable.
            self.shutdown(err=1,retriable=0)
            return
+       else:
+           debug("Received valid ACK for message from %s", self.address)
 
-       debug("Received valid ACK for message from %s", self.address)
        if not self.isJunk:
            justSent = self.messageList[0]
            justSentHandle = self.handleList[0]
            del self.messageList[0]
            del self.handleList[0]
-           if self.sentCallback is not None:
+           if not rejected and self.sentCallback is not None:
                self.sentCallback(justSent, justSentHandle)
+           elif rejected and self.failCallback is not None:
+               self.failCallback(justSent, justSentHandle, retriable=1)
 
        self.beginNextMessage()