[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] Check Packet-Versions before using any server
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv12392/lib/mixminion
Modified Files:
BuildMessage.py ClientDirectory.py Packet.py ServerInfo.py
test.py
Log Message:
Check Packet-Versions before using any server
Index: BuildMessage.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/BuildMessage.py,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- BuildMessage.py 3 Jan 2004 07:35:23 -0000 1.67
+++ BuildMessage.py 7 Jan 2004 02:50:08 -0000 1.68
@@ -548,6 +548,10 @@
"""
assert len(path) == len(secrets)
+ for info in path:
+ if not info.supportsPacketVersion():
+ raise MixError("Server %s does not support any recognized packet format."%info.getNickname())
+
routing, sizes, totalSize = _getRouting(path, exitType, exitInfo)
if totalSize > HEADER_LEN:
raise MixError("Path cannot fit in header")
Index: ClientDirectory.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientDirectory.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- ClientDirectory.py 3 Jan 2004 07:35:23 -0000 1.23
+++ ClientDirectory.py 7 Jan 2004 02:50:08 -0000 1.24
@@ -447,6 +447,8 @@
for info, _ in lst:
if not info.isValidFrom(startAt, endAt):
continue
+ if not info.supportsPacketVersion():
+ continue
n = info.getNickname().lower()
if u.has_key(n):
if u[n].isNewerThan(info):
@@ -759,6 +761,9 @@
prevFixed = None
for e in p:
fixed = e.getFixedServer(self, startAt, endAt)
+ if fixed and not fixed.supportsPacketVersion():
+ raise UIError("We don't support any packet formats used by %s",
+ fixed.getNickname())
if prevFixed and fixed and not prevFixed.canRelayTo(fixed):
raise UIError("Server %s can't relay to %s" %
prevFixed.getNickname(), fixed.getNickname())
@@ -1120,7 +1125,8 @@
assert self.lastHop is None
liveServers = directory.getLiveServers(startAt, endAt)
result = [ desc for desc in liveServers
- if self.isSupportedByServer(desc) ]
+ if self.isSupportedByServer(desc) and
+ desc.supportsPacketVersion() ]
return result
def getRouting(self):
Index: Packet.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Packet.py,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- Packet.py 3 Jan 2004 07:35:23 -0000 1.71
+++ Packet.py 7 Jan 2004 02:50:08 -0000 1.72
@@ -48,6 +48,7 @@
# Major and minor number for the understood packet format.
MAJOR_NO, MINOR_NO = 0,3
+PACKET_VERSION = "%s.%s"%(MAJOR_NO,MINOR_NO)
# Length of a Mixminion packet
PACKET_LEN = 1 << 15
Index: ServerInfo.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ServerInfo.py,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- ServerInfo.py 3 Jan 2004 07:35:23 -0000 1.71
+++ ServerInfo.py 7 Jan 2004 02:50:08 -0000 1.72
@@ -118,8 +118,8 @@
"Packet-Key": ("REQUIRE", "publicKey", None),
"Contact-Fingerprint": ("ALLOW", None, None),
"Packet-Formats": ("ALLOW", None, None),#XXXX007 remove
- # XXXX010 change these next few to "REQUIRE".
- "Packet-Versions": ("ALLOW", None, None),
+ # XXXX008 change these next few to "REQUIRE".
+ "Packet-Versions": ("ALLOW", None, '0.3'),
"Software": ("ALLOW", None, None),
"Secure-Configuration": ("ALLOW", "boolean", None),
"Why-Insecure": ("ALLOW", None, None),
@@ -374,6 +374,13 @@
return []
return [ s.strip() for s in inc["Protocols"].split(",") ]
+ def supportsPacketVersion(self):
+ """Return true iff we can build packets in a format this server
+ recognizes."""
+ formatStr = self['Server'].get("Packet-Versions", "0.3")
+ formats = [ s.strip() for s in formatStr.split(",") ]
+ return mixminion.Packet.PACKET_VERSION in formats
+
def canRelayTo(self, otherDesc):
"""Return true iff this server can relay packets to the server
described by otherDesc."""
Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -d -r1.173 -r1.174
--- test.py 3 Jan 2004 07:35:23 -0000 1.173
+++ test.py 7 Jan 2004 02:50:08 -0000 1.174
@@ -1796,6 +1796,7 @@
def getPort(self): return self.port
def getPacketKey(self): return self.key
def getKeyDigest(self): return self.keyid
+ def supportsPacketVersion(self): return 1
def getRoutingInfo(self):
return IPV4Info(self.addr, self.port, self.keyid)