All Projects → webtorrent → Ut_metadata

webtorrent / Ut_metadata

Licence: mit
BitTorrent Extension for Peers to Send Metadata Files (BEP 9)

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ut metadata

Torrent Discovery
Discover BitTorrent and WebTorrent peers
Stars: ✭ 177 (+80.61%)
Mutual labels:  bittorrent, webtorrent, peer, browser
Webtorrent Hybrid
WebTorrent (with WebRTC support in Node.js)
Stars: ✭ 422 (+330.61%)
Mutual labels:  bittorrent, webtorrent, browser
Webtorrent
⚡️ Streaming torrent client for the web
Stars: ✭ 25,554 (+25975.51%)
Mutual labels:  bittorrent, webtorrent, browser
P2p Media Loader
An open-source engine for P2P streaming of live and on demand video directly in a web browser HTML page
Stars: ✭ 822 (+738.78%)
Mutual labels:  bittorrent, webtorrent, peer
Parse Torrent
Parse a torrent identifier (magnet uri, .torrent file, info hash)
Stars: ✭ 325 (+231.63%)
Mutual labels:  bittorrent, webtorrent, browser
Bittorrent Protocol
Simple, robust, BitTorrent peer wire protocol implementation
Stars: ✭ 279 (+184.69%)
Mutual labels:  bittorrent, webtorrent, browser
Aria2.js
JavaScript library for aria2, "The next generation download utility."
Stars: ✭ 471 (+380.61%)
Mutual labels:  bittorrent, magnet, browser
Bittorrent Tracker
🌊 Simple, robust, BitTorrent tracker (client & server) implementation
Stars: ✭ 1,184 (+1108.16%)
Mutual labels:  bittorrent, webtorrent, browser
Bittorrent Dht
🕸 Simple, robust, BitTorrent DHT implementation
Stars: ✭ 1,004 (+924.49%)
Mutual labels:  bittorrent, webtorrent, peer
Create Torrent
Create .torrent files
Stars: ✭ 264 (+169.39%)
Mutual labels:  bittorrent, webtorrent, browser
Magnet Uri
Parse a magnet URI and return an object of keys/values
Stars: ✭ 183 (+86.73%)
Mutual labels:  bittorrent, webtorrent, browser
torrent-spider
基于DHT的p2p网络资源爬虫
Stars: ✭ 65 (-33.67%)
Mutual labels:  metadata, bittorrent, magnet
Exifer
A lightweight Exif meta-data decipher.
Stars: ✭ 290 (+195.92%)
Mutual labels:  metadata, browser
Planktos
Serving websites over bittorrent
Stars: ✭ 481 (+390.82%)
Mutual labels:  bittorrent, webtorrent
Webtorrent Cli
WebTorrent, the streaming torrent client. For the command line.
Stars: ✭ 633 (+545.92%)
Mutual labels:  bittorrent, webtorrent
Motrix
A full-featured download manager.
Stars: ✭ 29,357 (+29856.12%)
Mutual labels:  bittorrent, magnet
Aria2 Pro Docker
Aria2 Pro | A perfect Aria2 Docker image | 更好用的 Aria2 Docker 容器镜像
Stars: ✭ 802 (+718.37%)
Mutual labels:  bittorrent, magnet
Torrenter
Simple nodejs package to download torrents using torrent-indexer and webtorrent, especially movie and series.
Stars: ✭ 42 (-57.14%)
Mutual labels:  webtorrent, magnet
Bittorrent Peerid
Map a BitTorrent peer ID to a human-readable client name and version
Stars: ✭ 47 (-52.04%)
Mutual labels:  bittorrent, webtorrent
Instant.io
🚀 Streaming file transfer over WebTorrent (torrents on the web)
Stars: ✭ 2,954 (+2914.29%)
Mutual labels:  bittorrent, webtorrent

ut_metadata travis npm downloads javascript style guide

BitTorrent Extension for Peers to Send Metadata Files (BEP 9)

JavaScript implementation of the Extension for Peers to Send Metadata Files (BEP 9). Use with bittorrent-protocol.

The purpose of this extension is to allow clients to join a swarm and complete a download without the need of downloading a .torrent file first. This extension instead allows clients to download the metadata from peers. It makes it possible to support magnet links, a link on a web page only containing enough information to join the swarm (the info hash).

Works in the browser with browserify! This module is used by WebTorrent.

install

npm install ut_metadata

usage

This package should be used with bittorrent-protocol, which supports a plugin-like system for extending the protocol with additional functionality.

Say you're already using bittorrent-protocol. Your code might look something like this:

const Protocol = require('bittorrent-protocol')
const net = require('net')

net.createServer(socket => {
  var wire = new Protocol()
  socket.pipe(wire).pipe(socket)

  // handle handshake
  wire.on('handshake', (infoHash, peerId) => {
    wire.handshake(new Buffer('my info hash'), new Buffer('my peer id'))
  })

}).listen(6881)

To add support for BEP 9, simply modify your code like this:

const Protocol = require('bittorrent-protocol')
const net = require('net')
const ut_metadata = require('ut_metadata')

net.createServer(socket => {
  const wire = new Protocol()
  socket.pipe(wire).pipe(socket)

  // initialize the extension
  wire.use(ut_metadata())

  // all `ut_metadata` functionality can now be accessed at wire.ut_metadata

  // ask the peer to send us metadata
  wire.ut_metadata.fetch()

  // 'metadata' event will fire when the metadata arrives and is verified to be correct!
  wire.ut_metadata.on('metadata', metadata => {
    // got metadata!

    // Note: the event will not fire if the peer does not support ut_metadata, if they
    // don't have metadata yet either, if they repeatedly send invalid data, or if they
    // simply don't respond.
  })

  // optionally, listen to the 'warning' event if you want to know that metadata is
  // probably not going to arrive for one of the above reasons.
  wire.ut_metadata.on('warning', err => {
    console.log(err.message)
  })

  // handle handshake
  wire.on('handshake', (infoHash, peerId) => {
    wire.handshake(new Buffer('my info hash'), new Buffer('my peer id'))
  })

}).listen(6881)

api

ut_metadata([metadata])

Initialize the extension. If you have the torrent metadata (Buffer), pass it into the ut_metadata constructor so it's made available to the peer.

const metadata = fs.readFileSync(__dirname + '/file.torrent')
wire.use(ut_metadata(metadata))

ut_metadata.fetch()

Ask the peer to send metadata.

ut_metadata.cancel()

Stop asking the peer to send metadata.

ut_metadata.setMetadata(metadata)

Set the metadata. If you didn't have the metadata at the time ut_metadata was initialized, but you end up getting it from another peer (or somewhere else), you should call setMetadata so the metadata will be available to the peer.

ut_metadata.on('metadata', function (metadata) {})

Fired when metadata is available and verified to be correct. Called with a single parameter of type Buffer.

wire.ut_metadata.on('metadata', metadata => {
  console.log(Buffer.isBuffer(metadata)) // true
})

Note: the event will not fire if the peer does not support ut_metadata, if they don't have metadata yet either, if they repeatedly send invalid data, or if they simply don't respond.

ut_metadata.on('warning', function (err) {})

Fired if:

  • the peer does not support ut_metadata
  • the peer doesn't have metadata yet
  • the peer repeatedly sent invalid data
wire.ut_metadata.on('warning', err => {
  console.log(err.message)
})

license

MIT. Copyright (c) Feross Aboukhadijeh and WebTorrent, LLC.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].