Skip to content
A C++14 Distributed Hash Table implementation
C++ Python C Rust M4 CMake Other
Branch: master
Clone or download

Latest commit

Latest commit face9f1 Mar 30, 2020


Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows github: disable tests and examples when building asio Dec 12, 2019
MSVC update copyright date Jan 3, 2020
argon2 @ 62358ba update argon2 Dec 2, 2019
c c binding: fix build Dec 16, 2019
cmake http: implement secure connection Aug 7, 2019
doc build/autoconf: always build doc Makefile Dec 2, 2019
docker docker: build c bindings, use asio 1.12 Dec 16, 2019
include network engine: retransmit value parts Mar 30, 2020
m4 autotools: update to C++14 Nov 27, 2019
python pingpong: print execution time Feb 7, 2020
resources opendht: add logo Sep 1, 2016
rust update copyright date Jan 3, 2020
src request: cleanup Mar 30, 2020
tests tests/dhtrunner: test put/listen for large values Mar 30, 2020
tools durl: cleanup, fix on macOS Feb 23, 2020
.clang-tidy build: add clang-tidy configuration Mar 17, 2019
.gitignore gitignore: ignore files from vscode, eclipse Apr 8, 2019
.gitmodules Merge pull request #175 from sim590/argon2-submodule Mar 30, 2017
.travis.yml travis: update to xenial Nov 26, 2018
CMakeLists.txt cmake: add option to build http without proxy Feb 13, 2020
COPYING Initial commit Nov 20, 2014 build/autoconf: always build doc Makefile Dec 2, 2019 Update Mar 21, 2020 Merge pull request #175 from sim590/argon2-submodule Mar 30, 2017 configure: cleanup Dec 12, 2019 c wrapper: add pkg-config file Oct 16, 2019 pkg-config: add argon2 dependency when not using included version Jun 18, 2017


A lightweight C++14 Distributed Hash Table implementation.

OpenDHT provides an easy to use distributed in-memory data store. Every node in the network can read and write values to the store. Values are distributed over the network, with redundancy.

  • Lightweight and scalable, designed for large networks and small devices
  • High resilience to network disruption
  • Public key cryptography layer providing optional data signature and encryption (using GnuTLS)
  • IPv4 and IPv6 support
  • Clean and powerful C++14 map API
  • Bindings for C, Rust & Python 3
  • REST API with optional HTTP client+server with push notification support


See the wiki:

How-to build and install

Build instructions:

How-to build a simple client app

g++ main.cpp -std=c++14 -lopendht -lgnutls


C++ example

The tools directory includes simple example programs :

  • dhtnode, a command line tool, allowing to run a DHT node and perform operations supported by the library (get, put etc.) with text values.
  • dhtchat, a very simple IM client working over the dht.

Example program launching a DHT node, connecting to the network and performing some basic operations:

#include <opendht.h>
#include <vector>

int main()
    dht::DhtRunner node;

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

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

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

    // put some data on the dht, signed with our generated private key
    node.putSigned("unique_key_42", some_data);

    // get data from the dht
    node.get("other_unique_key", [](const std::vector<std::shared_ptr<dht::Value>>& values) {
        // Callback called when values are found
        for (const auto& value : values)
            std::cout << "Found value: " << *value << std::endl;
        return true; // return false to stop the search

    // wait for dht threads to end
    return 0;

Python 3 example

import opendht as dht

node = dht.DhtRunner()

# Join the network through any running node,
# here using a known bootstrap node.
node.bootstrap("", "4222")

# blocking call (provide callback arguments to make the call non-blocking)
node.put(dht.InfoHash.get("unique_key"), dht.Value(b'some binary data'))

results = node.get(dht.InfoHash.get("unique_key"))
for r in results:


  • msgpack-c 1.2+, used for data serialization.
  • GnuTLS 3.3+, used for cryptographic operations.
  • Nettle 2.4+, a GnuTLS dependency for crypto.
  • (optional) restinio used for the REST API.
  • (optional) jsoncpp 1.7.4-3+, used for the REST API.
  • Build tested with GCC 5.2+ (GNU/Linux, Windows with MinGW), Clang/LLVM (GNU/Linux, Android, macOS, iOS).
  • Build tested with Microsoft Visual Studio 2015, 2017, 2019


IRC: join us on Freenode at #opendht.


Copyright (C) 2014-2020 Savoir-faire Linux Inc.

OpenDHT is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

See COPYING or for the full GPLv3 license.


This project was originally based on by Juliusz Chroboczek. It is independent from another project called OpenDHT (Sean Rhea. Ph.D. Thesis, 2005), now extinct.


We gratefully accept Bitcoin donations to support OpenDHT development at: bitcoin:3EykSd1An888efq4Bq3KaV3hJ3JQ4FPnwm.

You can’t perform that action at this time.