6

I am looking for opensource implementations of Kademlia DHT in C/C++. It must be lightweight and crossplatform (win/linux/mac).

It must be able to post information to DHT and retrieve it.

Kirill V. Lyadvinsky
  • 97,037
  • 24
  • 136
  • 212
Alexander Shishenko
  • 940
  • 1
  • 11
  • 28

5 Answers5

5

OpenDHT is a lightweight Kademlia DHT in C++11. The API is very simple :

dht::DhtRunner node;

// Launch a dht node on a new thread, using a
// generated RSA key pair, and listen on port 4222.
node.run(4222, dht::crypto::generateIdentity(), true);

// Join the network through any running node,
// here using a known bootstrap node.
node.bootstrap("bootstrap.jami.net", "4222");

// put some data on the dht
std::vector<uint8_t> some_data(5, 10);
node.put("unique_key", some_data);

It supports compiling with LLVM or GCC on OS X, Linux and Windows.

aberaud
  • 909
  • 1
  • 11
  • 24
2

LibTorrent's Kademlia DHT is written in C++ and is well documented.
Here is example code with immutable and mutable get/put operations: https://github.com/arvidn/libtorrent/blob/master/tools/dht_put.cpp

1

I have found a BitTorrent DHT library, used by Transmission. It is written in pure C, but it can be easily used from C++.

I am using it in my C++ project. It works well but requires an external cryptographic hash and randomization functions.

Alexander Shishenko
  • 940
  • 1
  • 11
  • 28
1

What's wrong with maidsafe-dht ?

Kirill V. Lyadvinsky
  • 97,037
  • 24
  • 136
  • 212
1

You could try bitdht used by retroshare.

fredix
  • 11
  • 2