From: Cameron Dale Date: Fri, 11 Jan 2008 18:51:32 +0000 (-0800) Subject: Upgrade the security in khashmir by using longer TIDs. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=831e4f2adebf21b0427edde718668356a8df4837;p=quix0rs-apt-p2p.git Upgrade the security in khashmir by using longer TIDs. --- diff --git a/TODO b/TODO index 9b4f748..eca4e13 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,3 @@ -Upgrade the security in khashmir by using longer TIDs. - -The TIDs sent with every request that must be echoed on response are -very short (one char). They should be lengthened to 20 using the NewID() -function from khash. - - Hashes of files need to be stored permanently. A new database of files and their hashes is needed. It should store the @@ -13,6 +6,9 @@ so we can check if a file needs to be rehashed on startup. The DB can also be used to store info needed to manage the values stored in the DHT. +Change all print statements to log.msg() calls. + + Add ability to search and hash and DHT-store other directories. The user should be able to specify a list of directories that will be diff --git a/apt_dht_Khashmir/krpc.py b/apt_dht_Khashmir/krpc.py index 40ab8d8..441079c 100644 --- a/apt_dht_Khashmir/krpc.py +++ b/apt_dht_Khashmir/krpc.py @@ -10,6 +10,8 @@ from twisted.internet.defer import Deferred from twisted.internet import protocol, reactor from twisted.trial import unittest +from khash import newID + KRPC_TIMEOUT = 20 KRPC_ERROR = 1 @@ -71,7 +73,6 @@ class KRPC: self.addr = addr self.noisy = spew self.tids = {} - self.mtid = 0 self.stopped = False def datagramReceived(self, str, addr): @@ -157,8 +158,7 @@ class KRPC: raise ProtocolError, "connection has been stopped" # make message # send it - msg = {TID : chr(self.mtid), TYP : REQ, REQ : method, ARG : args} - self.mtid = (self.mtid + 1) % 256 + msg = {TID : newID(), TYP : REQ, REQ : method, ARG : args} if self.noisy: print self.factory.port, "sending to", self.addr, ":", msg str = bencode(msg)