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

[minion-cvs] ClientMain.py: Fix a bug where we could get confused by...



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

Modified Files:
	ClientMain.py Common.py Config.py 
Log Message:
ClientMain.py: Fix a bug where we could get confused by old servers that 
    mistook framgnets for encrypted messages.  We'd believe them about the
    "encrypted" part, and then when found that we were able to decode the
    fragment just fine, we'd think that it was sent via a SURB, and that 
    therefore we were under an identity blending attack.

    Oddly, we were doing so wrongly, so the converse identity blending
    attack wouldn't have worked.  In case you cared. :)

ClientMain.py: Fix a bug in 'mixminion ping' that would mistake any filename
    with a dot for a hotname. Duh.

Common.py: Note stupidity in interface for calls to shred.

Config.py, ClientMain.py: Remember fname; replace ConnectionTimeout
    with Timeout.



Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -d -r1.168 -r1.169
--- ClientMain.py	22 Mar 2004 10:26:56 -0000	1.168
+++ ClientMain.py	23 Mar 2004 00:13:55 -0000	1.169
@@ -192,7 +192,7 @@
 #BlockServers: example5,example6,example7
 
 [Network]
-ConnectionTimeout: 60 seconds
+Timeout: 2 minutes
 """ % fields)
 
 class MixminionClient:
@@ -441,12 +441,7 @@
     def pingServer(self, routingInfo):
         """Given an IPV4Info, try to connect to a server and find out if
            it's up.  Returns a boolean and a status message."""
-        timeout = self.config['Network'].get('ConnectionTimeout')
-        if timeout:
-            timeout = int(timeout)
-        else:
-            timeout = 60
-
+        timeout = self.config.getTimeout()
         try:
             mixminion.MMTPClient.pingServer(routingInfo, timeout)
             return 1, "Server seems to be running"
@@ -472,18 +467,13 @@
            XXXX return 1 if all delivered
            """
         #XXXX write unit tests
-        timeout = self.config['Network'].get('ConnectionTimeout')
-        if timeout:
-            timeout = int(timeout)
-        else:
-            timeout = 60
+        timeout = self.config.getTimeout()
 
         if noQueue or lazyQueue:
             handles = []
         else:
             handles = self.queuePackets(pktList, routingInfo)
 
-
         packetsSentByIndex = {}
         def callback(idx, packetsSentByIndex=packetsSentByIndex):
             packetsSentByIndex[idx] = 1
@@ -681,10 +671,12 @@
                                                          userKeys=surbKeys,
                                                          retNym=nym)
                 if p:
-                    if nym:
-                        nym=nym[0]
+                    if nym == []:
+                        nym = "---"
+                    elif nym[0] in (None, ""):
+                        nym = "default identity"
                     else:
-                        nym="default"
+                        nym = nym[0]
                     if p.isSingleton():
                         results.append(p.getUncompressedContents())
                     else:
@@ -1312,7 +1304,7 @@
     client = parser.client
 
     for arg in args:
-        if '.' in arg:
+        if '.' in arg and not os.path.exists(arg):
             addrport = arg.split(":",1)
             if len(addrport) == 2:
                 try:
@@ -1406,7 +1398,8 @@
 """.strip()
 
 def listServers(cmd, args):
-    """[Entry point] Print info about """
+    """[Entry point] Print info about servers in the directory, or on
+       the command line."""
     options, args = getopt.getopt(args, "hf:D:vQF:JTRs:cC",
                                   ['help', 'config=', "download-directory=",
                                    'verbose', 'quiet', 'feature=', 'justify',

Index: Common.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Common.py,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -d -r1.135 -r1.136
--- Common.py	18 Mar 2004 05:55:50 -0000	1.135
+++ Common.py	23 Mar 2004 00:13:55 -0000	1.136
@@ -753,6 +753,7 @@
     for i in xrange(0, len(fnames), 250-len(_SHRED_OPTS)):
         files = fnames[i:i+250-len(_SHRED_OPTS)]
         try:
+            #XXXX008 if blocking, we should just call this with P_WAIT.
             pid = os.spawnl(os.P_NOWAIT,
                             _SHRED_CMD, _SHRED_CMD, *(_SHRED_OPTS+files))
         except OSError, e:

Index: Config.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Config.py,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- Config.py	18 Mar 2004 04:48:22 -0000	1.81
+++ Config.py	23 Mar 2004 00:13:55 -0000	1.82
@@ -752,9 +752,11 @@
 
         if filename:
             contents = mixminion.Common.readPossiblyGzippedFile(filename)
+            self.fname = filename
             self.__load(contents)
         else:
             assert string is not None
+            self.fname = None
             self.__load(string)
 
     def __load(self, fileContents):
@@ -988,7 +990,9 @@
                        'BlockEntries' : ('ALLOW*', 'list', ""),
                        'BlockExits' : ('ALLOW*', 'list', ""),
                        },
-        'Network' : { 'ConnectionTimeout' : ('ALLOW', "interval", "2 minutes")}
+        'Network' : { 'ConnectionTimeout' : ('ALLOW', "interval", None),
+                      'Timeout' : ('ALLOW', "interval", None) }
+
         }
     def __init__(self, fname=None, string=None):
         _ConfigFile.__init__(self, fname, string)
@@ -1011,11 +1015,27 @@
         _validateHostSection(self['Host'])
 
         t = self['Network'].get('ConnectionTimeout')
-        if t:
-            if int(t) < 5:
-                LOG.warn("Very short connection timeout")
-            elif int(t) > 60:
-                LOG.warn("Very long connection timeout")
+        if t is not None:
+            LOG.warn("The ConnectionTimout option in your .mixminionrc is deprecated; use Timeout instead.")
+        t = self.getTimeout()
+        if int(t) < 5:
+            LOG.warn("Very short network timeout")
+        elif int(t) > 120:
+            LOG.warn("Very long network timeout")
+
+    def getTimeout(self):
+        """Return the network timeout in this configuration."""
+        network = self.get("Network",{})
+        # The variable is now called 'Timeout'...
+        t = network.get("Timeout",None)
+        if t is not None:
+            return int(t)
+        # ...but older code may call it 'ConnectionTimout'.
+        t = network.get("ConnectionTimeout",None)
+        if t is not None:
+            return int(t)
+        # ...default to 2 minutes.
+        return 120
 
 def _validateHostSection(sec):
     """Helper function: Makes sure that the shared [Host] section is correct;