[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[minion-cvs] Make drop messages follow the spec
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv9524/lib/mixminion
Modified Files:
BuildMessage.py ClientMain.py
Log Message:
Make drop messages follow the spec
Index: BuildMessage.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/BuildMessage.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- BuildMessage.py 9 Jan 2003 06:28:58 -0000 1.34
+++ BuildMessage.py 12 Jan 2003 04:25:27 -0000 1.35
@@ -20,10 +20,11 @@
'buildReplyBlock', 'decodePayload' ]
def buildForwardMessage(payload, exitType, exitInfo, path1, path2,
- paddingPRNG=None):
+ paddingPRNG=None, suppressTag=0):
"""Construct a forward message.
payload: The payload to deliver. Must compress to under 28K-22b.
- If it does not, MixError is raised.
+ If it does not, MixError is raised. If the payload is
+ None, 28K of random data is sent.
exitType: The routing type for the final node. (2 bytes, >=0x100)
exitInfo: The routing info for the final node, not including tag.
path1: Sequence of ServerInfo objects for the first leg of the path
@@ -40,19 +41,25 @@
if not path2:
raise MixError("Second leg of path is empty")
- LOG.debug("Encoding forward message for %s-byte payload",len(payload))
- LOG.debug(" Using path %s/%s",
- [s.getNickname() for s in path1],
- [s.getNickname() for s in path2])
- LOG.debug(" Delivering to %04x:%r", exitType, exitInfo)
-
# Compress, pad, and checksum the payload.
- payload = _encodePayload(payload, 0, paddingPRNG)
+ if payload is not None:
+ payload = _encodePayload(payload, 0, paddingPRNG)
+ LOG.debug("Encoding forward message for %s-byte payload",len(payload))
+ else:
+ payload = paddingPRNG.getBytes(PAYLOAD_LEN)
+ LOG.debug("Generating DROP message with %s bytes", PAYLOAD_LEN)
+ LOG.debug(" Using path %s:%s",
+ ",".join([s.getNickname() for s in path1]),
+ ",".join([s.getNickname() for s in path2]))
+ LOG.debug(" Delivering to %04x:%r", exitType, exitInfo)
+
# Choose a random decoding tag.
- tag = _getRandomTag(paddingPRNG)
- exitInfo = tag + exitInfo
- return _buildMessage(payload, exitType, exitInfo, path1, path2,paddingPRNG)
+ if not suppressTag:
+ tag = _getRandomTag(paddingPRNG)
+ exitInfo = tag + exitInfo
+ return _buildMessage(payload, exitType, exitInfo, path1, path2,
+ paddingPRNG)
def buildEncryptedForwardMessage(payload, exitType, exitInfo, path1, path2,
key, paddingPRNG=None, secretRNG=None):
@@ -375,7 +382,7 @@
reply = path2
path2 = None
else:
- if len(exitInfo) < TAG_LEN:
+ if len(exitInfo) < TAG_LEN and exitType != DROP_TYPE:
raise MixError("Implausibly short exit info: %r"%exitInfo)
if exitType < MIN_EXIT_TYPE and exitType != DROP_TYPE:
raise MixError("Invalid exit type: %4x"%exitType)
Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- ClientMain.py 10 Jan 2003 20:12:04 -0000 1.41
+++ ClientMain.py 12 Jan 2003 04:25:27 -0000 1.42
@@ -828,13 +828,19 @@
address -- the results of a parseAddress call
payload -- the contents of the message to send
- path1,path2 -- lists of servers."""
+ path1,path2 -- lists of servers.
+
+ DOCDOC payload == None.
+ """
routingType, routingInfo, _ = address.getRouting()
LOG.info("Generating payload...")
+ suppressTag = 0
+ if payload is None:
+ suppressTag = 1
msg = mixminion.BuildMessage.buildForwardMessage(
payload, routingType, routingInfo, servers1, servers2,
- self.prng)
+ self.prng, suppressTag=suppressTag)
return msg, servers1[0]
def sendMessages(self, msgList, server):
@@ -1090,11 +1096,12 @@
# XXXX Clean up this ugly control structure.
if inFile is None and address.getRouting()[0] == DROP_TYPE:
- payload = ""
+ payload = None
LOG.info("Sending dummy message")
else:
if address.getRouting()[0] == DROP_TYPE:
- LOG.warn("Sending a payload with a dummy message makes no sense")
+ LOG.error("Cannot send a payload with a DROP message.")
+ sys.exit(0)
if inFile is None:
inFile = "-"