mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-02-22 13:19:04 +00:00
fix #11 - support torrents with 64-bit file sizes
This commit is contained in:
parent
a924e620e1
commit
dfd5149d6b
11
index.js
11
index.js
@ -1,6 +1,7 @@
|
||||
exports.Client = Client
|
||||
exports.Server = Server
|
||||
|
||||
var bignum = require('bignum')
|
||||
var bncode = require('bncode')
|
||||
var compact2string = require('compact2string')
|
||||
var dgram = require('dgram')
|
||||
@ -225,9 +226,9 @@ Client.prototype._requestUdp = function (announceUrl, opts) {
|
||||
transactionId,
|
||||
self._infoHash,
|
||||
self._peerId,
|
||||
toUInt32(0), toUInt32(opts.downloaded || 0), // 64bit
|
||||
toUInt32(0), toUInt32(opts.left || 0), // 64bit
|
||||
toUInt32(0), toUInt32(opts.uploaded || 0), // 64bit
|
||||
toUInt64(opts.downloaded || 0),
|
||||
toUInt64(opts.left || 0),
|
||||
toUInt64(opts.uploaded || 0),
|
||||
toUInt32(EVENTS[opts.event] || 0),
|
||||
toUInt32(0), // ip address (optional)
|
||||
toUInt32(0), // key (optional)
|
||||
@ -520,6 +521,10 @@ function toUInt32 (n) {
|
||||
return buf
|
||||
}
|
||||
|
||||
function toUInt64 (n) {
|
||||
return bignum(n).toBuffer({ size: 8 })
|
||||
}
|
||||
|
||||
function bytewiseEncodeURIComponent (buf) {
|
||||
return encodeURIComponent(buf.toString('binary'))
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
"url": "https://github.com/feross/bittorrent-tracker/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"bignum": "^0.6.2",
|
||||
"bncode": "^0.5.2",
|
||||
"compact2string": "^1.2.0",
|
||||
"extend.js": "0.0.1",
|
||||
|
@ -8,6 +8,9 @@ var parsedTorrent = parseTorrent(torrent)
|
||||
var peerId = new Buffer('01234567890123456789')
|
||||
var port = 6881
|
||||
|
||||
// remove all tracker servers except a single UDP one, for now
|
||||
parsedTorrent.announce = [ 'udp://tracker.publicbt.com:80/announce' ]
|
||||
|
||||
test('client.start()', function (t) {
|
||||
t.plan(4)
|
||||
|
||||
@ -18,7 +21,7 @@ test('client.start()', function (t) {
|
||||
})
|
||||
|
||||
client.once('update', function (data) {
|
||||
t.equal(data.announce, 'http://t.bitlove.org/announce')
|
||||
t.equal(data.announce, 'udp://tracker.publicbt.com:80/announce')
|
||||
t.equal(typeof data.complete, 'number')
|
||||
t.equal(typeof data.incomplete, 'number')
|
||||
})
|
||||
|
@ -3,6 +3,9 @@ var portfinder = require('portfinder')
|
||||
var Server = require('../').Server
|
||||
var test = require('tape')
|
||||
|
||||
// TODO: add tests to verify that the correct downloaded/left/uploaded numbers are
|
||||
// being sent
|
||||
|
||||
var infoHash = '4cb67059ed6bd08362da625b3ae77f6f4a075705'
|
||||
var peerId = '12345678901234567890'
|
||||
var torrentLength = 50000
|
||||
|
Loading…
Reference in New Issue
Block a user