@@ -6,6 +6,7 @@ var bncode = require('bncode')
66var bufferEqual = require ( 'buffer-equal' )
77var compact2string = require ( 'compact2string' )
88var concat = require ( 'concat-stream' )
9+ var debug = require ( 'debug' ) ( 'bittorrent-tracker' )
910var dgram = require ( 'dgram' )
1011var EventEmitter = require ( 'events' ) . EventEmitter
1112var 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 */
402403function 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}
0 commit comments