Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
bittorrent-tracker
Advanced tools
Node.js implementation of a BitTorrent tracker, client and server.
A BitTorrent tracker is an HTTP service which responds to GET requests from BitTorrent clients. The requests include metrics from clients that help the tracker keep overall statistics about the torrent. The response includes a peer list that helps the client participate in the torrent.
Also see bittorrent-dht. This module is used by WebTorrent.
npm install bittorrent-tracker
To connect to a tracker, just do this:
var Client = require('bittorrent-tracker').Client
var parseTorrent = require('parse-torrent')
var torrent = fs.readFileSync(__dirname + '/torrents/bitlove-intro.torrent')
var parsedTorrent = parseTorrent(torrent) // { infoHash: 'xxx', length: xx, announce: ['xx', 'xx'] }
var peerId = new Buffer('01234567890123456789')
var port = 6881
var client = new Client(peerId, port, parsedTorrent)
// you must add an 'error' event handler!
client.on('error', function (err) {
console.log(err.message)
// a tracker was unavailable or sent bad data to the client. you can probably ignore it
})
// start getting peers from the tracker
client.start()
client.on('update', function (data) {
console.log('got a response from tracker: ' + data.announce)
console.log('number of seeders on this tracker: ' + data.complete)
console.log('number of leechers on this tracker: ' + data.incomplete)
})
client.once('peer', function (addr) {
console.log('found a peer: ' + addr) // 85.10.239.191:48623
})
// announce that download has completed (and you are now a seeder)
client.complete()
// force a tracker announce. will trigger more 'update' events and maybe more 'peer' events
client.update()
// stop getting peers from the tracker, gracefully leave the swarm
client.stop()
TODO: Add a BitTorrent tracker server implementation to this package.
var Server = require('bittorrent-tracker').Server
var server = new Server()
// you must add an 'error' event handler!
server.on('error', function (err) {
console.log(err.message)
})
server.on('listening', function () {
console.log('tracker server is listening!')
})
// listen for individual tracker messages from peers:
server.on('start', function (addr, params) {
console.log('got start message from ' + addr)
console.log('params in the message: ' + JSON.stringify(params))
})
server.on('complete', function (addr, params) {})
server.on('update', function (addr, params) {})
server.on('stop', function (addr, params) {})
// get info hashes for all torrents in the tracker server
Object.keys(server.torrents)
// get the number of seeders for a particular torrent
server.torrents[infoHash].complete
// get the number of leechers for a particular torrent
server.torrents[infoHash].incomplete
// get the peers who are in a particular torrent swarm
server.torrents[infoHash].peers
MIT. Copyright (c) Feross Aboukhadijeh.
FAQs
Simple, robust, BitTorrent tracker (client & server) implementation
The npm package bittorrent-tracker receives a total of 3,089 weekly downloads. As such, bittorrent-tracker popularity was classified as popular.
We found that bittorrent-tracker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.