My Project 3.2.0
C++ Distributed Hash Table
|
Public Types | |
typedef std::function< void(bool)> | SignatureCheckCallback |
using | Config = SecureDhtConfig |
![]() | |
using | Status = NodeStatus |
using | NodeExport = dht::NodeExport |
Public Member Functions | |
SecureDht (std::unique_ptr< DhtInterface > dht, Config config, IdentityAnnouncedCb iacb={}, const std::shared_ptr< Logger > &l={}) | |
InfoHash | getId () const |
PkId | getLongId () const |
Sp< crypto::PublicKey > | getPublicKey () const |
ValueType | secureType (ValueType &&type) |
ValueType | secureType (const ValueType &type) |
void | registerType (const ValueType &type) override |
void | registerType (ValueType &&type) |
void | registerInsecureType (const ValueType &type) |
void | get (const InfoHash &id, GetCallback cb, DoneCallback donecb={}, Value::Filter &&={}, Where &&w={}) override |
void | get (const InfoHash &id, GetCallback cb, DoneCallbackSimple donecb={}, Value::Filter &&f={}, Where &&w={}) override |
void | get (const InfoHash &key, GetCallbackSimple cb, DoneCallback donecb={}, Value::Filter &&f={}, Where &&w={}) override |
void | get (const InfoHash &key, GetCallbackSimple cb, DoneCallbackSimple donecb, Value::Filter &&f={}, Where &&w={}) override |
void | putSigned (const InfoHash &hash, Sp< Value > val, DoneCallback callback, bool permanent=false) |
void | putSigned (const InfoHash &hash, Value &&v, DoneCallback callback, bool permanent=false) |
void | putEncrypted (const InfoHash &hash, const InfoHash &to, Sp< Value > val, DoneCallback callback, bool permanent=false) |
void | putEncrypted (const InfoHash &hash, const InfoHash &to, Value &&v, DoneCallback callback, bool permanent=false) |
void | putEncrypted (const InfoHash &hash, const crypto::PublicKey &to, Sp< Value > val, DoneCallback callback, bool permanent=false) |
void | putEncrypted (const InfoHash &hash, const crypto::PublicKey &to, Value &&v, DoneCallback callback, bool permanent=false) |
void | sign (Value &v) const |
Value | encrypt (Value &v, const crypto::PublicKey &to) const |
Value | decrypt (const Value &v) |
void | findCertificate (const InfoHash &node, const std::function< void(const Sp< crypto::Certificate >)> &cb) |
void | findPublicKey (const InfoHash &node, const std::function< void(const Sp< crypto::PublicKey >)> &cb) |
Sp< crypto::Certificate > | registerCertificate (const InfoHash &node, const Blob &cert) |
void | registerCertificate (Sp< crypto::Certificate > &cert) |
Sp< crypto::Certificate > | getCertificate (const InfoHash &node) const |
Sp< crypto::PublicKey > | getPublicKey (const InfoHash &node) const |
void | setLocalCertificateStore (CertificateStoreQuery &&query_method) |
void | setOnPublicAddressChanged (PublicAddressChangedCb cb) override |
void | shutdown (ShutdownCallback cb, bool stop=false) override |
void | dumpTables () const override |
const InfoHash & | getNodeId () const override |
std::pair< size_t, size_t > | getStoreSize () const override |
std::string | getStorageLog () const override |
std::string | getStorageLog (const InfoHash &h) const override |
void | setStorageLimit (size_t limit=DEFAULT_STORAGE_LIMIT) override |
size_t | getStorageLimit () const override |
std::vector< NodeExport > | exportNodes () const override |
std::vector< ValuesExport > | exportValues () const override |
void | importValues (const std::vector< ValuesExport > &v) override |
NodeStats | getNodesStats (sa_family_t af) const override |
std::vector< unsigned > | getNodeMessageStats (bool in=false) override |
std::string | getRoutingTablesLog (sa_family_t af) const override |
std::string | getSearchesLog (sa_family_t af) const override |
std::string | getSearchLog (const InfoHash &h, sa_family_t af=AF_UNSPEC) const override |
std::vector< SockAddr > | getPublicAddress (sa_family_t family=0) override |
time_point | periodic (const uint8_t *buf, size_t buflen, SockAddr sa, const time_point &now) override |
time_point | periodic (const uint8_t *buf, size_t buflen, const sockaddr *from, socklen_t fromlen, const time_point &now) override |
NodeStatus | updateStatus (sa_family_t af) override |
NodeStatus | getStatus (sa_family_t af) const override |
NodeStatus | getStatus () const override |
net::DatagramSocket * | getSocket () const override |
bool | isRunning (sa_family_t af=0) const override |
const ValueType & | getType (ValueType::Id type_id) const override |
void | addBootstrap (const std::string &host, const std::string &service) override |
void | clearBootstrap () override |
void | insertNode (const InfoHash &id, const SockAddr &sa) override |
void | insertNode (const NodeExport &n) override |
void | pingNode (SockAddr sa, DoneCallbackSimple &&cb={}) override |
void | query (const InfoHash &key, QueryCallback cb, DoneCallback done_cb={}, Query &&q={}) override |
void | query (const InfoHash &key, QueryCallback cb, DoneCallbackSimple done_cb={}, Query &&q={}) override |
std::vector< Sp< Value > > | getLocal (const InfoHash &key, const Value::Filter &f={}) const override |
Sp< Value > | getLocalById (const InfoHash &key, Value::Id vid) const override |
void | put (const InfoHash &key, Sp< Value > v, DoneCallback cb=nullptr, time_point created=time_point::max(), bool permanent=false) override |
void | put (const InfoHash &key, const Sp< Value > &v, DoneCallbackSimple cb, time_point created=time_point::max(), bool permanent=false) override |
void | put (const InfoHash &key, Value &&v, DoneCallback cb=nullptr, time_point created=time_point::max(), bool permanent=false) override |
void | put (const InfoHash &key, Value &&v, DoneCallbackSimple cb, time_point created=time_point::max(), bool permanent=false) override |
std::vector< Sp< Value > > | getPut (const InfoHash &h) const override |
Sp< Value > | getPut (const InfoHash &h, const Value::Id &vid) const override |
bool | cancelPut (const InfoHash &h, const Value::Id &vid) override |
size_t | listen (const InfoHash &key, ValueCallback, Value::Filter={}, Where={}) override |
size_t | listen (const InfoHash &key, GetCallback cb, Value::Filter={}, Where w={}) override |
size_t | listen (const InfoHash &key, GetCallbackSimple cb, Value::Filter f={}, Where w={}) override |
bool | cancelListen (const InfoHash &h, size_t token) override |
void | connectivityChanged (sa_family_t af) override |
void | connectivityChanged () override |
void | forwardAllMessages (bool forward) |
void | setPushNotificationToken (const std::string &token="") override |
void | pushNotificationReceived (const std::map< std::string, std::string > ¬ification) override |
void | setLogger (const Logger &logger) override |
void | setLogger (const std::shared_ptr< Logger > &logger) override |
void | setLogFilter (const InfoHash &f) override |
![]() | |
DhtInterface (const Logger &l) | |
DhtInterface (const std::shared_ptr< Logger > &l) | |
void | addOnConnectedCallback (std::function< void()> cb) |
virtual void | setPushNotificationTopic (const std::string &) |
virtual void | setPushNotificationPlatform (const std::string &) |
Static Public Member Functions | |
static dht::Config | getConfig (const SecureDht::Config &conf) |
Additional Inherited Members | |
![]() | |
std::shared_ptr< Logger > | logger_ {} |
std::queue< std::function< void()> > | onConnectCallbacks_ {} |
Definition at line 33 of file securedht.h.
Definition at line 38 of file securedht.h.
typedef std::function<void(bool)> dht::SecureDht::SignatureCheckCallback |
Definition at line 36 of file securedht.h.
dht::SecureDht::SecureDht | ( | std::unique_ptr< DhtInterface > | dht, |
Config | config, | ||
IdentityAnnouncedCb | iacb = {}, | ||
const std::shared_ptr< Logger > & | l = {} ) |
|
inlineoverridevirtual |
Reimplemented from dht::DhtInterface.
Definition at line 234 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 309 of file securedht.h.
|
inlineoverridevirtual |
Stop any put/announce operation at the given location, for the value with the given id.
Implements dht::DhtInterface.
Definition at line 300 of file securedht.h.
|
inlineoverridevirtual |
Reimplemented from dht::DhtInterface.
Definition at line 237 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 315 of file securedht.h.
|
inlineoverridevirtual |
Inform the DHT of lower-layer connectivity changes. This will cause the DHT to assume a public IP address change. The DHT will recontact neighbor nodes, re-register for listen ops etc.
Implements dht::DhtInterface.
Definition at line 312 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 162 of file securedht.h.
|
inlineoverridevirtual |
Get the list of good nodes for local storage saving purposes The list is ordered to minimize the back-to-work delay.
Implements dht::DhtInterface.
Definition at line 183 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 186 of file securedht.h.
|
inline |
Definition at line 319 of file securedht.h.
|
overridevirtual |
"Secure" get(), that will check the signature of signed data, and decrypt encrypted data. If the signature can't be checked, or if the data can't be decrypted, it is not returned. Public, non-signed & non-encrypted data is retransmitted as-is.
Implements dht::DhtInterface.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 94 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 97 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 100 of file securedht.h.
|
inlinestatic |
Definition at line 40 of file securedht.h.
|
inline |
Definition at line 58 of file securedht.h.
|
inlineoverridevirtual |
Get locally stored data for the given hash.
Implements dht::DhtInterface.
Definition at line 255 of file securedht.h.
|
inlineoverridevirtual |
Get locally stored data for the given key and value id.
Implements dht::DhtInterface.
Definition at line 258 of file securedht.h.
|
inline |
Definition at line 61 of file securedht.h.
|
inlineoverridevirtual |
Get the ID of the DHT node.
Implements dht::DhtInterface.
Definition at line 165 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 195 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 192 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 207 of file securedht.h.
|
inline |
Definition at line 64 of file securedht.h.
Get data currently being put at the given hash.
Implements dht::DhtInterface.
Definition at line 294 of file securedht.h.
|
inlineoverridevirtual |
Get data currently being put at the given hash with the given id.
Implements dht::DhtInterface.
Definition at line 297 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 198 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 201 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 204 of file securedht.h.
|
inlineoverridevirtual |
Reimplemented from dht::DhtInterface.
Definition at line 225 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 222 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 219 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 179 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 170 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 173 of file securedht.h.
|
inlineoverridevirtual |
Returns the total memory usage of stored values and the number of stored values.
Implements dht::DhtInterface.
Definition at line 167 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 231 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 189 of file securedht.h.
Insert a node in the main routing table. The node is not pinged, so this should be used to bootstrap efficiently from previously known nodes.
Implements dht::DhtInterface.
Definition at line 240 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 243 of file securedht.h.
|
inlineoverridevirtual |
Returns true if the node is running (have access to an open socket).
af: address family. If non-zero, will return true if the node is running for the provided family.
Implements dht::DhtInterface.
Definition at line 228 of file securedht.h.
|
overridevirtual |
Listen on the network for any changes involving a specified hash. The node will register to receive updates from relevent nodes when new values are added or removed.
Implements dht::DhtInterface.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 306 of file securedht.h.
|
overridevirtual |
Implements dht::DhtInterface.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 213 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 210 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 246 of file securedht.h.
|
inlineoverridevirtual |
Call linked callback with push_notification
notification | to process |
Implements dht::DhtInterface.
Definition at line 331 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 269 of file securedht.h.
|
inlineoverridevirtual |
Announce a value on all available protocols (IPv4, IPv6).
The operation will start as soon as the node is connected to the network. The done callback will be called once, when the first announce succeeds, or fails.
Implements dht::DhtInterface.
Definition at line 261 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 278 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 286 of file securedht.h.
|
inline |
Definition at line 122 of file securedht.h.
void dht::SecureDht::putEncrypted | ( | const InfoHash & | hash, |
const InfoHash & | to, | ||
Sp< Value > | val, | ||
DoneCallback | callback, | ||
bool | permanent = false ) |
Will sign the data using our private key, encrypt it using the recipient' public key, and put it in the DHT. The operation will be immediate if the recipient' public key is known (otherwise it will be retrived first).
|
inline |
Definition at line 118 of file securedht.h.
void dht::SecureDht::putSigned | ( | const InfoHash & | hash, |
Sp< Value > | val, | ||
DoneCallback | callback, | ||
bool | permanent = false ) |
Will take ownership of the value, sign it using our private key and put it in the DHT.
|
inline |
Definition at line 108 of file securedht.h.
|
inlineoverridevirtual |
Similar to Dht::get, but sends a Query to filter data remotely.
key | the key for which to query data for. |
cb | a function called when new values are found on the network. It should return false to stop the operation. |
done_cb | a function called when the operation is complete. cb and done_cb won't be called again afterward. |
q | a query used to filter values on the remotes before they send a response. |
Implements dht::DhtInterface.
Definition at line 249 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 252 of file securedht.h.
|
inline |
Definition at line 83 of file securedht.h.
|
inlineoverridevirtual |
Implements dht::DhtInterface.
Definition at line 75 of file securedht.h.
|
inline |
Definition at line 79 of file securedht.h.
Definition at line 70 of file securedht.h.
|
inline |
Allows to set a custom callback called by the library to find a locally-stored certificate. The search key used is the public key ID, so there may be multiple certificates retured, signed with the same private key.
Definition at line 149 of file securedht.h.
|
inlineoverridevirtual |
Only print logs related to the given InfoHash (if given), or disable filter (if zeroes).
Reimplemented from dht::DhtInterface.
Definition at line 348 of file securedht.h.
|
inlineoverridevirtual |
Reimplemented from dht::DhtInterface.
Definition at line 335 of file securedht.h.
|
inlineoverridevirtual |
Reimplemented from dht::DhtInterface.
Definition at line 340 of file securedht.h.
|
inlineoverridevirtual |
Reimplemented from dht::DhtInterface.
Definition at line 152 of file securedht.h.
|
inlineoverridevirtual |
Reimplemented from dht::DhtInterface.
Definition at line 323 of file securedht.h.
|
inlineoverridevirtual |
Set the in-memory storage limit in bytes
Implements dht::DhtInterface.
Definition at line 176 of file securedht.h.
|
inlineoverridevirtual |
void dht::SecureDht::sign | ( | Value & | v | ) | const |
Take ownership of the value and sign it using our private key.
|
inlineoverridevirtual |
Get the current status of the node for the given family.
Reimplemented from dht::DhtInterface.
Definition at line 216 of file securedht.h.