[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] A few minor changes, one of them with little tentacles ...
Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv2215/lib/mixminion/server
Modified Files:
Modules.py PacketHandler.py ServerMain.py
Log Message:
A few minor changes, one of them with little tentacles throughout the code.
- Make the presence/absence of a tag decided by users of
DeliverableMessage/Subheader, not (as before) by DM/S on the basis of
exit types. This allows extension types to exist without deliverhandles.
- Add a 'mixminiond' script and entrypoint. Should work.
- Fix a bug: when no workable exit server is found, we shouldn't crash.
Index: Modules.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/Modules.py,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- Modules.py 27 Jan 2004 05:13:36 -0000 1.70
+++ Modules.py 21 Feb 2004 00:02:09 -0000 1.71
@@ -65,6 +65,10 @@
"Zero-argument constructor, as required by Module protocol."
pass
+ def usesDecodingHandle(self):
+ """DOCDOC"""
+ return 1
+
def getRetrySchedule(self):
"""Return a retry schedule for this module's queue, as specified
in ServerQueue.DeliveryQueue.setRetrySchedule."""
@@ -142,6 +146,7 @@
# module: the underlying DeliveryModule object.
def __init__(self, module):
self.module = module
+ self.hasTag = 1
def queueDeliveryMessage(self, packet, retry=0, lastAttempt=0):
"""Instead of queueing our message, pass it directly to the underlying
@@ -439,11 +444,18 @@
mod = self.typeToModule.get(exitType)
if mod is None:
- LOG.error("Unable to handle message with unknown type %s",
+ LOG.error("Unable to handle packet with unknown type %s",
exitType)
return "<nil>"
+ try:
+ packet.setTagged(mod.usesDecodingHandle())
+ except ParseError:
+ LOG.error("Packet (type %04x) missing decoding handle; dropped",
+ exitType)
+ return "<nil>"
+
queue = self.queues[mod.getName()]
- LOG.debug("Delivering message %r (type %04x) via module %s",
+ LOG.debug("Delivering packet %r (type %04x) via module %s",
packet.getContents()[:8], exitType, mod.getName())
return queue.queueDeliveryMessage(packet)
@@ -500,6 +512,7 @@
#----------------------------------------------------------------------
class DropModule(DeliveryModule):
"""Null-object pattern: drops all messages it receives."""
+ def usesDecodingHandle(self): return 0
def getConfigSyntax(self):
return { }
def getRetrySchedule(self):
@@ -543,6 +556,7 @@
self.maxInterval = None
self.maxFragments = None
self.lock = threading.RLock()
+ def usesDecodingHandle(self): return 0
def getConfigSyntax(self):
return { "Delivery/Fragmented" :
{ 'Enabled' : ('REQUIRE', "boolean", "no"),
@@ -561,7 +575,7 @@
deliverySecs = [ 'Delivery/MBOX', 'Delivery/SMTP',
'Delivery/SMTP-Via-Mixmaster' ]
enabled = [ config.get(s,{}).get("Enabled") for s in deliverySecs ]
-
+
if not [ e for e in enabled if e ]:
raise ConfigError("You've specified Fragmented delivery, but no actual delivery method. This doesn't make much sense.")
@@ -725,6 +739,7 @@
self.tp = None
self.headers = None
+ def setTagged(self,tagged=1): pass
def isDelivery(self): return 1
def getExitType(self): return self.exitType
def getAddress(self): return self.address
Index: PacketHandler.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/PacketHandler.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- PacketHandler.py 3 Jan 2004 07:35:24 -0000 1.35
+++ PacketHandler.py 21 Feb 2004 00:02:09 -0000 1.36
@@ -205,9 +205,9 @@
# If we're an exit node, there's no need to process the headers
# further.
if rt >= Packet.MIN_EXIT_TYPE:
- return DeliveryPacket(rt, subh.getExitAddress(),
+ return DeliveryPacket(rt, subh.getExitAddress(0),
keys.get(Crypto.APPLICATION_KEY_MODE),
- subh.getTag(), payload)
+ payload)
# If we're not an exit node, make sure that what we recognize our
# routing type.
@@ -288,18 +288,15 @@
# dPayload -- An instance of mixminion.Packet.Payload for this object.
# error -- None, or a string containing an error encountered while trying
# to decode the payload.
- def __init__(self, routingType, routingInfo, applicationKey,
- tag, payload):
+ def __init__(self, routingType, routingInfo, applicationKey, payload):
"""Construct a new DeliveryPacket."""
assert 0 <= routingType <= 0xFFFF
assert len(applicationKey) == 16
- #assert len(tag) == 20 #XXXX007 make tag system sane.
- assert len(tag) == 20 or routingType == Packet.FRAGMENT_TYPE
assert len(payload) == 28*1024
self.exitType = routingType
self.address = routingInfo
self.key = applicationKey
- self.tag = tag
+ self.tag = ""
self.payload = payload
self.contents = None
self.type = None
@@ -307,6 +304,19 @@
self.isfrag = 0
self.dPayload = None
self.error = None
+ self.hasTag = 0 # XXXX007 DOCDOC
+
+ def setTagged(self,tagged=1):
+ self.hasTag=tagged
+ x = self.tag+self.address
+ if tagged:
+ if len(x)<Packet.TAG_LEN:
+ raise ParseError("Missing decoding handle for exit type")
+ self.tag = x[:Packet.TAG_LEN]
+ self.address = x[Packet.TAG_LEN:]
+ else:
+ self.tag = ""
+ self.address = x
def __getstate__(self):
return "V0", self.__dict__
@@ -389,8 +399,7 @@
message = self.payload
self.contents = None
try:
- self.dPayload = mixminion.BuildMessage.decodePayload(message,
- self.tag)
+ self.dPayload = mixminion.BuildMessage.decodePayload(message, "")
if self.dPayload is None:
# encrypted message
self.type = 'enc'
Index: ServerMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerMain.py,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- ServerMain.py 6 Feb 2004 23:14:28 -0000 1.117
+++ ServerMain.py 21 Feb 2004 00:02:09 -0000 1.118
@@ -1392,11 +1392,11 @@
def signalServer(cmd, args):
"""[Entry point] Send a SIGHUP or a SIGTERM to a running mixminion
server."""
- if cmd.endswith("server-stop"):
+ if cmd.endswith("stop"):
sig_reload = 0
usage = _SIGNAL_SERVER_USAGE % ("server-stop", "shut down")
else:
- assert cmd.endswith("server-reload")
+ assert cmd.endswith("reload")
sig_reload = 1
usage = _SIGNAL_SERVER_USAGE % ("server-reload",
"rescan its configuration")