Skip to content

Commit 85b7c60

Browse files
committed
add debug
1 parent 202bfe8 commit 85b7c60

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var bncode = require('bncode')
66
var bufferEqual = require('buffer-equal')
77
var compact2string = require('compact2string')
88
var concat = require('concat-stream')
9+
var debug = require('debug')('bittorrent-tracker')
910
var dgram = require('dgram')
1011
var EventEmitter = require('events').EventEmitter
1112
var extend = require('extend.js')
@@ -400,6 +401,7 @@ inherits(Client, EventEmitter)
400401
* @param {Number} opts.interval interval in ms to send announce requests to the tracker
401402
*/
402403
function Client (peerId, port, torrent, opts) {
404+
403405
var self = this
404406
if (!(self instanceof Client)) return new Client(peerId, port, torrent, opts)
405407
EventEmitter.call(self)
@@ -414,17 +416,19 @@ function Client (peerId, port, torrent, opts) {
414416
? torrent.infoHash
415417
: new Buffer(torrent.infoHash, 'hex')
416418
self.torrentLength = torrent.length
417-
self._announce = torrent.announce
418419

419420
// optional
420421
self._numWant = self._opts.numWant || 80
421422
self._intervalMs = self._opts.interval || (30 * 60 * 1000) // default: 30 minutes
422423

424+
debug('new tracker client for ' + self._infoHash.toString('hex'))
425+
423426
if (typeof torrent.announce === 'string') {
424427
// magnet-uri returns a string if the magnet uri only contains one 'tr' parameter
425428
torrent.announce = [torrent.announce]
426429
}
427430
self._trackers = torrent.announce.map(function (announceUrl) {
431+
debug('creating tracker for ' + announceUrl)
428432
return new Tracker(self, announceUrl, self._opts)
429433
})
430434
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"buffer-equal": "0.0.0",
1717
"compact2string": "^1.2.0",
1818
"concat-stream": "^1.4.5",
19+
"debug": "^1.0.0",
1920
"extend.js": "0.0.1",
2021
"hat": "0.0.3",
2122
"inherits": "^2.0.1",

0 commit comments

Comments
 (0)