node-dht is currently in a very experimental stage and most of these feature are being implemented as we speak.var dht = require('dht');// global nodes to enable NAT-traversal (optional)var globalNode = dht.createNode(10000).setGlobal();var globalNode2 = dht.createNode(10001).setGlobal();var bobNode = dht.createNode(10002);var aliceNode = dht.createNode(10003);// have global nodes join to form our bootstrap nodesglobalNode2.join("localhost", 10000, function (success) {// joined if success == true});// have bobNode join the networkbobNode.join("localhost", 10000, function (success) {// have aliceNode join the network after bob has joinedaliceNode.join("localhost", 10000, function (success) {// put data into the network (k/v store)aliceNode.put(key, value, ttl)// send data to specific nodesaliceNode.send(bobNode.id, data)});});
That is an interesting project. However, I bet lines of code can be
reduced by implementing the protocol in JavaScript instead of an
external library that has to deal with asynchronicity itself.
> The goal of node-dht is to provide a flexible library for building networked
> applications that can communicate via DHTs. node-dht can be used as a
> decentralized, peer-to-peer key value store with the ability to traverse
> NATs if needed.
I browsed the NAT detection code a bit. Can you elaborate how it is
going to work in the end?
> Most of all node-dht breaks DHTs out of the blackbox that they are usually
> presented as, and provides a very clean way of interacting and experimenting
> with DHTs.
Do you have any particular use-cases in mind? DHT power comes with many
participants. Unless widespread use has been achieved somebody who wants
to use it for data-heavy projects could overload the network.
> Let me know what you think!
I discovered that Kademlia is very prone to NodeID spoofing and can thus
be used to facilitate DDoS attacks. Telehash.org has a straight-forward
solution to this: make NodeIDs immediately verifyable, ie. by creating
it from the SHA1 hash of a peer's IP+port number.
Bill Casarin wrote:That is an interesting project. However, I bet lines of code can be
> This is just a little something I have been tinkering with. I was trying to
> think of a good way to test node's capabilities and it turns out distributed
> hash tables work quite well in an evented environment like node. I found a
> great little library called libcage which is evented and was able to get it
> to live nicely within node's event loop.
reduced by implementing the protocol in JavaScript instead of an
external library that has to deal with asynchronicity itself.
I browsed the NAT detection code a bit. Can you elaborate how it is
> The goal of node-dht is to provide a flexible library for building networked
> applications that can communicate via DHTs. node-dht can be used as a
> decentralized, peer-to-peer key value store with the ability to traverse
> NATs if needed.
going to work in the end?
libcage try to detect the NAT type to access two nodes, which have global IP address.
So, there must be at least two nodes having global IP address on the DHT network.
If you plan to use libcage on the Internet of IPv4, please make prepare two nodes, which have global IP address as bootstrapping nodes when you deploy it.
Please use set_global() function, which set the state 'GLOBAL', for the two nodes.
Other nodes will determine 'GLOBAL' or 'NATTED' by communicating with two nodes whose states are 'GLOBAL'.
Of course, you can disable the detection of NATs to pass 'false' to the 3rd argument of cage::open().
If you use PF_INET6, which indicates IPv6, the detection is automatically disabled.
Do you have any particular use-cases in mind? DHT power comes with many
> Most of all node-dht breaks DHTs out of the blackbox that they are usually
> presented as, and provides a very clean way of interacting and experimenting
> with DHTs.
participants. Unless widespread use has been achieved somebody who wants
to use it for data-heavy projects could overload the network.
I discovered that Kademlia is very prone to NodeID spoofing and can thus
> Let me know what you think!
be used to facilitate DDoS attacks. Telehash.org has a straight-forward
solution to this: make NodeIDs immediately verifyable, ie. by creating
it from the SHA1 hash of a peer's IP+port number.
--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.