• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

MSVC/H03-Aug-2019-4,4054,138

argon2/H03-Aug-2019-

cmake/H03-Aug-2019-160136

doc/H03-May-2022-1,2511,049

docker/H03-Aug-2019-7157

include/H03-Aug-2019-7,8294,415

m4/H03-Aug-2019-563446

python/H03-May-2022-3,8953,199

resources/H03-May-2022-

src/H03-Aug-2019-15,17712,410

tests/H03-Aug-2019-1,341736

tools/H03-May-2022-1,2951,083

.clang-tidyH A D03-Aug-2019257 21

.gitignoreH A D03-Aug-2019644 7663

.gitmodulesH A D03-Aug-2019102 54

.travis.ymlH A D03-Aug-20192.1 KiB6959

COPYINGH A D03-Aug-201934.3 KiB675553

Makefile.amH A D03-Aug-2019369 3423

README.mdH A D03-Aug-20194.5 KiB12393

autogen.shH A D03-Aug-201965 32

configure.acH A D03-Aug-20197.6 KiB204173

opendht.pc.inH A D03-Aug-2019283 1211

README.md

1<img src="https://raw.githubusercontent.com/savoirfairelinux/opendht/master/resources/opendht_logo_512.png" width="100" align="right">
2<br>
3<h1 style="margin-top:10px">
4    <a id="user-content-opendht-" class="anchor" href="/savoirfairelinux/opendht/blob/master/README.md#opendht-" aria-hidden="true"></a>OpenDHT
5</h1>
6
7A lightweight C++11 Distributed Hash Table implementation.
8
9OpenDHT provides an easy to use distributed in-memory data store.
10Every node in the network can read and write values to the store.
11Values are distributed over the network, with redundancy.
12
13 * Lightweight and scalable, designed for large networks and small devices
14 * High resilience to network disruption
15 * Public key cryptography layer providing optional data signature and encryption (using GnuTLS)
16 * IPv4 and IPv6 support
17 * Clean and powerful C++11 map API
18 * Python 3 bindings
19 * REST API
20
21## Documentation
22See the wiki: <https://github.com/savoirfairelinux/opendht/wiki>
23
24#### How-to build and install
25
26Build instructions: <https://github.com/savoirfairelinux/opendht/wiki/Build-the-library>
27
28#### How-to build a simple client app
29```bash
30g++ main.cpp -std=c++11 -lopendht -lgnutls
31```
32
33## Examples
34### C++ example
35The `tools` directory includes simple example programs :
36* `dhtnode`, a command line tool, allowing to run a DHT node and perform operations supported by the library (get, put etc.) with text values.
37* `dhtchat`, a very simple IM client working over the dht.
38
39Example program launching a DHT node, connecting to the network and performing some basic operations:
40```c++
41#include <opendht.h>
42#include <vector>
43
44int main()
45{
46    dht::DhtRunner node;
47
48    // Launch a dht node on a new thread, using a
49    // generated RSA key pair, and listen on port 4222.
50    node.run(4222, dht::crypto::generateIdentity(), true);
51
52    // Join the network through any running node,
53    // here using a known bootstrap node.
54    node.bootstrap("bootstrap.ring.cx", "4222");
55
56    // put some data on the dht
57    std::vector<uint8_t> some_data(5, 10);
58    node.put("unique_key", some_data);
59
60    // put some data on the dht, signed with our generated private key
61    node.putSigned("unique_key_42", some_data);
62
63    // get data from the dht
64    node.get("other_unique_key", [](const std::vector<std::shared_ptr<dht::Value>>& values) {
65        // Callback called when values are found
66        for (const auto& value : values)
67            std::cout << "Found value: " << *value << std::endl;
68        return true; // return false to stop the search
69    });
70
71    // wait for dht threads to end
72    node.join();
73    return 0;
74}
75```
76### Python 3 example
77```python
78import opendht as dht
79
80node = dht.DhtRunner()
81node.run()
82
83# Join the network through any running node,
84# here using a known bootstrap node.
85node.bootstrap("bootstrap.ring.cx", "4222")
86
87# blocking call (provide callback arguments to make the call non-blocking)
88node.put(dht.InfoHash.get("unique_key"), dht.Value(b'some binary data'))
89
90results = node.get(dht.InfoHash.get("unique_key"))
91for r in results:
92    print(r)
93```
94
95## Dependencies
96- msgpack-c 1.2+, used for data serialization.
97- GnuTLS 3.3+, used for cryptographic operations.
98- Nettle 2.4+, a GnuTLS dependency for crypto.
99- (optional) restbed used for the REST API. commit fb84213e170bc171fecd825a8e47ed9f881a12cd (https://github.com/AmarOk1412/restbed/tree/async_read_until)
100- (optional) jsoncpp 1.7.4-3+, used for the REST API.
101- Build tested with GCC 5.2+ (GNU/Linux, Windows with MinGW), Clang/LLVM (GNU/Linux, Android, macOS, iOS).
102- Build tested with Microsoft Visual Studio 2015
103
104## Contact
105
106IRC: join us on Freenode at [`#opendht`](https://webchat.freenode.net/?channels=%23opendht).
107
108## License
109Copyright (C) 2014-2019 Savoir-faire Linux Inc.
110
111OpenDHT 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.
112
113This 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.
114
115See COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html for the full GPLv3 license.
116
117## Acknowledgements
118This project was originally based on https://github.com/jech/dht by Juliusz Chroboczek.
119It is independent from another project called OpenDHT (Sean Rhea. Ph.D. Thesis, 2005), now extinct.
120
121## Donations
122We gratefully accept Bitcoin donations to support OpenDHT development at: `bitcoin:3EykSd1An888efq4Bq3KaV3hJ3JQ4FPnwm`.
123