[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Improve documentation, refactor



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

Modified Files:
	PacketHandler.py 
Log Message:
Improve documentation, refactor

Index: PacketHandler.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/PacketHandler.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- PacketHandler.py	13 Jan 2003 06:28:49 -0000	1.5
+++ PacketHandler.py	4 Feb 2003 02:05:36 -0000	1.6
@@ -60,17 +60,12 @@
             h.close()
 
     def processMessage(self, msg):    
-        """DOCDOC
-
-           Given a 32K mixminion message, processes it completely.
+        """Given a 32K mixminion message, processes it completely.
 
-           Returns one of:
+           Return one of:
                     None [if the mesesage should be dropped.]
-                    ("EXIT",
-                       (exit_type, exit_info, application_key,
-                        tag, payload)) [if this is the exit node]
-                    ("QUEUE", (ipv4info, message_out))
-                        [if this is a forwarding node]
+                    a DeliveryPacket object
+                    a RelayedPacket object
 
            May raise CryptoError, ParseError, or ContentError if the packet
            is malformatted, misencrypted, unparseable, repeated, or otherwise
@@ -234,7 +229,7 @@
         return self.contents
 
     def isPlaintext(self):
-        if self.type is None: self.decode()        
+        if self.type is None: self.decode()
         return self.type == 'plain'
 
     def isOvercompressed(self):
@@ -277,7 +272,6 @@
             self.contents = message
             self.type = 'err'
 
-
         self.payload = None
 
     def getAsciiContents(self):
@@ -291,3 +285,19 @@
 
     def getAsciiTag(self):
         return base64.encodestring(self.tag).strip()
+
+    def getAsciiEncodedMessage(self):
+        tag = None
+        if self.isOvercompressed():
+            tp = 'LONG'
+        elif self.isEncrypted():
+            tp = 'ENC'
+            tag = self.tag
+        elif self.isPrintingAscii():
+            assert self.isPlaintext()
+            tp = 'TXT'
+        else:
+            assert self.isPlaintext()
+            tp = 'BIN'
+            
+        return Packet.AsciiEncodedMessage(self.contents, tp, tag)