[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
In directory moria.mit.edu:/tmp/cvs-serv8971/lib/mixminion
Modified Files:
ClientMain.py Common.py Config.py Crypto.py Main.py
ServerInfo.py benchmark.py test.py
Log Message:
Resolve XXXXs and FFFFs for 004
Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- ClientMain.py 5 Jun 2003 05:48:38 -0000 1.88
+++ ClientMain.py 5 Jun 2003 18:41:40 -0000 1.89
@@ -464,9 +464,9 @@
elements with a given nickname are valid over the given time
interval, the most-recently-published one is included.
"""
- # XXXX This is not really good: servers may be the same, even if
- # XXXX their nicknames are different. The logic should probably
- # XXXX go into directory, though.
+ # FFFF This is not really good: servers may be the same, even if
+ # FFFF their nicknames are different. The logic should probably
+ # FFFF go into directory, though.
u = {} # Map from lcnickname -> latest-expiring info encountered in lst
for info, _ in lst:
@@ -542,10 +542,9 @@
s = self.__findOne(self.byNickname[name.lower()], startAt, endAt)
if not s:
- # FFFF Beef up this message to say that we know about that
- # FFFF nickname, but that all suchnamed servers are dead.
- raise UIError("Couldn't find any valid descriptor with name %s"
- % name)
+ raise UIError(
+ "Couldn't find any currently live descriptor with name %s"
+ % name)
if not self.goodServerNicknames.has_key(s.getNickname().lower()):
LOG.warn("Server %s is not recommended",name)
@@ -639,45 +638,32 @@
used = filter(None, servers)
nNeeded = len([info for info in servers if info is None])
relays = self.__find(self.byCapability['relay'], startAt, endAt)
- unusedRelays = setSub(relays, used)
- if relays:
- # We know at least one relay, but not enough to choose without
- # replacement. First, give an appropriate warning...
+ if not relays:
+ raise UIError("No relays known")
+ elif len(relays) == 2:
+ LOG.warn("Not enough servers to avoid same-server hops")
+ elif len(relays) == 1:
+ LOG.warn("Only one relay known")
- #XXXX004 These warnings are all wrong
- if len(unusedRelays) >= nNeeded:
- pass
- elif len(relays) >= 3:
- LOG.warn("Not enough servers for distinct path (%s unused, %s known)",
- len(unusedRelays), len(relays))
- elif len(relays) > 1:
- LOG.warn("Not enough servers to avoid same-server hops")
+ # Now fill in the servers. For each relay we need...
+ for i in xrange(len(servers)):
+ if servers[i] is not None:
+ continue
+ # Find the servers adjacent to it, if any...
+ if i>0:
+ abutters = filter(None,[ servers[i-1], servers[i+1]])
else:
- assert len(relays) == 1
- LOG.warn("Only one relay known")
-
- # Now fill in the servers. For each relay we need...
- for i in xrange(len(servers)):
- if servers[i] is not None:
- continue
- # Find the servers adjacent to it, if any...
- if i>0:
- abutters = filter(None,[ servers[i-1], servers[i+1]])
- else:
- abutters = filter(None,[ servers[i+1] ])
- # ...and see if there are any relays left that aren't adjacent.
- candidates = setSub(relays, abutters)
- if candidates:
- # Good. There are.
- servers[i] = prng.pick(candidates)
- else:
- # Nope. Choose a random relay.
- servers[i] = prng.pick(relays)
- else:
- # If we don't know any relays, give up.
- raise UIError("No relays known")
+ abutters = filter(None,[ servers[i+1] ])
+ # ...and see if there are any relays left that aren't adjacent.
+ candidates = setSub(relays, abutters)
+ if candidates:
+ # Good. There are.
+ servers[i] = prng.pick(candidates)
+ else:
+ # Nope. Choose a random relay.
+ servers[i] = prng.pick(relays)
- # XXXX004 We need to make sure that the path isn't totally junky.
+ # FFFF We need to make sure that the path isn't totally junky.
return servers
@@ -747,7 +733,8 @@
You can use a question mark to indicate a randomly chosen server:
'foo,bar,?,quux,?'.
As an abbreviation, you can use star followed by a number to indicate
- that number of randomly chosen
+ that number of randomly chosen servers:
+ 'foo,bar,*2,quux'.
You can use a star to specify a fill point where randomly-selected
servers will be added:
@@ -758,6 +745,7 @@
path, nHops must equal the path length; and if nHops is used _with_ a
star on the path, nHops must be >= the path length.
"""
+ #DOCDOC comment this.
if not path:
path = '*'
explicitSwap = 0
@@ -782,7 +770,6 @@
raise UIError("Can't have two variable-length wildcards in a path")
starPos = i
- # XXXX004 check for match with nHops.
myNHops = nHops or defaultNHops or 6
if starPos is not None:
haveHops = len(path) - 1
@@ -797,7 +784,7 @@
firstLegLen = colonPos
del path[colonPos]
elif halfPath:
- firstLegLen = len(path)
+ firstLegLen = 0
else:
firstLegLen = ceilDiv(len(path), 2)
@@ -807,7 +794,7 @@
for i in xrange(len(path)):
if path[i] == '?': path[i] = None
- # Remark: why do this now
+ # DOCDOC Remark: why do this now
if address is None:
rt, ri, exitNode = None, None, None
exitCap = 'relay'
@@ -924,8 +911,11 @@
self._checkMagic(fn, magic)
# ...then see if we can load it without a password...
try:
- return self._load(fn, magic, "")
- except MixError:
+ data = self._load(fn, magic, "")
+ self.keyring = cPickle.loads(data)
+ self.keyringPassword = ""
+ return self.keyring
+ except MixError, e:
pass
# ...then ask the user for a password 'till it loads.
while 1:
@@ -955,7 +945,7 @@
return {}
def _saveKeyring(self):
- assert self.keyringPassword
+ assert self.keyringPassword is not None
fn = os.path.join(self.keyDir, "keyring")
LOG.trace("Saving keyring to %s", fn)
self._save(fn+"_tmp",
@@ -1217,7 +1207,7 @@
# )
# XXXX change this to be OO; add nicknames.
- # XXXX004 write unit tests
+ # XXXX write unit tests
def __init__(self, directory, prng=None):
"""Create a new ClientQueue object, storing packets in 'directory'
@@ -1364,7 +1354,7 @@
queue it and exit.
forceNoQueue -- if true, do not queue the message even if delivery
fails."""
- #XXXX004 write unit tests
+ #XXXX write unit tests
message, firstHop = \
self.generateReplyMessage(payload, servers, surbList)
@@ -1382,7 +1372,7 @@
expiryTime -- if provided, a time at which the replyBlock must
still be valid, and after which it should not be used.
"""
- #XXXX004 write unit tests
+ #XXXX write unit tests
key = self.keys.getSURBKey(name=name, create=1)
exitType, exitInfo, _ = address.getRouting()
@@ -1419,7 +1409,7 @@
the path. We use the first one that is neither expired nor
used, and mark it used.
"""
- #XXXX004 write unit tests
+ #XXXX write unit tests
if now is None:
now = time.time()
surbLog = self.openSURBLog() # implies lock
@@ -1473,7 +1463,7 @@
If warnIfLost is true, log a warning if we fail to deliver
the message, and we don't queue it.
"""
- #XXXX004 write unit tests
+ #XXXX write unit tests
timeout = self.config['Network'].get('ConnectionTimeout')
if timeout:
timeout = int(timeout)
@@ -1522,7 +1512,7 @@
def flushQueue(self, maxMessages=None):
"""Try to send end all messages in the queue to their destinations.
"""
- #XXXX004 write unit tests
+ #XXXX write unit tests
LOG.info("Flushing message queue")
# XXXX This is inefficient in space!
@@ -1573,7 +1563,7 @@
"""Insert all the messages in msgList into the queue, to be sent
to the server identified by the IPV4Info object 'routing'.
"""
- #XXXX004 write unit tests
+ #XXXX write unit tests
LOG.trace("Queueing messages")
handles = []
try:
@@ -1596,7 +1586,7 @@
Raise ParseError on malformatted messages. Unless 'force' is
true, do not uncompress possible zlib bombs.
"""
- #XXXX004 write unit tests
+ #XXXX write unit tests
results = []
for msg in parseTextEncodedMessages(s, force=force):
if msg.isOvercompressed() and not force:
@@ -1688,7 +1678,7 @@
we create a fresh one.
"""
if configFile is None:
- configFile = os.environ.get("MIXMINIONRC", None)
+ configFile = os.environ.get("MIXMINIONRC")
if configFile is None:
configFile = "~/.mixminionrc"
configFile = os.path.expanduser(configFile)
Index: Common.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Common.py,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- Common.py 5 Jun 2003 05:34:56 -0000 1.87
+++ Common.py 5 Jun 2003 18:41:40 -0000 1.88
@@ -501,7 +501,7 @@
global _SHRED_OPTS
cmd, opts = None, None
if conf is not None:
- val = conf['Host'].get('ShredCommand', None)
+ val = conf['Host'].get('ShredCommand')
if val is not None:
cmd, opts = val
@@ -710,8 +710,7 @@
self.addHandler(_ConsoleLogHandler(sys.stderr))
else:
self.setMinSeverity(config['Server'].get('LogLevel', "WARN"))
- logfile = config['Server'].get('LogFile',None)
- # ???? Does this even work if 'logfile' is not given?
+ logfile = config['Server'].get('LogFile')
if logfile is None:
homedir = config['Server']['Homedir']
if homedir:
Index: Config.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Config.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- Config.py 5 Jun 2003 05:48:38 -0000 1.46
+++ Config.py 5 Jun 2003 18:41:40 -0000 1.47
@@ -376,7 +376,6 @@
if not isPrintingAscii(contents):
raise ConfigError("Invalid characters in file")
- #FFFF We should really use xreadlines or something if we have a file.
fileLines = contents.split("\n")
if fileLines[-1] == '':
del fileLines[-1]
@@ -569,7 +568,7 @@
self._sectionEntries[secName] = sectionEntries
sectionEntryLines[secName] = entryLines
- secConfig = self._syntax.get(secName, None)
+ secConfig = self._syntax.get(secName)
if not secConfig:
LOG.warn("Skipping unrecognized section %s", secName)
@@ -634,7 +633,7 @@
assert rule == 'ALLOW*'
section[k] = map(parseFn,default)
- cb = self._callbacks.get(secName, None)
+ cb = self._callbacks.get(secName)
if cb:
cb(section, sectionEntries)
Index: Crypto.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Crypto.py,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- Crypto.py 5 Jun 2003 05:24:23 -0000 1.44
+++ Crypto.py 5 Jun 2003 18:41:40 -0000 1.45
@@ -655,7 +655,7 @@
none is provided, tries some sane defaults."""
global _TRNG_FILENAME
if config is not None:
- requestedFile = config['Host'].get('EntropySource', None)
+ requestedFile = config['Host'].get('EntropySource')
else:
requestedFile = None
Index: Main.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Main.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- Main.py 30 May 2003 05:16:15 -0000 1.46
+++ Main.py 5 Jun 2003 18:41:40 -0000 1.47
@@ -116,7 +116,7 @@
"unittests" : ( 'mixminion.test', 'testAll' ),
"benchmarks" : ( 'mixminion.benchmark', 'timeAll' ),
"send" : ( 'mixminion.ClientMain', 'runClient' ),
- # XXXX Obsolete; use "queue"; remove in 0.0.5
+ # XXXX005 Obsolete; use "queue"; remove in 0.0.5
"pool" : ( 'mixminion.ClientMain', 'runClient' ),
"queue" : ( 'mixminion.ClientMain', 'runClient' ),
"import-server" : ( 'mixminion.ClientMain', 'importServer' ),
Index: ServerInfo.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ServerInfo.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- ServerInfo.py 29 May 2003 03:37:02 -0000 1.46
+++ ServerInfo.py 5 Jun 2003 18:41:40 -0000 1.47
@@ -113,7 +113,7 @@
if k == 'Descriptor-Version' and v.strip() != '0.2':
raise ConfigError("Unrecognized descriptor version: %s"
% v.strip())
- #XXXX Remove sections with unrecognized versions.
+ # FFFF005 Remove sections with unrecognized versions.
return contents
@@ -227,14 +227,14 @@
def getCaps(self):
# FFFF refactor this once we have client addresses.
caps = []
- if not self['Incoming/MMTP'].get('Version',None):
+ if not self['Incoming/MMTP'].get('Version'):
return caps
- if self['Delivery/MBOX'].get('Version', None):
+ if self['Delivery/MBOX'].get('Version'):
caps.append('mbox')
- if self['Delivery/SMTP'].get('Version', None):
+ if self['Delivery/SMTP'].get('Version'):
caps.append('smtp')
# XXXX This next check is highly bogus.
- if self['Outgoing/MMTP'].get('Version',None):
+ if self['Outgoing/MMTP'].get('Version'):
caps.append('relay')
return caps
Index: benchmark.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/benchmark.py,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- benchmark.py 5 Jun 2003 05:34:56 -0000 1.39
+++ benchmark.py 5 Jun 2003 18:41:40 -0000 1.40
@@ -56,7 +56,7 @@
if iters < 1: iters = 1
nones = [None]*iters
if ov:
- overhead = loop_overhead.get(iters, None)
+ overhead = loop_overhead.get(iters)
if overhead is None:
overhead = loop_overhead[iters] = timeit_((
lambda:(lambda:None)()), iters, 0)
@@ -808,7 +808,7 @@
fn = mix_mktemp()
dh = mix_mktemp()
_ml.generate_cert(fn, p, p2, "A", "B", 100, 10000)
- dh_fname = os.environ.get("MM_TEST_DHPARAMS", None)
+ dh_fname = os.environ.get("MM_TEST_DHPARAMS")
if dh_fname and os.path.exists(dh_fname):
dh = dh_fname
elif dh_fname:
Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- test.py 5 Jun 2003 05:48:38 -0000 1.117
+++ test.py 5 Jun 2003 18:41:40 -0000 1.118
@@ -3008,7 +3008,7 @@
dhfile = f+"_dh"
pkfile = f+"_pk"
certfile = f+"_cert"
- dh_fname = os.environ.get("MM_TEST_DHPARAMS", None)
+ dh_fname = os.environ.get("MM_TEST_DHPARAMS")
if dh_fname and not USE_SLOW_MODE:
dhfile = dh_fname
if not os.path.exists(dh_fname):
@@ -4910,7 +4910,6 @@
class ServerKeysTests(unittest.TestCase):
def testServerKeyring(self):
- #XXXX004 rethink this
keyring = _getServerKeyring()
home = _FAKE_HOME
@@ -5407,7 +5406,6 @@
None, [None]*4, startAt=now+100*oneDay)
finally:
s = resumeLog()
- self.assertEquals(4, s.count("Not enough servers for distinct"))
self.assertEquals(4, s.count("to avoid same-server hops"))
self.assertEquals(3, s.count("Only one relay known"))
@@ -5559,6 +5557,10 @@
pathIs((p1[1],p2[0],p2[-1]), (bob, joe, joe))
eq((len(p1),len(p2)), (5,4))
+ # 1f. Half-path
+ p1,p2 = ppath(ks, None, "*3", email, halfPath=1)
+ eq((len(p1),len(p2)), (0,3))
+
# 2. Failing cases
raises = self.assertRaises
# Nonexistant server
@@ -5640,7 +5642,7 @@
fname = os.path.join(dirname, "surblog")
s = SURBLog(fname)
try:
- #XXXX writeme
+ #XXXX005 writeme
pass
finally:
s.close()