GitXplorerGitXplorer
g

node-dht

public
8 stars
2 forks
0 issues

Commits

List of commits on branch master.
Unverified
aa00204765cbb3cfb606ae36cac8a555e048aa8d

Remove stored buffers

committed 14 years ago
Unverified
97a05066c6c1fc770dd5a441b09a79b5adbd8a67

Add GetPeerAddress

committed 14 years ago
Unverified
6b9e357ce746c120aadbbf3deaf4b0bfb105976a

Finish TODO: Buffers in C++

committed 14 years ago
Unverified
840a1f517083b25fab352e7fb150fa1d5c9e2fda

Use new feature of libcage

committed 14 years ago
Unverified
2b9c527de4e64161164a6227762be9b3113c6d86

Made sendrecv example more readable

committed 14 years ago
Unverified
1fed87adcb78afea329775657b7987ca995d1fa3

Prevent garbage collection of returned string

committed 14 years ago

README

The README file for this repository.

node-dht

node-dht is a Kademlia-based Distributed Hash Table library for node.js with NAT-traversing super powers! node-dht is a set of bindings to the libcage library which does the heavy lifting under the hood.

What can you do with it? node-dht can be used as a decentralized peer-to-peer key/value store with the ability to traverse NATs if needed. More complicated protocols can be implemented on top of node-dht as well!

The goal of node-dht is to provide a very flexible, usable, and hackable set of tools to easily implement DHT services into your application.

node-dht is in an early-alpha stage and is very unstable.

Quick Start

var dht = require('../dht')
var port = 10000;

// create our initial nodes
var node = dht.createNode(port).setGlobal();
var node2 = dht.createNode(port + 1).setGlobal();

// node2 -> join -> node
node2.join("localhost", port, function (success) {
  console.log("join", success ? "succeed" : "failed");

  node.printState();
  node2.printState();
});

Building

Good luck, the automated build process isn't well fleshed out yet.

Depedencies

Step by Step

boost, libev

  1. build and install boost
  2. build libev WITH -DEV_MULTIPLICITY=0, install it
  3. libcage requires omake, download and install it

libcage

libcage was originally implemented with libevent. To make it play nice inside node.js' event loop, we need to link to libev instead. Luckily libev provides a compatibility header for libevent so all that needed to be changed was the linker options. You can get this version from the libev branch on my fork of libcage (link in the dependencies section).

  1. git checkout libev
  2. sudo omake install

If you have linking errors when building libcage there's a good chance that it's trying to link to libevent, make sure it's trying to include libev's event.h instead of libevent's event.h by removing libevent or by moving the headers around.

node-dht

  1. make