pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/net/bittorrent Add a couple of patches from the FreeBS...
details: https://anonhg.NetBSD.org/pkgsrc/rev/ab3d530634ed
branches: trunk
changeset: 488961:ab3d530634ed
user: recht <recht%pkgsrc.org@localhost>
date: Sun Feb 13 13:53:34 2005 +0000
description:
Add a couple of patches from the FreeBSD port:
patch-BitTorrent::Rerequester.py
o Chase latest CVS version
- Add {show_infopage,infopage_redirect,scrape_allowed}
options to tracker
- Try to resolve IPs when possible
patch-BitTorrent::track.py
o Chase latest CVS version
- Add {show_infopage,infopage_redirect,scrape_allowed}
options to tracker
- Try to resolve IPs when possible
patch-BitTorrent::zurllib.py
o A better fix for the python 2.4 issue: there are still some minor
adjustments required but the port is quite useable again
patch-btcompletedir.py
o Chase latest CVS version
- Add {show_infopage,infopage_redirect,scrape_allowed}
options to tracker
- Try to resolve IPs when
Bump PKGREVISION.
diffstat:
net/bittorrent/Makefile | 4 +-
net/bittorrent/distinfo | 10 +-
net/bittorrent/patches/patch-aa | 8 +-
net/bittorrent/patches/patch-ab | 6 +-
net/bittorrent/patches/patch-ac | 32 ++++
net/bittorrent/patches/patch-ad | 302 ++++++++++++++++++++++++++++++++++++++++
net/bittorrent/patches/patch-ae | 20 ++
net/bittorrent/patches/patch-af | 13 +
8 files changed, 383 insertions(+), 12 deletions(-)
diffs (truncated from 446 to 300 lines):
diff -r de52e3b8d932 -r ab3d530634ed net/bittorrent/Makefile
--- a/net/bittorrent/Makefile Sun Feb 13 13:12:14 2005 +0000
+++ b/net/bittorrent/Makefile Sun Feb 13 13:53:34 2005 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.23 2004/10/03 00:17:49 tv Exp $
+# $NetBSD: Makefile,v 1.24 2005/02/13 13:53:34 recht Exp $
#
.include "Makefile.common"
PKGNAME= ${DISTNAME:S/BitT/bitt/}
-PKGREVISION= 1
+PKGREVISION= 2
PYDISTUTILSPKG= YES
diff -r de52e3b8d932 -r ab3d530634ed net/bittorrent/distinfo
--- a/net/bittorrent/distinfo Sun Feb 13 13:12:14 2005 +0000
+++ b/net/bittorrent/distinfo Sun Feb 13 13:53:34 2005 +0000
@@ -1,6 +1,10 @@
-$NetBSD: distinfo,v 1.11 2004/05/25 12:42:19 wiz Exp $
+$NetBSD: distinfo,v 1.12 2005/02/13 13:53:34 recht Exp $
SHA1 (BitTorrent-3.4.2.zip) = e3c34b0988369e706564f24fc63d9921c6af8298
Size (BitTorrent-3.4.2.zip) = 244989 bytes
-SHA1 (patch-aa) = 8c3abb81127bda1594b944fd6e11f587e8477e87
-SHA1 (patch-ab) = 186ad86d153bc0c7a3e3234c03ec854b2325cb03
+SHA1 (patch-aa) = 95bb805f2b906c91bf36ecb7ce289cab84242ca9
+SHA1 (patch-ab) = ece6faa60d27df84f1c5d5b64f8d5c61fb79dc6e
+SHA1 (patch-ac) = ff3f9963f017cf0f967a7355116819deb64a861d
+SHA1 (patch-ad) = 46d79fa604516f6aab196eb3d91d546702977fa5
+SHA1 (patch-ae) = 5ce8d3808396c091e7e60f4de88d93064ac470dc
+SHA1 (patch-af) = 21a9ddf3b2d69728582f3ee4fd5d68a55a5b826a
diff -r de52e3b8d932 -r ab3d530634ed net/bittorrent/patches/patch-aa
--- a/net/bittorrent/patches/patch-aa Sun Feb 13 13:12:14 2005 +0000
+++ b/net/bittorrent/patches/patch-aa Sun Feb 13 13:53:34 2005 +0000
@@ -1,8 +1,8 @@
-$NetBSD: patch-aa,v 1.4 2004/03/03 10:02:08 recht Exp $
+$NetBSD: patch-aa,v 1.5 2005/02/13 13:53:34 recht Exp $
---- setup.py.orig 2004-03-03 01:16:06.000000000 +0100
-+++ setup.py 2004-03-03 01:16:42.000000000 +0100
-@@ -18,9 +18,9 @@
+--- setup.py.orig Mon Mar 17 20:34:41 2003
++++ setup.py
+@@ -18,9 +18,9 @@ setup(
packages = ["BitTorrent"],
diff -r de52e3b8d932 -r ab3d530634ed net/bittorrent/patches/patch-ab
--- a/net/bittorrent/patches/patch-ab Sun Feb 13 13:12:14 2005 +0000
+++ b/net/bittorrent/patches/patch-ab Sun Feb 13 13:53:34 2005 +0000
@@ -1,7 +1,7 @@
-$NetBSD: patch-ab,v 1.1 2004/03/09 10:33:22 recht Exp $
+$NetBSD: patch-ab,v 1.2 2005/02/13 13:53:34 recht Exp $
---- btreannounce.py.orig 2004-03-07 22:50:01.000000000 +0100
-+++ btreannounce.py 2004-03-07 22:50:12.000000000 +0100
+--- btreannounce.py.orig Mon Mar 17 20:26:40 2003
++++ btreannounce.py
@@ -3,7 +3,7 @@
# Written by Henry 'Pi' James and Bram Cohen
# see LICENSE.txt for license information
diff -r de52e3b8d932 -r ab3d530634ed net/bittorrent/patches/patch-ac
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/net/bittorrent/patches/patch-ac Sun Feb 13 13:53:34 2005 +0000
@@ -0,0 +1,32 @@
+$NetBSD: patch-ac,v 1.3 2005/02/13 13:53:34 recht Exp $
+
+--- BitTorrent/Rerequester.py.orig Sat Apr 3 06:10:45 2004
++++ BitTorrent/Rerequester.py
+@@ -5,7 +5,7 @@ from zurllib import urlopen, quote
+ from btformats import check_peers
+ from bencode import bdecode
+ from threading import Thread, Lock
+-from socket import error
++from socket import error, gethostbyname
+ from time import time
+ from random import randrange
+ from binascii import b2a_hex
+@@ -18,8 +18,7 @@ class Rerequester:
+ 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)
++ self.ip = ip
+ self.interval = interval
+ self.last = None
+ self.trackerid = None
+@@ -81,6 +80,8 @@ class Rerequester:
+
+ def rerequest(self, url, set):
+ try:
++ if self.ip:
++ url += '&ip=' + gethostbyname(self.ip)
+ h = urlopen(url)
+ r = h.read()
+ h.close()
diff -r de52e3b8d932 -r ab3d530634ed net/bittorrent/patches/patch-ad
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/net/bittorrent/patches/patch-ad Sun Feb 13 13:53:34 2005 +0000
@@ -0,0 +1,302 @@
+$NetBSD: patch-ad,v 1.3 2005/02/13 13:53:34 recht Exp $
+
+--- BitTorrent/track.py.orig Sun Mar 21 20:33:17 2004
++++ BitTorrent/track.py
+@@ -37,12 +37,15 @@ defaults = [
+ 'minimum time it must have been since the last flush to do another one'),
+ ('allowed_dir', '', 'only allow downloads for .torrents in this dir'),
+ ('parse_allowed_interval', 15, 'minutes between reloading of allowed_dir'),
++ ('show_infopage', 1, "whether to display an info page when the tracker's root dir is loaded"),
++ ('infopage_redirect', '', 'a URL to redirect the info page to'),
+ ('show_names', 1, 'whether to display names from allowed dir'),
+ ('favicon', '', 'file containing x-icon data to return when browser requests favicon.ico'),
+ ('only_local_override_ip', 1, "ignore the ip GET parameter from machines which aren't on local network IPs"),
+ ('logfile', '', 'file to write the tracker logs, use - for stdout (default)'),
+ ('allow_get', 0, 'use with allowed_dir; adds a /file?hash={hash} url that allows users to download the torrent file'),
+ ('keep_dead', 0, 'keep dead torrents after they expire (so they still show up on your /scrape and web page)'),
++ ('scrape_allowed', 'full', 'scrape access allowed (can be none, specific or full)'),
+ ('max_give', 200, 'maximum number of peers to give with any one request'),
+ ]
+
+@@ -124,11 +127,11 @@ class Tracker:
+ favicon = config['favicon']
+ self.favicon = None
+ if favicon:
+- if isfile(favicon):
++ try:
+ h = open(favicon, 'rb')
+ self.favicon = h.read()
+ h.close()
+- else:
++ except:
+ print "**warning** specified favicon file -- %s -- does not exist." % favicon
+ self.rawserver = rawserver
+ self.becache1 = {}
+@@ -190,6 +193,130 @@ class Tracker:
+ self.uq_broken = 0
+ self.keep_dead = config['keep_dead']
+
++ def get_infopage(self):
++ if not self.config['show_infopage']:
++ return (404, 'Not Found', {'Content-Type': 'text/plain', 'Pragma': 'no-cache'}, alas)
++ red = self.config['infopage_redirect']
++ if red != '':
++ return (302, 'Found', {'Content-Type': 'text/html', 'Location': red},
++ '<A HREF="'+red+'">Click Here</A>')
++
++ s = StringIO()
++ s.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n' \
++ '<html><head><title>BitTorrent download info</title>\n')
++ if self.favicon != None:
++ s.write('<link rel="shortcut icon" href="/favicon.ico" />\n')
++ s.write('</head>\n<body>\n' \
++ '<h3>BitTorrent download info</h3>\n'\
++ '<ul>\n'
++ '<li><strong>tracker version:</strong> %s</li>\n' \
++ '<li><strong>server time:</strong> %s</li>\n' \
++ '</ul>\n' % (version, isotime()))
++ names = self.downloads.keys()
++ if not names:
++ s.write('<p>not tracking any files yet...</p>\n')
++ else:
++ names.sort()
++ tn = 0
++ tc = 0
++ td = 0
++ tt = 0 # Total transferred
++ ts = 0 # Total size
++ nf = 0 # Number of files displayed
++ uc = {}
++ ud = {}
++ if self.allowed != None and self.show_names:
++ s.write('<table summary="files" border="1">\n' \
++ '<tr><th>info hash</th><th>torrent name</th><th align="right">size</th><th align="right">complete</th><th align="right">downloading</th><th align="right">downloaded</th><th
align="right">transferred</th></tr>\n')
++ else:
++ s.write('<table summary="files">\n' \
++ '<tr><th>info hash</th><th align="right">complete</th><th align="right">downloading</th><th align="right">downloaded</th></tr>\n')
++ for name in names:
++ l = self.downloads[name]
++ n = self.completed.get(name, 0)
++ tn = tn + n
++ lc = []
++ for i in l.values():
++ if type(i) == DictType:
++ if i['left'] == 0:
++ lc.append(1)
++ uc[i['ip']] = 1
++ else:
++ ud[i['ip']] = 1
++ c = len(lc)
++ tc = tc + c
++ d = len(l) - c
++ td = td + d
++ if self.allowed != None and self.show_names:
++ if self.allowed.has_key(name):
++ nf = nf + 1
++ sz = self.allowed[name]['length'] # size
++ ts = ts + sz
++ szt = sz * n # Transferred for this torrent
++ tt = tt + szt
++ if self.allow_get == 1:
++ linkname = '<a href="/file?info_hash=' + quote(name) + '">' + self.allowed[name]['name'] + '</a>'
++ else:
++ linkname = self.allowed[name]['name']
++ s.write('<tr><td><code>%s</code></td><td>%s</td><td align="right">%s</td><td align="right">%i</td><td align="right">%i</td><td align="right">%i</td><td
align="right">%s</td></tr>\n' \
++ % (b2a_hex(name), linkname, size_format(sz), c, d, n, size_format(szt)))
++ else:
++ s.write('<tr><td><code>%s</code></td><td align="right"><code>%i</code></td><td align="right"><code>%i</code></td><td align="right"><code>%i</code></td></tr>\n' \
++ % (b2a_hex(name), c, d, n))
++ ttn = 0
++ for i in self.completed.values():
++ ttn = ttn + i
++ if self.allowed != None and self.show_names:
++ s.write('<tr><td align="right" colspan="2">%i files</td><td align="right">%s</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td
align="right">%s</td></tr>\n'
++ % (nf, size_format(ts), len(uc), tc, len(ud), td, tn, ttn, size_format(tt)))
++ else:
++ s.write('<tr><td align="right">%i files</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td align="right">%i/%i</td></tr>\n'
++ % (nf, len(uc), tc, len(ud), td, tn, ttn))
++ s.write('</table>\n' \
++ '<ul>\n' \
++ '<li><em>info hash:</em> SHA1 hash of the "info" section of the metainfo (*.torrent)</li>\n' \
++ '<li><em>complete:</em> number of connected clients with the complete file (total: unique IPs/total connections)</li>\n' \
++ '<li><em>downloading:</em> number of connected clients still downloading (total: unique IPs/total connections)</li>\n' \
++ '<li><em>downloaded:</em> reported complete downloads (total: current/all)</li>\n' \
++ '<li><em>transferred:</em> torrent size * total downloaded (does not include partial transfers)</li>\n' \
++ '</ul>\n')
++ s.write('</body>\n' \
++ '</html>\n')
++ return (200, 'OK', {'Content-Type': 'text/html; charset=iso-8859-1'}, s.getvalue())
++
++ def scrapedata(self, name, return_name = True):
++ l = self.downloads[name]
++ n = self.completed.get(name, 0)
++ c = len([1 for i in l.values() if i['left'] == 0])
++ d = len(l) - c
++ f = {'complete': c, 'incomplete': d, 'downloaded': n}
++ if ( return_name and self.show_names
++ and self.allowed is not None and self.allowed.has_key(name) ):
++ f['name'] = self.allowed[name]['name']
++ return (f)
++
++ def get_scrape(self, paramslist):
++ fs = {}
++ if paramslist.has_key('info_hash'):
++ if self.config['scrape_allowed'] not in ['specific', 'full']:
++ return (400, 'Not Authorized', {'Content-Type': 'text/plain', 'Pragma': 'no-cache'},
++ bencode({'failure reason':
++ 'specific scrape function is not available with this tracker.'}))
++ for infohash in paramslist['info_hash']:
++ if infohash in self.downloads.keys():
++ fs[infohash] = self.scrapedata(infohash)
++ else:
++ if self.config['scrape_allowed'] != 'full':
++ return (400, 'Not Authorized', {'Content-Type': 'text/plain', 'Pragma': 'no-cache'},
++ bencode({'failure reason':
++ 'full scrape function is not available with this tracker.'}))
++ names = self.downloads.keys()
++ names.sort()
++ for name in names:
++ fs[name] = self.scrapedata(name)
++
++ return (200, 'OK', {'Content-Type': 'text/plain'}, bencode({'files': fs}))
++
+ def get(self, connection, path, headers):
+ try:
+ (scheme, netloc, path, pars, query, fragment) = urlparse(path)
+@@ -197,117 +324,22 @@ class Tracker:
+ path = path.replace('+',' ')
+ query = query.replace('+',' ')
+ path = unquote(path)[1:]
++ paramslist = {}
+ params = {}
+ for s in query.split('&'):
+ if s != '':
+ i = s.index('=')
+- params[unquote(s[:i])] = unquote(s[i+1:])
++ kw = unquote(s[:i])
++ key, value = unquote(s[:i]), unquote(s[i+1:])
++ paramslist.setdefault(key, []).append(value)
++ params[key] = value
+ except ValueError, e:
+ return (400, 'Bad Request', {'Content-Type': 'text/plain'},
+ 'you sent me garbage - ' + str(e))
+ if path == '' or path == 'index.html':
+- s = StringIO()
+- s.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n' \
+- '<html><head><title>BitTorrent download info</title>\n')
+- if self.favicon != None:
+- s.write('<link rel="shortcut icon" href="/favicon.ico" />\n')
+- s.write('</head>\n<body>\n' \
+- '<h3>BitTorrent download info</h3>\n'\
+- '<ul>\n'
+- '<li><strong>tracker version:</strong> %s</li>\n' \
+- '<li><strong>server time:</strong> %s</li>\n' \
+- '</ul>\n' % (version, isotime()))
+- names = self.downloads.keys()
+- if names:
+- names.sort()
Home |
Main Index |
Thread Index |
Old Index