Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var createTracker = function(torrent) {
console.log('---------- createTracker -------',true);
if (opts.trackers) {
torrent = Object.create(torrent);
var trackers = (opts.tracker !== false) && torrent.announce ? torrent.announce : [];
torrent.announce = trackers.concat(opts.trackers);
} else if (opts.tracker === false) {
return;
}
if (!torrent.announce || !torrent.announce.length) return;
var tr = new tracker.Client(new Buffer(opts.id), port, torrent);
tr.on('peer', onpeer);
tr.on('error', function() { /* noop */ });
tr.start();
return tr;
};
var createTracker = function(torrent) {
if (opts.trackers) {
torrent = Object.create(torrent);
var trackers = (opts.tracker !== false) && torrent.announce ? torrent.announce : [];
torrent.announce = trackers.concat(opts.trackers);
} else if (opts.tracker === false) {
return;
}
if (!torrent.announce || !torrent.announce.length) return;
var tr = new tracker.Client(new Buffer(opts.id), port, torrent);
tr.on('peer', onpeer);
tr.on('error', function() { /* noop */ });
tr.start();
return tr;
};
var createTracker = function(torrent) {
if (opts.trackers) {
torrent = Object.create(torrent);
var trackers = (opts.tracker !== false) && torrent.announce ? torrent.announce : [];
torrent.announce = trackers.concat(opts.trackers);
} else if (opts.tracker === false) {
return;
}
if (!torrent.announce || !torrent.announce.length) return;
var tr = new tracker.Client(new Buffer(opts.id), port, torrent);
tr.on('peer', onpeer);
tr.on('error', function() { /* noop */ });
tr.start();
return tr;
};
return function(torrent) {
if (opts.trackers) {
torrent = Object.create(torrent);
var trackers = (opts.tracker !== false) && torrent.announce ? torrent.announce : [];
torrent.announce = trackers.concat(opts.trackers);
} else if (opts.tracker === false) {
return;
}
if (!torrent.announce || !torrent.announce.length) return;
var tr = new tracker.Client(new Buffer(opts.id), engine.port || DEFAULT_PORT, torrent);
tr.on('peer', function(addr) {
engine.connect(addr);
});
tr.on('error', function() {});
tr.start();
return tr;
};
};