mgnt

0.3.1 • Public • Published
                     o  
                     |  
    o-O-o o--o o-o  -o-
    | | | |  | |  |  |
    o o o o--O o  o  o  
             |          
          o--o          

Extensible bittorrent client. Built with webtorrent. Probably a bit buggy, as it's still an early prototype.

Install and usage

$ npm install mgnt -g
$ mgnt [path] # default ~/torrents/ 

Quit with q.

Extensions

ui

Provides a simple user interface.

list

Active transfer list.

input

Adds support for input (e.g. pasting torrents).

API

Core

core = new Core([path], [options])
/**
 * options: {
 *   dht: Boolean|Object,
 *   maxPeers: Number,
 *   nodeId: String|Buffer,
 *   peerId: String|Buffer,
 *   rtcConfig: Object,
 *   tracker: Boolean,
 *   wrtc: Object
 * }
 **/

Both path and options are optional.

References to torrent below refers to instances of webtorrent::torrent.

core.path

Default torrent download path.

core.client

An instance of webtorrent.

core.package

Contents of this module's package.json.

core.download(id)

Add id to client and begin downloading.

core.remove(id)

Remove id from client.

core.seed(input, options)

Begins seeding input.

core.extend(Extension)

Extend core with Extension (has to be a class).

core.round(number, precision)

Rounds number to precision. Returns the number as a string.

core.destroy

Destroys the client and exits the process.

Events

add

core.on('add', function(torrent) {
  // e.g. console.log(torrent.infoHash);
});

Emitted when a torrent has been successfully added to the client.

download

core.on('download',  function(torrent, chunkSize) {
  // e.g. console.log(torrent.downloadSpeed());
});

Emitted when a chunk of chunkSize has been successfully downloaded from torrent.

wire

core.on('wire', function(torrent, wire, addr) {
  // e.g. wire.use(myExtension);
});

Emitted whenever a new peer is connected to torrent. wire is an instance of bittorrent-protocol.

done

core.on('done', function(torrent) {
  // e.g. console.log(torrent.name);
});

Emitted when torrent has finished downloading.

seed

core.on('seed', function(torrent) {
  // e.g. console.log(torrent.uploaded);
});

Emitted when torrent has begun seeding.

error

core.on('error', function(error) {
  // e.g. throw error;
});

Emitted when an error occurs with the client.

Contribute

If you want to contribute with an extension, create a git repository with your code and send me a link or submit a pull request.

See Extensions above for examples.

Package Sidebar

Install

npm i mgnt

Weekly Downloads

0

Version

0.3.1

License

MIT

Last publish

Collaborators

  • mateogianolio