New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bittorrent-dht

Package Overview
Dependencies
Maintainers
1
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bittorrent-dht - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

11

index.js

@@ -12,9 +12,8 @@ // TODO:

var compact2string = require('compact2string')
var crypto = require('crypto')
var dgram = require('dgram') // or chrome-dgram
var debug = require('debug')('bittorrent-dht')
var dgram = require('dgram')
var EventEmitter = require('events').EventEmitter
var hat = require('hat')
var inherits = require('inherits')
var portfinder = require('portfinder') // or chrome-portfinder
var debug = require('debug')('bittorrent-dht');
var portfinder = require('portfinder')

@@ -122,3 +121,3 @@ // Use random port above 1024

var port = Number(addr.split(':')[1])
if (!(port > 0 && port < 65535)) return;
if (!(port > 0 && port < 65535)) return
this.socket.send(this.message, 0, this.message.length, port, host, function () {

@@ -128,3 +127,3 @@ setTimeout(function () {

if (!this.nodes[addr] && this.reqs[addr] < MAX_REQUESTS) {
this.query.call(this, addr);
this.query.call(this, addr)
}

@@ -131,0 +130,0 @@ }.bind(this), REQ_TIMEOUT)

{
"name": "bittorrent-dht",
"description": "Simple, robust, BitTorrent DHT implementation",
"version": "0.5.0",
"version": "0.6.0",
"author": {

@@ -10,6 +10,2 @@ "name": "Feross Aboukhadijeh",

},
"browser": {
"dgram": "chrome-dgram/index.js",
"portfinder": "chrome-portfinder/index.js"
},
"bugs": {

@@ -19,15 +15,12 @@ "url": "https://github.com/feross/bittorrent-dht/issues"

"dependencies": {
"bitfield": "~0.1.0",
"bncode": "~0.5.2",
"chrome-dgram": "2.x",
"chrome-portfinder": "0.x",
"compact2string": "~1.2.0",
"hat": "0.0.3",
"inherits": "~2.0.1",
"portfinder": "~0.2.1",
"debug": "^0.7.4"
"bncode": "^0.5.3",
"compact2string": "^1.2.0",
"debug": "^0.8.0",
"hat": "^0.0.3",
"inherits": "^2.0.1",
"portfinder": "^0.2.1"
},
"devDependencies": {
"once": "1.x",
"tape": "2.x"
"once": "^1.3.0",
"tape": "^2.12.3"
},

@@ -34,0 +27,0 @@ "homepage": "http://webtorrent.io",

@@ -1,6 +0,2 @@

# bittorrent-dht
[![Build Status](http://img.shields.io/travis/feross/bittorrent-dht.svg)](https://travis-ci.org/feross/bittorrent-dht)
[![NPM Version](http://img.shields.io/npm/v/bittorrent-dht.svg)](https://npmjs.org/package/bittorrent-dht)
[![NPM](http://img.shields.io/npm/dm/bittorrent-dht.svg)](https://npmjs.org/package/bittorrent-dht)
[![Gittip](http://img.shields.io/gittip/feross.svg)](https://www.gittip.com/feross/)
# bittorrent-dht [![build](https://img.shields.io/travis/feross/bittorrent-dht.svg)](https://travis-ci.org/feross/bittorrent-dht) [![npm](https://img.shields.io/npm/v/bittorrent-dht.svg)](https://npmjs.org/package/bittorrent-dht) [![npm downloads](https://img.shields.io/npm/dm/bittorrent-dht.svg)](https://npmjs.org/package/bittorrent-dht) [![gittip](https://img.shields.io/gittip/feross.svg)](https://www.gittip.com/feross/)

@@ -11,8 +7,6 @@ ### Simple, robust, BitTorrent DHT implementation

Works in the browser with [browserify](http://browserify.org/) and [chrome-dgram](https://github.com/feross/chrome-dgram)!
This module is used by [WebTorrent](https://github.com/feross/WebTorrent). Works in the browser with [browserify](http://browserify.org/) and a `dgram` shim (like [chrome-dgram](https://github.com/feross/chrome-dgram) for chrome apps).
This module is used by [WebTorrent](https://github.com/feross/WebTorrent).
### install
## install
```

@@ -22,8 +16,81 @@ npm install bittorrent-dht

## methods
### example
TODO
```javascript
var DHT = require('bittorrent-dht');
var magnet = require('magnet-uri');
## license
var uri = "magnet:?xt=urn:btih:e3811b9539cacff680e418124272177c47477157&dn=Ubuntu+13.10+Desktop+Live+ISO+amd64";
var parsed = magnet(uri);
MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).
var dht = new DHT();
dht.on('peer', function (addr, hash) {
console.log('Found peer at ' + addr + '!');
});
dht.setInfoHash(parsed.infoHash);
var port = 20000;
dht.listen(port, function (port) {
console.log("Now listening on port " + port);
});
dht.findPeers();
```
### methods
#### `setInfoHash(infoHash)`
Associate an infoHash with the DHT object. Can be a String or Buffer.
#### `dht.listen([port], [callback])`
Open the socket. If port is undefined, one is picked with [portfinder](https://github.com/indexzero/node-portfinder).
`callback` is equivalent to `listening` event.
#### `findPeers([num])`
Get `num` peers from the DHT. Defaults to unlimited.
### events
#### 'peer'
function (addr, infoHash){ ... }
Called when a peer is found. `addr` is of the form `IP_ADDRESS:PORT`
#### 'message'
function (data, rinfo){ ... }
Called when a message is received. `rinfo` is an object with properties `address`, `port`
#### 'node'
function (addr){ ... }
Called when client finds a new DHT node.
#### 'listening'
function () { ... }
#### 'error'
function (err){ ... }
### license
MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc