C++实现DHT

6
我正在寻找C/C++语言的Kademlia分布式哈希表(DHT)的开源实现。它必须轻量级且跨平台(Windows/Linux/Mac)。
它必须能够向DHT发布信息并检索信息。
5个回答

5

OpenDHT 是一个基于 C++11 的轻量级 Kademlia DHT。它的 API 非常简单:

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);

它支持在OS X、Linux和Windows上使用LLVM或GCC进行编译。


2

1

谢谢!我 git 克隆了源代码,看起来非常优质和易懂。 - Alexander Shishenko

1
我发现了一个BitTorrent DHT库,被Transmission使用。它是用纯C编写的,但可以很容易地从C++中使用。
我正在我的C++项目中使用它。它工作得很好,但需要外部加密哈希和随机化函数。

1
你可以尝试使用 Retroshare 中使用的 bitdht

太遗憾了,它不完全。 - marrat

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接