bittorrent-tracker
Advanced tools
15
index.js
@@ -74,3 +74,3 @@ /* vim: set ts=2 sw=2 sts=2 et: */ | ||
opts.event = 'completed' | ||
opts.downloaded = self._torrentLength | ||
opts.downloaded = opts.downloaded || self.torrentLength || 0 | ||
self._request(opts) | ||
@@ -130,3 +130,2 @@ } | ||
port: self.client._port, | ||
left: self.client._torrentLength - (opts.downloaded || 0), | ||
compact: 1, | ||
@@ -138,2 +137,6 @@ numwant: self.client._numWant, | ||
if (self.client.torrentLength !== undefined) { | ||
opts.left = self.client.torrentLength - (opts.downloaded || 0) | ||
} | ||
if (self._trackerId) { | ||
@@ -275,3 +278,3 @@ opts.trackerid = self._trackerId | ||
toUInt64(opts.downloaded || 0), | ||
toUInt64(opts.left || 0), | ||
opts.left ? toUInt64(opts.left) : new Buffer('FFFFFFFFFFFFFFFF', 'hex'), | ||
toUInt64(opts.uploaded || 0), | ||
@@ -399,3 +402,3 @@ toUInt32(EVENTS[opts.event] || 0), | ||
: new Buffer(torrent.infoHash, 'hex') | ||
self._torrentLength = torrent.length | ||
self.torrentLength = torrent.length | ||
self._announce = torrent.announce | ||
@@ -407,2 +410,6 @@ | ||
if (typeof torrent.announce === 'string') { | ||
// magnet-uri returns a string if the magnet uri only contains one 'tr' parameter | ||
torrent.announce = [torrent.announce] | ||
} | ||
self._trackers = torrent.announce.map(function (announceUrl) { | ||
@@ -409,0 +416,0 @@ return new Tracker(self, announceUrl, self._opts) |
{ | ||
"name": "bittorrent-tracker", | ||
"description": "Simple, robust, BitTorrent tracker (client & server) implementation", | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"author": { | ||
@@ -25,2 +25,3 @@ "name": "Feross Aboukhadijeh", | ||
"devDependencies": { | ||
"magnet-uri": "^2.0.1", | ||
"parse-torrent": "^1.1.0", | ||
@@ -27,0 +28,0 @@ "portfinder": "^0.2.1", |
@@ -14,3 +14,3 @@ var Client = require('../').Client | ||
test('client.start()', function (t) { | ||
test('large torrent: client.start()', function (t) { | ||
t.plan(4) | ||
@@ -17,0 +17,0 @@ |
@@ -6,2 +6,4 @@ var Client = require('../').Client | ||
// TODO: add test where tracker doesn't support compact | ||
var torrent = fs.readFileSync(__dirname + '/torrents/bitlove-intro.torrent') | ||
@@ -13,3 +15,3 @@ var parsedTorrent = parseTorrent(torrent) | ||
test('client.start()', function (t) { | ||
test('torrent: client.start()', function (t) { | ||
t.plan(4) | ||
@@ -37,3 +39,3 @@ | ||
test('client.stop()', function (t) { | ||
test('torrent: client.stop()', function (t) { | ||
t.plan(4) | ||
@@ -65,3 +67,3 @@ | ||
test('client.update()', function (t) { | ||
test('torrent: client.update()', function (t) { | ||
t.plan(3) | ||
@@ -90,3 +92,3 @@ | ||
test('client.scrape()', function (t) { | ||
test('torrent: client.scrape()', function (t) { | ||
t.plan(4) | ||
@@ -109,3 +111,1 @@ | ||
}) | ||
// TODO: add test where tracker doesn't support compact |
@@ -46,3 +46,3 @@ var Client = require('../').Client | ||
}) | ||
client.stop() | ||
@@ -49,0 +49,0 @@ }) |
114715
1.69%14
7.69%860
5.52%4
33.33%4
33.33%