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

[minion-cvs] Resolve XXXXs and FFFFs for 004



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

Modified Files:
	EventStats.py HashLog.py MMTPServer.py Modules.py 
	ServerConfig.py ServerKeys.py ServerMain.py ServerQueue.py 
Log Message:
Resolve XXXXs and FFFFs for 004

Index: EventStats.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/EventStats.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- EventStats.py	5 Jun 2003 05:24:23 -0000	1.5
+++ EventStats.py	5 Jun 2003 18:41:40 -0000	1.6
@@ -16,10 +16,12 @@
 
 # _EVENTS: a list of all recognized event types.
 _EVENTS = [ 'ReceivedPacket',
-           'AttemptedRelay',
-           'SuccessfulRelay', 'FailedRelay', 'UnretriableRelay',
-           'AttemptedDelivery',
-           'SuccessfulDelivery', 'FailedDelivery', 'UnretriableDelivery',
+           
+            'AttemptedRelay', 'SuccessfulRelay',
+            'FailedRelay', 'UnretriableRelay',
+           
+            'AttemptedDelivery', 'SuccessfulDelivery',
+            'FailedDelivery', 'UnretriableDelivery',
             ]
 
 class NilEventLog:
@@ -130,6 +132,9 @@
             assert self.count is not None
             assert self.lastRotation is not None
             assert self.accumulatedTime is not None
+            for e in _EVENTS:
+                if not self.count.has_key(e):
+                    self.count[e] = {}
         else:
             self.count = {}
             for e in _EVENTS:

Index: HashLog.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/HashLog.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- HashLog.py	5 Jun 2003 05:24:23 -0000	1.13
+++ HashLog.py	5 Jun 2003 18:41:40 -0000	1.14
@@ -151,7 +151,7 @@
             self.__lock.acquire()
             self.journal[hash] = 1
             os.write(self.journalFile, hash)
-            #XXXX Make this configurable.
+            # FFFF Make this configurable.
             if len(self.journal) > MAX_JOURNAL:
                 self.sync()
         finally:

Index: MMTPServer.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/MMTPServer.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- MMTPServer.py	5 Jun 2003 01:52:52 -0000	1.35
+++ MMTPServer.py	5 Jun 2003 18:41:40 -0000	1.36
@@ -91,12 +91,12 @@
     def hasReader(self, reader):
         """Return true iff 'reader' is a reader on this server."""
         fd = reader.fileno()
-        return self.readers.get(fd, None) is reader
+        return self.readers.get(fd) is reader
 
     def hasWriter(self, writer):
         """Return true iff 'writer' is a writer on this server."""
         fd = writer.fileno()
-        return self.writers.get(fd, None) is writer
+        return self.writers.get(fd) is writer
 
     def registerReader(self, reader):
         """Register a connection as a reader.  The connection's 'handleRead'
@@ -965,14 +965,12 @@
         # FFFF Don't always listen; don't always retransmit!
         # FFFF Support listening on multiple IPs
 
-        if config['Incoming/MMTP'].get('ListenIP',None) is not None:
-            IP = config['Incoming/MMTP']['ListenIP']
-        else:
+        IP = config['Incoming/MMTP'].get('ListenIP')
+        if IP is None:
             IP = config['Incoming/MMTP']['IP']
 
-        if config['Incoming/MMTP'].get('ListenPort',None) is not None:
-            port = config['Incoming/MMTP']['ListenPort']
-        else:
+        port =  config['Incoming/MMTP'].get('ListenPort')
+        if port is None:
             port = config['Incoming/MMTP']['Port']
 
         self.listener = ListenConnection(IP, port,
@@ -1011,7 +1009,7 @@
 
     def sendMessages(self, ip, port, keyID, messages, handles):
         """Begin sending a set of messages to a given server."""
-        # ???? Can we remove these asserts yet?
+
         for m,h in zip(messages, handles):
             if m in ("JUNK", "RENEGOTIATE"):
                 assert h is None

Index: Modules.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/Modules.py,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- Modules.py	5 Jun 2003 05:48:39 -0000	1.41
+++ Modules.py	5 Jun 2003 18:41:40 -0000	1.42
@@ -135,20 +135,20 @@
         """Instead of queueing our message, pass it directly to the underlying
            DeliveryModule."""
         try:
-            EventStats.log.attemptedDelivery() #XXXX
+            EventStats.log.attemptedDelivery() #FFFF
             res = self.module.processMessage(packet)
             if res == DELIVER_OK:
-                EventStats.log.successfulDelivery() #XXXX
+                EventStats.log.successfulDelivery() #FFFF
             elif res == DELIVER_FAIL_RETRY:
                 LOG.error("Unable to retry delivery for message")
-                EventStats.log.unretriableDelivery() #XXXX
+                EventStats.log.unretriableDelivery() #FFFF
             else:
                 LOG.error("Unable to deliver message")
-                EventStats.log.unretriableDelivery() #XXXX
+                EventStats.log.unretriableDelivery() #FFFF
         except:
             LOG.error_exc(sys.exc_info(),
                                "Exception delivering message")
-            EventStats.log.unretriableDeliery() #XXXX
+            EventStats.log.unretriableDeliery() #FFFF
 
         return "<nil>"
 
@@ -407,7 +407,7 @@
         """
         exitType = packet.getExitType()
 
-        mod = self.typeToModule.get(exitType, None)
+        mod = self.typeToModule.get(exitType)
         if mod is None:
             LOG.error("Unable to handle message with unknown type %s",
                       exitType)
@@ -587,7 +587,7 @@
         domparts = dom.split(".")
         for idx in range(len(domparts)):
             subdom = ".".join(domparts[idx:])
-            if self.domains.get(subdom,None) == 'SUB':
+            if self.domains.get(subdom) == 'SUB':
                 return 1
 
         # Does it match any patterns?
@@ -888,7 +888,7 @@
                  }
 
     def validateConfig(self, config, lines, contents):
-        #XXXX write more
+        #FFFF write more
         sec = config['Delivery/SMTP-Via-Mixmaster']
         if not sec.get("Enabled"):
             return

Index: ServerConfig.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerConfig.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- ServerConfig.py	5 Jun 2003 05:48:39 -0000	1.32
+++ ServerConfig.py	5 Jun 2003 18:41:40 -0000	1.33
@@ -99,7 +99,7 @@
         """Callback from the [Server] section of a config file.  Parses
            the module options, and adds new sections to the syntax
            accordingly."""
-        self.moduleManager.setPath(section.get('ModulePath', None))
+        self.moduleManager.setPath(section.get('ModulePath'))
         for mod in section.get('Module', []):
             LOG.info("Loading module %s", mod)
             self.moduleManager.loadExtModule(mod)
@@ -147,7 +147,7 @@
            is reasonable.  Warn or raise ConfigError if it isn't.  Ignore
            the entry if it isn't there.
         """
-        entry = self[sectionName].get(entryName,None)
+        entry = self[sectionName].get(entryName)
         if not entry:
             return
         mixInterval = self['Server']['MixInterval'].getSeconds()

Index: ServerKeys.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerKeys.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- ServerKeys.py	5 Jun 2003 05:24:23 -0000	1.38
+++ ServerKeys.py	5 Jun 2003 18:41:40 -0000	1.39
@@ -51,7 +51,6 @@
 #
 #FFFF Make this configurable
 DIRECTORY_UPLOAD_URL = "http://mixminion.net/minion-cgi/publish";
-#DIRECTORY_UPLOAD_URL = "http://192.168.0.1/cgi-bin/publish";
 
 #----------------------------------------------------------------------
 class ServerKeyring:
@@ -1028,7 +1027,12 @@
         raise IPGuessError("Multiple addresses found: %s" % (
                     ", ".join(ip_set.keys())))
 
-    return ip_set.keys()[0]
+    IP = ip_set.keys()[0]
+    if IP.startswith("192.168.") or IP.startswith("10.") or \
+       IP.startswith("176.16."):
+        raise IPGuessError("Only address found is in a private IP block")
+
+    return IP
 
 def generateCertChain(filename, mmtpKey, identityKey, nickname,
                       certStarts, certEnds):

Index: ServerMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerMain.py,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- ServerMain.py	5 Jun 2003 05:48:39 -0000	1.72
+++ ServerMain.py	5 Jun 2003 18:41:40 -0000	1.73
@@ -180,7 +180,7 @@
         except:
             LOG.error_exc(sys.exc_info(),
                     "Unexpected error when processing IN:%s", handle)
-            self.removeMessage(handle) # ???? Really dump this message?
+            self.removeMessage(handle)
 
 class MixPool:
     """Wraps a mixminion.server.Queue.*MixPool to send messages to an exit
@@ -351,21 +351,21 @@
 
     def onMessageReceived(self, msg):
         self.incomingQueue.queueMessage(msg)
-        # XXXX Replace with server.
+        # FFFF Replace with server.
         EventStats.log.receivedPacket()
 
     def onMessageSent(self, msg, handle):
         self.outgoingQueue.deliverySucceeded(handle)
-        EventStats.log.attemptedRelay() # XXXX replace with addr
-        EventStats.log.successfulRelay() # XXXX replace with addr
+        EventStats.log.attemptedRelay() # FFFF replace with addr
+        EventStats.log.successfulRelay() # FFFF replace with addr
 
     def onMessageUndeliverable(self, msg, handle, retriable):
         self.outgoingQueue.deliveryFailed(handle, retriable)
-        EventStats.log.attemptedRelay() # XXXX replace with addr
+        EventStats.log.attemptedRelay() # FFFF replace with addr
         if retriable:
-            EventStats.log.failedRelay() # XXXX replace with addr
+            EventStats.log.failedRelay() # FFFF replace with addr
         else:
-            EventStats.log.unretriableRelay() # XXXX replace with addr
+            EventStats.log.unretriableRelay() # FFFF replace with addr
 
 #----------------------------------------------------------------------
 class CleaningThread(threading.Thread):
@@ -805,7 +805,6 @@
         if self.config['Server'].get("Daemon",1):
             closeUnusedFDs()
 
-        # FFFF Support for automatic key rotation.
         while 1:
             nextEventTime = self.firstEventTime()
             now = time.time()
@@ -953,7 +952,7 @@
     sys.exit(0)
 
 def configFromServerArgs(cmd, args, usage=None):
-    #XXXX
+    """DOCDOC"""
     options, args = getopt.getopt(args, "hf:", ["help", "config="])
     if args:
         if usage:
@@ -975,7 +974,7 @@
     return readConfigFile(configFile)
 
 def readConfigFile(configFile):
-    #XXXX
+    """DOCDOC"""
     if configFile is None:
         configFile = None
         for p in ["~/.mixminiond.conf", "~/etc/mixminiond.conf",
@@ -1216,7 +1215,7 @@
 """.strip()
 
 def printServerStats(cmd, args):
-    #XXXX
+    """DOCDOC"""
     config = configFromServerArgs(cmd, args, _PRINT_STATS_USAGE)
     checkHomedirVersion(config)
     _signalServer(config, 1)

Index: ServerQueue.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerQueue.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- ServerQueue.py	5 Jun 2003 05:24:23 -0000	1.19
+++ ServerQueue.py	5 Jun 2003 18:41:41 -0000	1.20
@@ -510,8 +510,8 @@
     def _repOk(self):
         """Raise an assertion error if the internal state of this object is
            nonsensical."""
-        #XXXX004 Later in the release cycle, we should call this less.  It
-        #XXXX004 adds ~8-9ms on my laptop for ~400 messages
+        # XXXX Later in the release cycle, we should call this *even* less.
+        # XXXX It adds ~8-9ms on my laptop for ~400 messages
         try:
             self._lock.acquire()
 
@@ -552,7 +552,6 @@
         finally:
             self._lock.release()
 
-        self._repOk()
         return handle
 
     def _inspect(self,handle):
@@ -583,6 +582,7 @@
         """Sends all messages which are not already being sent, and which
            are scheduled to be sent."""
         assert self.retrySchedule is not None
+        self._repOk()
         if now is None:
             now = time.time()
         LOG.trace("ServerQueue checking for deliverable messages in %s",
@@ -609,11 +609,15 @@
                     self.sendable.append(h)
         finally:
             self._lock.release()
-        self._repOk()
+
         if messages:
             self._deliverMessages(messages)
-            self._repOk()
+        self._repOk()
 
+    # FFFF004 This interface is inefficient in space: we don't need to load 
+    # FFFF004 the messages to tell whether they need to be delivered.  We
+    # FFFF004 should have _deliverMessages() take a list of handles, not of
+    # FFFF004 messages.
     def _deliverMessages(self, msgList):
         """Abstract method; Invoked with a list of (handle, message)
            tuples every time we have a batch of messages to send.
@@ -730,7 +734,6 @@
                     except KeyError:
                         LOG.error("Handle %s was not pending", handle)
 
-                    self._repOk()
                     self._writeState(handle)
                     return
 
@@ -739,7 +742,6 @@
             # If we reach this point, the message is undeliverable.
             LOG.trace("     (Giving up on %s)", handle)
             self.removeMessage(handle)
-            self._repOk()
         finally:
             self._lock.release()