bittorrent-dht
Advanced tools
Comparing version 0.3.0 to 0.3.1
10
index.js
@@ -10,3 +10,3 @@ // TODO: | ||
var bencode = require('bncode') | ||
var bncode = require('bncode') | ||
var compact2string = require('compact2string') | ||
@@ -16,2 +16,3 @@ var crypto = require('crypto') | ||
var EventEmitter = require('events').EventEmitter | ||
var hat = require('hat') | ||
var inherits = require('inherits') | ||
@@ -65,2 +66,5 @@ var portfinder = require('portfinder') // or chrome-portfinder | ||
if (!opts) opts = {} | ||
if (!opts.nodeId) opts.nodeId = hat(160) | ||
this.nodeId = typeof opts.nodeId === 'string' | ||
@@ -110,3 +114,3 @@ ? new Buffer(opts.nodeId, 'hex') | ||
// console.log('Created DHT message: ' + JSON.stringify(this.message)) | ||
this.message = bencode.encode(this.message) | ||
this.message = bncode.encode(this.message) | ||
} | ||
@@ -213,3 +217,3 @@ | ||
// console.log('got response from ' + addr) | ||
message = bencode.decode(data) | ||
message = bncode.decode(data) | ||
if (!message) throw new Error('message is undefined') | ||
@@ -216,0 +220,0 @@ } catch (err) { |
{ | ||
"name": "bittorrent-dht", | ||
"description": "Simple, robust, BitTorrent DHT implementation", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"author": { | ||
@@ -23,2 +23,3 @@ "name": "Feross Aboukhadijeh", | ||
"compact2string": "~1.2.0", | ||
"hat": "0.0.3", | ||
"inherits": "~2.0.1", | ||
@@ -25,0 +26,0 @@ "portfinder": "~0.2.1" |
# bittorrent-dht | ||
[](https://travis-ci.org/feross/bittorrent-dht) | ||
[](https://npmjs.org/package/bittorrent-dht) | ||
[](https://npmjs.org/package/bittorrent-dht) | ||
[](https://www.gittip.com/feross/) | ||
[](https://travis-ci.org/feross/bittorrent-dht) | ||
[](https://npmjs.org/package/bittorrent-dht) | ||
[](https://npmjs.org/package/bittorrent-dht) | ||
[](https://www.gittip.com/feross/) | ||
@@ -7,0 +7,0 @@ ### Simple, robust, BitTorrent DHT implementation |
@@ -11,3 +11,4 @@ var DHT = require('../') | ||
var hash = '1E69917FBAA2C767BCA463A96B5572785C6D8A12' // Pride & Prejudice | ||
var dht = new DHT(new Buffer(hash, 'hex')) | ||
var dht = new DHT() | ||
dht.setInfoHash(hash) | ||
dht.findPeers(300) | ||
@@ -14,0 +15,0 @@ |
13314
332
8