|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 03-May-2022 | - |
| MSVC/ | H | 03-Aug-2019 | - | 4,405 | 4,138 |
| argon2/ | H | 03-Aug-2019 | - | | |
| cmake/ | H | 03-Aug-2019 | - | 160 | 136 |
| doc/ | H | 03-May-2022 | - | 1,251 | 1,049 |
| docker/ | H | 03-Aug-2019 | - | 71 | 57 |
| include/ | H | 03-Aug-2019 | - | 7,829 | 4,415 |
| m4/ | H | 03-Aug-2019 | - | 563 | 446 |
| python/ | H | 03-May-2022 | - | 3,895 | 3,199 |
| resources/ | H | 03-May-2022 | - | | |
| src/ | H | 03-Aug-2019 | - | 15,177 | 12,410 |
| tests/ | H | 03-Aug-2019 | - | 1,341 | 736 |
| tools/ | H | 03-May-2022 | - | 1,295 | 1,083 |
| .clang-tidy | H A D | 03-Aug-2019 | 257 | 2 | 1 |
| .gitignore | H A D | 03-Aug-2019 | 644 | 76 | 63 |
| .gitmodules | H A D | 03-Aug-2019 | 102 | 5 | 4 |
| .travis.yml | H A D | 03-Aug-2019 | 2.1 KiB | 69 | 59 |
| COPYING | H A D | 03-Aug-2019 | 34.3 KiB | 675 | 553 |
| Makefile.am | H A D | 03-Aug-2019 | 369 | 34 | 23 |
| README.md | H A D | 03-Aug-2019 | 4.5 KiB | 123 | 93 |
| autogen.sh | H A D | 03-Aug-2019 | 65 | 3 | 2 |
| configure.ac | H A D | 03-Aug-2019 | 7.6 KiB | 204 | 173 |
| opendht.pc.in | H A D | 03-Aug-2019 | 283 | 12 | 11 |
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