How to use bittorrent-tracker - 10 common examples

To help you get started, we’ve selected a few bittorrent-tracker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Ayms / torrent-live / lib / peer-discovery.js View on Github external
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;
	};
github philipphenkel / docker-bittorrent-tracker / server.js View on Github external
// Copyright (C) 2016 Philipp Henkel
// Licensed under the MIT License (MIT). See LICENSE file for more details.

var config = require('./config.js');
var filter = require('./filter')
var Server = require('bittorrent-tracker').Server

var server = new Server({
  trustProxy: config.get('trustProxy'),
  udp: config.get('udp'),
  http: config.get('http'),
  ws: config.get('websocket'),
  stats: config.get('stats'),
  filter: function (infoHash, params, cb) {
    var whitelist = config.get('torrentWhitelist')
    cb(filter.isTorrentAllowed(infoHash, whitelist))
  }
})

server.on('error', function (err) {
  console.error('error: ' + err.message)
})

server.on('warning', function (err) {
github binux / webtorrent-share / hybrid-server.js View on Github external
connect().use(serveStatic(__dirname)).listen(8000);

// bt hybrid server
var Server = require('bittorrent-tracker').Server
var WebTorrent = require('webtorrent-hybrid')
var parseTorrent = require('parse-torrent')

global.WEBTORRENT_ANNOUNCE = ["ws://127.0.0.1:8900/announce"]
//global.WEBTORRENT_ANNOUNCE = [ 'wss://tracker.webtorrent.io', 'wss://tracker.btorrent.xyz' ]

var client = new WebTorrent({
  dht: false,
  tracker: true
})

var server = new Server({
  udp: false,
  http: true,
  ws: true,
  filter: function(info_hash, params, cb) {
    // add to web torrent client here
    console.log('adding torrent: ' + info_hash)
    client.add(info_hash, {
      announce: ["https://tr.bangumi.moe:9696/announce", "http://tr.bangumi.moe:6969/announce", "http://127.0.0.1:8900/announce"]
    }, function(torrent) {
      console.log('added torrent: ' + torrent.magnetURI)
      // select pieces in file streaming order
      torrent.critical(0, Math.min(10, torrent.pieces.length - 1))
      for (var i = 10; i < torrent.pieces.length - 1; i += 10) {
        torrent.select(i, Math.min(i + 10, torrent.pieces.length - 1), torrent.pieces.length / 10 - i / 10)
      }
      torrent.on('wire', function(wire, addr) {
github gridcontrol / gridcontrol / research / bittorrent / tracker.js View on Github external
var Server = require('bittorrent-tracker').Server;

var server = new Server({
  udp: true, // enable udp server? [default=true]
  http: true, // enable http server? [default=true]
  ws: true, // enable websocket server? [default=true]
  stats: true // enable web-based statistics? [default=true]
});

server.on('error', function (err) {
  // fatal server error!
  console.log(err.message);
});

server.on('warning', function (err) {
  // client sent bad data. probably not a problem, just a buggy client.
  console.log(err.message);
});
github mafintosh / torrent-stream / lib / peer-discovery.js View on Github external
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;
	};
github arestov / deklarota / nodejs / troxent / torrent-stream / lib / peer-discovery.js View on Github external
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;
	};
github ZeroNetJS / zeronet-js / tools / debug / torrent-server.js View on Github external
var Server = require('bittorrent-tracker').Server

var server = new Server({
  udp: true, // enable udp server? [default=true]
  http: true, // enable http server? [default=true]
  ws: true, // enable websocket server? [default=true]
  stats: true, // enable web-based statistics? [default=true]
  filter: function (infoHash, params, cb) {
    // Blacklist/whitelist function for allowing/disallowing torrents. If this option is
    // omitted, all torrents are allowed. It is possible to interface with a database or
    // external system before deciding to allow/deny, because this function is async.

    // It is possible to block by peer id (whitelisting torrent clients) or by secret
    // key (private trackers). Full access to the original HTTP/UDP request parameters
    // are available in `params`.

    // This example only allows one torrent.

    if (true) {
github axiom-org / axiom / ts / src / node / Tracker.ts View on Github external
constructor(port) {
    this.server = new Server({
      udp: true,
      http: true,
      ws: true,
      stats: true,
      filter: (infoHash, params, callback) => {
        // Any content you don't want to host, you can reject here based on infoHash.
        // TODO: validate prepareUpdateBucket calls and only allow tracking torrents
        // that have previously sent this validation.
        callback(null);
      }
    });

    this.server.http.on("request", (req, res) => {
      let parsed = url.parse(req.url, true);
      if (parsed.pathname !== "/prepareUpdateBucket") {
        return;
github mafintosh / torrent-stream / test / tracker.js View on Github external
var test = require('tap').test
var torrents = require('../')
var fs = require('fs')
var path = require('path')
var rimraf = require('rimraf')
var tracker = require('bittorrent-tracker')
var server = new tracker.Server()

var torrent = fs.readFileSync(path.join(__dirname, 'data', 'test.torrent'))
var tmpPath = path.join(__dirname, '..', 'torrents', 'test')
rimraf.sync(tmpPath)

var fixture

server.on('error', function () {})

test('seed should connect to the tracker', function (t) {
  t.plan(3)

  server.once('listening', function () {
    t.ok(true, 'tracker should be listening')
    fixture = torrents(torrent, {
      dht: false,
github mafintosh / torrent-stream / test / blocklist.js View on Github external
var test = require('tap').test
var torrents = require('../')
var fs = require('fs')
var path = require('path')
var rimraf = require('rimraf')
var tracker = require('bittorrent-tracker')
var server = new tracker.Server()

var torrent = fs.readFileSync(path.join(__dirname, 'data', 'test.torrent'))
var tmpPath = path.join(__dirname, '..', 'torrents', 'test')
rimraf.sync(tmpPath)

var seed

server.on('error', function () {})

test('seed should connect to the tracker', function (t) {
  t.plan(3)

  server.once('listening', function () {
    t.ok(true, 'tracker should be listening')
    seed = torrents(torrent, {
      dht: false,

bittorrent-tracker

Simple, robust, BitTorrent tracker (client & server) implementation

MIT
Latest version published 3 months ago

Package Health Score

75 / 100
Full package analysis