RCS file: /opt/src/cvsroot/bittorrent/BitTorrent/Rerequester.py,v retrieving revision 1.1.1.7 retrieving revision 1.1.1.7.2.2 diff -c -u -r1.1.1.7 -r1.1.1.7.2.2 cvs diff: conflicting specifications of output style --- BitTorrent/Rerequester.py 13 Apr 2004 02:22:07 -0000 1.1.1.7 +++ BitTorrent/Rerequester.py 29 Sep 2004 22:18:49 -0000 1.1.1.7.2.2 @@ -14,12 +14,30 @@ def __init__(self, url, interval, sched, howmany, minpeers, connect, externalsched, amount_left, up, down, port, ip, myid, infohash, timeout, errorfunc, maxpeers, doneflag, - upratefunc, downratefunc, ever_got_incoming): + upratefunc, downratefunc, ever_got_incoming,announce_list=None): self.url = ('%s?info_hash=%s&peer_id=%s&port=%s&key=%s' % (url, quote(infohash), quote(myid), str(port), b2a_hex(''.join([chr(randrange(256)) for i in xrange(4)])))) if ip != '': self.url += '&ip=' + quote(ip) + + if announce_list : + if url not in announce_list : + announce_list.append(url) + self.announce_list=[] # Mutable + for i in announce_list : + url= ('%s?info_hash=%s&peer_id=%s&port=%s&key=%s' % + (i, quote(infohash), quote(myid), str(port), + b2a_hex(''.join([chr(randrange(256)) for i in xrange(4)])))) + if ip != '' : + url += '&ip=' + quote(ip) + self.announce_list.append(url) + import random + random.seed() + random.shuffle(self.announce_list) + else : + self.announce_list=None + self.interval = interval self.last = None self.trackerid = None @@ -76,6 +94,10 @@ if self.last_failed and self.upratefunc() < 100 and self.downratefunc() < 100: self.errorfunc('Problem connecting to tracker - timeout exceeded') self.last_failed = True + if self.announce_list : + self.url=self.announce_list.pop(0) + self.announce_list.append(self.url) + self.sched(checkfail, self.timeout) Thread(target = self.rerequest, args = [s, set]).start() @@ -95,6 +117,10 @@ if self.last_failed: self.errorfunc(r) self.last_failed = True + if self.announce_list : + self.url=self.announce_list.pop(0) + self.announce_list.append(self.url) + self.externalsched(fail, 0) def postrequest(self, data): Index: BitTorrent/download.py =================================================================== RCS file: /opt/src/cvsroot/bittorrent/BitTorrent/download.py,v retrieving revision 1.1.1.13.2.1 retrieving revision 1.1.1.13.2.2 diff -c -u -r1.1.1.13.2.1 -r1.1.1.13.2.2 cvs diff: conflicting specifications of output style --- BitTorrent/download.py 15 Apr 2004 13:18:36 -0000 1.1.1.13.2.1 +++ BitTorrent/download.py 29 Sep 2004 21:54:19 -0000 1.1.1.13.2.2 @@ -270,6 +270,20 @@ encoder = Encoder(connecter, rawserver, myid, config['max_message_length'], rawserver.add_task, config['keepalive_interval'], infohash, config['max_initiate']) + + announce_list=response.get('announce-list') + def plano(a) : + import types + r=[] + for i in a : + if type(i) in types.StringTypes : + r.append(i) + else : + r.extend(plano(i)) + return r + if announce_list : + announce_list=plano(announce_list) + rerequest = Rerequester(response['announce'], config['rerequest_interval'], rawserver.add_task, connecter.how_many_connections, config['min_peers'], encoder.start_connection, @@ -277,7 +291,7 @@ upmeasure.get_total, downmeasure.get_total, listen_port, config['ip'], myid, infohash, config['http_timeout'], errorfunc, config['max_initiate'], doneflag, upmeasure.get_rate, downmeasure.get_rate, - encoder.ever_got_incoming) + encoder.ever_got_incoming,announce_list=announce_list) if config['spew']: spewflag.set() DownloaderFeedback(choker, rawserver.add_task, statusfunc,