diff options
Diffstat (limited to 'net/bittorrent')
-rw-r--r-- | net/bittorrent/patches/patch-ab | 13 | ||||
-rw-r--r-- | net/bittorrent/patches/patch-ac | 57 | ||||
-rw-r--r-- | net/bittorrent/patches/patch-ad | 87 |
3 files changed, 157 insertions, 0 deletions
diff --git a/net/bittorrent/patches/patch-ab b/net/bittorrent/patches/patch-ab new file mode 100644 index 00000000000..75817a76472 --- /dev/null +++ b/net/bittorrent/patches/patch-ab @@ -0,0 +1,13 @@ +$NetBSD: patch-ab,v 1.1 2004/03/09 10:33:22 recht Exp $ + +--- btreannounce.py.orig 2004-03-07 22:50:01.000000000 +0100 ++++ btreannounce.py 2004-03-07 22:50:12.000000000 +0100 +@@ -3,7 +3,7 @@ + # Written by Henry 'Pi' James and Bram Cohen + # see LICENSE.txt for license information + +-from sys import argv ++from sys import argv, exit + from BitTorrent.bencode import bencode, bdecode + + if len(argv) < 3: diff --git a/net/bittorrent/patches/patch-ac b/net/bittorrent/patches/patch-ac new file mode 100644 index 00000000000..79b9b4cec43 --- /dev/null +++ b/net/bittorrent/patches/patch-ac @@ -0,0 +1,57 @@ +$NetBSD: patch-ac,v 1.1 2004/03/09 10:33:22 recht Exp $ + +--- BitTorrent/RawServer.py.orig 2004-02-07 14:35:06.000000000 +0100 ++++ BitTorrent/RawServer.py 2004-03-09 11:11:09.000000000 +0100 +@@ -75,8 +75,12 @@ + else: + self.raw_server.poll.register(self.socket, all) + ++def default_error_handler(x): ++ print x ++ + class RawServer: +- def __init__(self, doneflag, timeout_check_interval, timeout, noisy = True, errorfunc = None, maxconnects = 55): ++ def __init__(self, doneflag, timeout_check_interval, timeout, noisy = True, ++ errorfunc = default_error_handler, maxconnects = 55): + self.timeout_check_interval = timeout_check_interval + self.timeout = timeout + self.poll = poll() +@@ -114,6 +118,10 @@ + if reuse: + server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + server.setblocking(0) ++ try: ++ server.setsockopt(socket.IPPROTO_IP, socket.IP_TOS, 32) ++ except: ++ pass + server.bind((bind, port)) + server.listen(5) + self.poll.register(server, POLLIN) +@@ -147,7 +155,6 @@ + try: + newsock, addr = self.server.accept() + newsock.setblocking(0) +- newsock.setsockopt(socket.IPPROTO_IP, socket.IP_TOS, 32) + if len(self.single_sockets) >= self.maxconnects: + newsock.close() + continue +@@ -224,16 +231,16 @@ + if self.doneflag.isSet(): + return + self._close_dead() +- except error: ++ except error, e: + if self.doneflag.isSet(): + return + # I can't find a coherent explanation for what the behavior should be here, + # and people report conflicting behavior, so I'll just try all the possibilities + try: +- code, msg, desc = error ++ code, msg, desc = e + except: + try: +- code, msg = error ++ code, msg = e + except: + code = ENOBUFS + if code == ENOBUFS: diff --git a/net/bittorrent/patches/patch-ad b/net/bittorrent/patches/patch-ad new file mode 100644 index 00000000000..e473e8fe3fc --- /dev/null +++ b/net/bittorrent/patches/patch-ad @@ -0,0 +1,87 @@ +$NetBSD: patch-ad,v 1.1 2004/03/09 10:33:22 recht Exp $ + +--- BitTorrent/track.py.orig 2004-02-26 05:06:06.000000000 +0100 ++++ BitTorrent/track.py 2004-03-09 11:11:03.000000000 +0100 +@@ -148,9 +148,9 @@ + for y, dat in dl.items(): + self.times[x][y] = 0 + if not dat.get('nat',1): +- self.becache1.setdefault(downloadid,{})[y] = Bencached(bencode({'ip': dat['ip'], ++ self.becache1.setdefault(x,{})[y] = Bencached(bencode({'ip': dat['ip'], + 'port': dat['port'], 'peer id': y})) +- self.becache2.setdefault(downloadid,{})[y] = Bencached(bencode({'ip': dat['ip'], ++ self.becache2.setdefault(x,{})[y] = Bencached(bencode({'ip': dat['ip'], + 'port': dat['port']})) + self.reannounce_interval = config['reannounce_interval'] + self.save_dfile_interval = config['save_dfile_interval'] +@@ -351,6 +351,9 @@ + peers[myid] = {'ip': ip, 'port': port, 'left': left, "local_override" : local_override} + else: + peers[myid] = {'ip': ip, 'port': port, 'left': left} ++ if not self.natcheck or local_override: ++ self.becache1.setdefault(infohash,{})[myid] = Bencached(bencode({'ip': ip, 'port': port, 'peer id': myid})) ++ self.becache2.setdefault(infohash,{})[myid] = Bencached(bencode({'ip': ip, 'port': port})) + else: + peers[myid]['left'] = left + if params.get('event', '') == 'completed': +@@ -365,26 +368,25 @@ + peers[myid]['nat'] = 0 + else: + if peers.has_key(myid) and peers[myid]['ip'] == ip: +- if not peers[myid].get('nat',1): ++ try: + del self.becache1[infohash][myid] + del self.becache2[infohash][myid] ++ except KeyError: ++ pass + del peers[myid] + del ts[myid] + data = {'interval': self.reannounce_interval} +- cache1 = self.cache1.setdefault(infohash, []) +- cache2 = self.cache2.setdefault(infohash, []) +- if params.get('no_peer_id',0): +- cache = cache2 +- else: +- cache = cache1 + if rsize > 0: ++ if params.get('no_peer_id', 0): ++ cache = self.cache2.setdefault(infohash, []) ++ b = self.becache2 ++ else: ++ cache = self.cache1.setdefault(infohash, []) ++ b = self.becache1 + if len(cache) < rsize: +- del cache1[:] +- cache1.extend(self.becache1[infohash].values()) +- shuffle(cache1) +- del cache2[:] +- cache2.extend(self.becache2[infohash].values()) +- shuffle(cache2) ++ del cache[:] ++ cache.extend(b.setdefault(infohash, {}).values()) ++ shuffle(cache) + data['peers'] = cache[-rsize:] + del cache[-rsize:] + else: +@@ -403,7 +405,7 @@ + else: + record['nat'] += 1 + if result: +- self.becache1.setdefault(downloadid,{})[peerid] = Bencached(bencode({'ip': ip, 'port': port, 'peer id': myid})) ++ self.becache1.setdefault(downloadid,{})[peerid] = Bencached(bencode({'ip': ip, 'port': port, 'peer id': peerid})) + self.becache2.setdefault(downloadid,{})[peerid] = Bencached(bencode({'ip': ip, 'port': port})) + + def save_dfile(self): +@@ -420,9 +422,11 @@ + for x in self.times.keys(): + for myid, t in self.times[x].items(): + if t < self.prevtime: +- if not self.downloads[x][myid].get('nat',1): ++ try: + del self.becache1[x][myid] + del self.becache2[x][myid] ++ except KeyError: ++ pass + del self.times[x][myid] + del self.downloads[x][myid] + self.prevtime = time() |