Package: bittorrent
Version: 3.4.2-11
Followup-For: Bug #481276
Here's the same patch, except that I have added the new parameters to the
manpage for bittorrent-downloader.
-- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (500, 'testing'), (500, 'stable'), (1, 'experimental'), (1,
'unstable'), (1, 'testing'), (1, 'stable')
Architecture: i386 (i686)
Kernel: Linux 2.6.24-1-686 (SMP w/1 CPU core)
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages bittorrent depends on:
ii lsb-base 3.2-11 Linux Standard Base 3.2 init scrip
ii python 2.5.2-1 An interactive high-level object-o
ii python-support 0.7.7 automated rebuilding support for P
Versions of packages bittorrent recommends:
ii mime-support 3.40-1.1 MIME files 'mime.types' & 'mailcap
diff -Naur bittorrent-3.4.2-11-pristine/BitTorrent/download.py
bittorrent-3.4.2/BitTorrent/download.py
--- bittorrent-3.4.2-11-pristine/BitTorrent/download.py 2004-04-02
23:10:45.000000000 -0500
+++ bittorrent-3.4.2/BitTorrent/download.py 2008-05-24 12:26:06.000000000
-0400
@@ -92,6 +92,10 @@
"the number of uploads to fill out to with extra optimistic unchokes"),
('report_hash_failures', 0,
"whether to inform the user that hash failures occur. They're
non-fatal."),
+ ('min_outgoing_port', 1024,
+ "lowest port to which we are willing to connect"),
+ ('max_outgoing_port', 65535,
+ "highest port to which we are willing to connect"),
]
def download(params, filefunc, statusfunc, finfunc, errorfunc, doneflag, cols,
pathFunc = None, paramfunc = None, spewflag = Event()):
@@ -242,6 +246,13 @@
errorfunc("Couldn't listen - " + str(e))
return
+ if config['min_outgoing_port'] < 1024 or config['max_outgoing_port'] >
65535:
+ errorfunc("We can only connect to peers using ports between 1024 and
65535")
+ return
+ if config['min_outgoing_port'] > config['max_outgoing_port']:
+ errorfunc("max_outgoing_port less than min_outgoing_port; can't
connect")
+ return
+
choker = Choker(config['max_uploads'], rawserver.add_task, finflag.isSet,
config['min_uploads'])
upmeasure = Measure(config['max_rate_period'],
@@ -277,7 +288,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, config['min_outgoing_port'],
config['max_outgoing_port'])
if config['spew']:
spewflag.set()
DownloaderFeedback(choker, rawserver.add_task, statusfunc,
diff -Naur bittorrent-3.4.2-11-pristine/BitTorrent/Rerequester.py
bittorrent-3.4.2/BitTorrent/Rerequester.py
--- bittorrent-3.4.2-11-pristine/BitTorrent/Rerequester.py 2004-04-02
23:10:45.000000000 -0500
+++ bittorrent-3.4.2/BitTorrent/Rerequester.py 2008-05-24 12:26:06.000000000
-0400
@@ -14,7 +14,7 @@
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, min_outgoing,
max_outgoing):
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)]))))
@@ -41,6 +41,8 @@
self.ever_got_incoming = ever_got_incoming
self.last_failed = True
self.last_time = 0
+ self.min_outgoing = min_outgoing
+ self.max_outgoing = max_outgoing
def c(self):
self.sched(self.c, self.interval)
@@ -116,10 +118,12 @@
for x in xrange(0, len(p), 6):
ip = '.'.join([str(ord(i)) for i in p[x:x+4]])
port = (ord(p[x+4]) << 8) | ord(p[x+5])
- peers.append((ip, port, None))
+ if port >= min_outgoing and port <= max_outgoing:
+ peers.append((ip, port, None))
else:
for x in p:
- peers.append((x['ip'], x['port'], x.get('peer id')))
+ if x['port'] >= min_outgoing and x['port'] <=
max_outgoing:
+ peers.append((x['ip'], x['port'], x.get('peer
id')))
ps = len(peers) + self.howmany()
if ps < self.maxpeers:
if self.doneflag.isSet():
diff -Naur
bittorrent-3.4.2-11-pristine/debian/bittorrent-downloader.bittorrent.1
bittorrent-3.4.2/debian/bittorrent-downloader.bittorrent.1
--- bittorrent-3.4.2-11-pristine/debian/bittorrent-downloader.bittorrent.1
2008-05-22 21:58:42.000000000 -0400
+++ bittorrent-3.4.2/debian/bittorrent-downloader.bittorrent.1 2008-05-24
12:52:15.000000000 -0400
@@ -117,6 +117,16 @@
.B \-\-rarest_first_priority_cutoff \fInum\fP
the number of peers which need to have a piece before other partials take
priority over rarest first (default 3)
+.TP
+.B \-\-min_outgoing_port \fIportnum\fP
+set \fIportnum\fP as the minimum port to which we are allowed to connect
+(default 1024). Useful to set this for strict (outgoing blocking)
+firewalls that allow bittorrent out on specific ports.
+.TP
+.B \-\-max_outgoing_port \fIportnum\fP
+set \fIportnum\fP as the maximum port to which we are allowed to
+connect (default 65535). Useful to set this for strict (outgoing blocking)
+firewalls that allow bittorrent out on specific ports.
.SH SEE ALSO
.BR bttrack (1),
diff -Naur bittorrent-3.4.2-11-pristine/debian/changelog
bittorrent-3.4.2/debian/changelog
--- bittorrent-3.4.2-11-pristine/debian/changelog 2008-05-22
21:58:42.000000000 -0400
+++ bittorrent-3.4.2/debian/changelog 2008-05-24 13:12:32.000000000 -0400
@@ -1,3 +1,16 @@
+bittorrent (3.4.2-11.1~dfd6) unstable; urgency=low
+
+ * Add new commandline parameters to manpage.
+
+ -- Daniel Dickinson <[EMAIL PROTECTED]> Sat, 24 May 2008 13:12:30 -0500
+
+bittorrent (3.4.2-11.1~dfd2) unstable; urgency=low
+
+ * Add outgoing port range limiting in order to play well with strict
+ firewalls. Closes: #481276
+
+ -- Daniel Dickinson <[EMAIL PROTECTED]> Fri, 23 May 2008 03:29:15 -0500
+
bittorrent (3.4.2-11) unstable; urgency=low
* Add LSB logging functionality. (thanks David!) Closes: #384724