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

[minion-cvs] Test and debug server blocking, specific flushing/clean...



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

Modified Files:
	ClientDirectory.py ClientMain.py ClientUtils.py Config.py 
	test.py 
Log Message:
Test and debug server blocking, specific flushing/cleaning.

Index: ClientDirectory.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientDirectory.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- ClientDirectory.py	21 Feb 2004 00:02:09 -0000	1.32
+++ ClientDirectory.py	2 Mar 2004 05:40:14 -0000	1.33
@@ -117,15 +117,15 @@
         """Adjust this ClientDirectory to account for blocked servers."""
         sec = config.get("Security", {})
         blocked = {}
-        for lst in sec.get("BlockServers", []):
-            for nn in lst:
-                blocked[nn] = ['*']
         for lst in sec.get("BlockEntries", []):
             for nn in lst:
-                blocked.setdefault(nn,[]).append('entry')
+                blocked.setdefault(nn.lower(),[]).append('entry')
         for lst in sec.get("BlockExits", []):
             for nn in lst:
-                blocked.setdefault(nn,[]).append('exit')
+                blocked.setdefault(nn.lower(),[]).append('exit')
+        for lst in sec.get("BlockServers", []):
+            for nn in lst:
+                blocked[nn.lower()] = ['*']
         self._lock.write_in()
         try:
             self.blockedNicknames = blocked
@@ -133,7 +133,6 @@
         finally:
             self._lock.write_out()
 
-
     def updateDirectory(self, forceDownload=0, timeout=None, now=None):
         """Download a directory from the network as needed."""
         if now is None:

Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -d -r1.159 -r1.160
--- ClientMain.py	1 Mar 2004 06:46:48 -0000	1.159
+++ ClientMain.py	2 Mar 2004 05:40:14 -0000	1.160
@@ -530,7 +530,7 @@
             if exc and not nBad:
                 LOG.info("Got error after all packets were delivered.")
             if exc:
-                LOG.info("Error was: %s",exc[1])
+                LOG.info("Error was: %s", exc[1])
         finally:
                 clientUnlock()
 
@@ -561,10 +561,11 @@
             if handles is None:
                 handles = self.queue.getHandles()
                 LOG.info("Found %s pending packets", len(handles))
+            else:
+                LOG.info("Flushing %s packets", len(handles))
             if maxPackets is not None:
                 handles = mixminion.Crypto.getCommonPRNG().shuffle(handles,
                                                                maxPackets)
-            LOG.info("Flushing %s", len(handles))
             packets = []
             for h in handles:
                 try:
@@ -1812,7 +1813,7 @@
 
     if args:
         handles = parser.client.queue.getHandlesByDestAndAge(
-            args,parser.directory, None)
+            args, parser.directory, notAfter=None)
     else:
         handles = None
 

Index: ClientUtils.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientUtils.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- ClientUtils.py	16 Feb 2004 22:30:03 -0000	1.20
+++ ClientUtils.py	2 Mar 2004 05:40:14 -0000	1.21
@@ -689,7 +689,7 @@
         createPrivateDir(directory)
 
         # We used to name entries "pkt_X"; this has changed.
-        # XXXX007 remove this when it's no longer needed.
+        # XXXX008a remove this when it's no longer needed.
         for fn in os.listdir(directory):
             if fn.startswith("pkt_"):
                 handle = fn[4:]

Index: Config.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Config.py,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- Config.py	27 Jan 2004 05:55:54 -0000	1.77
+++ Config.py	2 Mar 2004 05:40:14 -0000	1.78
@@ -986,9 +986,9 @@
                        'ReplyPath' : ('ALLOW', None, "*4"),
                        'SURBPath' : ('ALLOW', None, "*4"),
                        #DOCDOC and add to .mixminionrc
-                       'BlockServers' : ('ALLOW*', 'seq', ""),
-                       'BlockEntries' : ('ALLOW*', 'seq', ""),
-                       'BlockExits' : ('ALLOW*', 'seq', ""),
+                       'BlockServers' : ('ALLOW*', 'list', ""),
+                       'BlockEntries' : ('ALLOW*', 'list', ""),
+                       'BlockExits' : ('ALLOW*', 'list', ""),
                        },
         'Network' : { 'ConnectionTimeout' : ('ALLOW', "interval", "2 minutes")}
         }

Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.186
retrieving revision 1.187
diff -u -d -r1.186 -r1.187
--- test.py	25 Feb 2004 06:03:11 -0000	1.186
+++ test.py	2 Mar 2004 05:40:14 -0000	1.187
@@ -233,6 +233,14 @@
             if len(s1) > min(40, len(s2)+5):
                 s1 = "..."+s1[-(len(s2)+5):]
             self.fail("%r does not end with %r"%(s1,s2))
+    def assertIn(self, item, lst):
+        """Fail unless 'item in lst'"""
+        if not (item in lst):
+            self.fail("%r not in %r"%(item,lst))
+    def assertNotIn(self, item, lst):
+        """Fail unless 'item not in lst'"""
+        if (item in lst):
+            self.fail("%r in %r"%(item,lst))
 
 #----------------------------------------------------------------------
 # Tests for common functionality
@@ -6727,6 +6735,20 @@
             self.assertSameSD(joe[0], p[3])
             neq(p[1].getNickname(), "Alice")
             neq(p[1].getNickname(), "Joe")
+
+            # 2a.1. (Blocking some servers)
+            ks.configure({"Security" : { "BlockServers" : [["Joe"]],
+                                         "BlockEntries" : [["Alice"]],
+                                         "BlockExits" : [["Bob"]] } })
+            for _ in xrange(100):
+                p = ks.getPath([None]*4)
+                eq(4, len(p))
+                p = [ s.getNickname() for s in p ]
+                self.assertNotEquals("Alice", p[0])
+                self.assertNotEquals("Bob", p[3])
+                self.assertNotIn("Joe", p)
+
+            ks.configure({})
             # 2b. With 3 <= servers < length
             ks2 = mixminion.ClientDirectory.ClientDirectory(mix_mktemp())
             ks2.importFromFile(os.path.join(impdirname, "Joe0"))
@@ -6802,7 +6824,7 @@
             else:
                 return paths
 
-        #XXXX007 remove
+        #XXXX008a remove
         mixminion.ClientDirectory.WARN_STAR = 0
 
         paddr = mixminion.ClientDirectory.parseAddress
@@ -7001,6 +7023,7 @@
         ks = mixminion.ClientDirectory.ClientDirectory(dirname)
         ks.clean(now=now+oneDay*500) # Should zap all of imported servers.
         raises(MixError, ks.getServerInfo, "Lola", strict=1)
+        ks.getServerInfo
 
     def testFeatureMaps(self):
         from mixminion.ClientDirectory import compressFeatureMap
@@ -7542,7 +7565,7 @@
     tc = loader.loadTestsFromTestCase
 
     if 0:
-        suite.addTest(tc(ModuleTests))
+        suite.addTest(tc(ClientDirectoryTests))
         return suite
     testClasses = [MiscTests,
                    MinionlibCryptoTests,