bittorrent-lsd

2.0.0 • Public • Published

bittorrent-lsd ci npm downloads javascript style guide

Local Service Discovery (BEP14) implementation.

Local Service Discovery (LSD) provides a SSDP-like (http over udp-multicast) mechanism to announce the presence in specific swarms to local neighbors.

This module is used by WebTorrent.

install

npm install bittorrent-lsd

example

const opts = {
  peerId: new Buffer('01234567890123456789'), // hex string or Buffer
  infoHash: new Buffer('01234567890123456789'), // hex string or Buffer
  port: common.randomPort() // torrent client port
}

const lsd = new LSD(opts)

// start getting peers from local network
lsd.start()

lsd.on('peer', (peerAddress, infoHash) => {
  console.log('found a peer: ' + peerAddress)
})

lsd.destroy()

api

lsd = new LSD([opts])

Create a new lsd instance.

lsd.start()

Start listening and sending (every 5 minutes) for local network announces.

lsd.destroy([callback])

Destroy the LSD. Closes the socket and cleans up resources.

events

lsd.on('peer', (peerAddress, infoHash) => { ... })

Emitted when a potential peer is found. peerAddress is of the form host:port. infoHash is the torrent info hash.

lsd.on('warning', (err) => { ... })

Emitted when the LSD gets an unexpected message.

lsd.on('error', (err) => { ... })

Emitted when the LSD has a fatal error.

license

MIT. Copyright (c) Julen Garcia Leunda and WebTorrent, LLC.

Package Sidebar

Install

npm i bittorrent-lsd

Weekly Downloads

3,145

Version

2.0.0

License

MIT

Unpacked Size

11.1 kB

Total Files

7

Last publish

Collaborators

  • alxhotel
  • feross
  • mafintosh
  • flet
  • watson
  • diegorbaquero
  • hicom150
  • jhiesey
  • webtorrent-bot