diff --git a/dtella/client/main.py b/dtella/client/main.py index a9602c4..f03c9ca 100644 --- a/dtella/client/main.py +++ b/dtella/client/main.py @@ -179,15 +179,15 @@ def startConnecting(self): # Get config from DNS def dns_cb(): try: + # 2011-08-21: New nodes ignore the value of 'when'. when, ipps = self.state.dns_ipcache except ValueError: pass else: random.shuffle(ipps) - age = max(time.time() - when, 0) for ipp in ipps: ad = Ad().setRawIPPort(ipp) - self.state.refreshPeer(ad, age) + self.state.refreshPeer(ad, 0) self.startInitialContact() diff --git a/dtella/common/core.py b/dtella/common/core.py index ea62a37..5bc4c40 100644 --- a/dtella/common/core.py +++ b/dtella/common/core.py @@ -934,8 +934,10 @@ def check_cb(src_n, src_ipp, rest): persist = bool(flags & PERSIST_BIT) - if rest: - raise BadPacketError("Extra data") + # 2011-08-21: allow 'rest' to be non-empty, in case we want to add + # new fields someday. + if len(rest) > 1024: + raise BadPacketError("Too much extra data") if not (5 <= expire <= 30*60): raise BadPacketError("Expire time out of range") @@ -1414,8 +1416,10 @@ def handlePacket_YR(self, ad, data): c_nbs, rest = self.decodeNodeList(rest) u_nbs, rest = self.decodeNodeList(rest) - if rest: - raise BadPacketError("Extra data") + # 2011-08-21: allow 'rest' to be non-empty, in case we want to add + # new fields someday. + if len(rest) > 1024: + raise BadPacketError("Too much extra data") if not (5 <= expire <= 30*60): raise BadPacketError("Expire time out of range") diff --git a/dtella/common/state.py b/dtella/common/state.py index a88ccb7..5065396 100644 --- a/dtella/common/state.py +++ b/dtella/common/state.py @@ -190,6 +190,7 @@ def setDNSIPCache(self, data): CHECK(len(data) % 6 == 4) + # 2011-08-21: New nodes ignore the value of 'when'. when, = struct.unpack("!I", data[:4]) ipps = [data[i:i+6] for i in range(4, len(data), 6)]