My Project 1.7.4
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) | |
InfoHash | getId () const |
PkId | getLongId () const |
ValueType | secureType (ValueType &&type) |
ValueType | secureType (const ValueType &type) |
void | registerType (const ValueType &type) |
void | registerType (ValueType &&type) |
void | registerInsecureType (const ValueType &type) |
void | get (const InfoHash &id, GetCallback cb, DoneCallback donecb={}, Value::Filter &&={}, Where &&w={}) |
void | get (const InfoHash &id, GetCallback cb, DoneCallbackSimple donecb={}, Value::Filter &&f={}, Where &&w={}) |
void | get (const InfoHash &key, GetCallbackSimple cb, DoneCallback donecb={}, Value::Filter &&f={}, Where &&w={}) |
void | get (const InfoHash &key, GetCallbackSimple cb, DoneCallbackSimple donecb, Value::Filter &&f={}, Where &&w={}) |
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 | sign (Value &v) const |
Value | encrypt (Value &v, const crypto::PublicKey &to) const |
Value | decrypt (const Value &v) |
void | findCertificate (const InfoHash &node, std::function< void(const Sp< crypto::Certificate >)> cb) |
void | findPublicKey (const InfoHash &node, std::function< void(const Sp< const crypto::PublicKey >)> cb) |
const Sp< crypto::Certificate > | registerCertificate (const InfoHash &node, const Blob &cert) |
void | registerCertificate (Sp< crypto::Certificate > &cert) |
const Sp< crypto::Certificate > | getCertificate (const InfoHash &node) const |
const Sp< const crypto::PublicKey > | getPublicKey (const InfoHash &node) const |
void | setLocalCertificateStore (CertificateStoreQuery &&query_method) |
void | shutdown (ShutdownCallback cb) |
void | dumpTables () const |
const InfoHash & | getNodeId () const |
std::pair< size_t, size_t > | getStoreSize () const |
std::string | getStorageLog () const |
std::string | getStorageLog (const InfoHash &h) const |
void | setStorageLimit (size_t limit=DEFAULT_STORAGE_LIMIT) |
std::vector< NodeExport > | exportNodes () |
std::vector< ValuesExport > | exportValues () const |
void | importValues (const std::vector< ValuesExport > &v) |
NodeStats | getNodesStats (sa_family_t af) const |
std::vector< unsigned > | getNodeMessageStats (bool in=false) |
std::string | getRoutingTablesLog (sa_family_t af) const |
std::string | getSearchesLog (sa_family_t af) const |
std::string | getSearchLog (const InfoHash &h, sa_family_t af=AF_UNSPEC) const |
std::vector< SockAddr > | getPublicAddress (sa_family_t family=0) |
time_point | periodic (const uint8_t *buf, size_t buflen, const SockAddr &sa) |
time_point | periodic (const uint8_t *buf, size_t buflen, const sockaddr *from, socklen_t fromlen) |
NodeStatus | getStatus (sa_family_t af) const |
NodeStatus | getStatus () const |
bool | isRunning (sa_family_t af=0) const |
const ValueType & | getType (ValueType::Id type_id) const |
void | insertNode (const InfoHash &id, const SockAddr &sa) |
void | insertNode (const InfoHash &id, const sockaddr *sa, socklen_t salen) |
void | insertNode (const NodeExport &n) |
void | pingNode (const sockaddr *sa, socklen_t salen, DoneCallbackSimple &&cb={}) |
void | query (const InfoHash &key, QueryCallback cb, DoneCallback done_cb={}, Query &&q={}) |
void | query (const InfoHash &key, QueryCallback cb, DoneCallbackSimple done_cb={}, Query &&q={}) |
std::vector< Sp< Value > > | getLocal (const InfoHash &key, Value::Filter f=Value::AllFilter()) const |
Sp< Value > | getLocalById (const InfoHash &key, Value::Id vid) const |
void | put (const InfoHash &key, Sp< Value > v, DoneCallback cb=nullptr, time_point created=time_point::max(), bool permanent=false) |
void | put (const InfoHash &key, const Sp< Value > &v, DoneCallbackSimple cb, time_point created=time_point::max(), bool permanent=false) |
void | put (const InfoHash &key, Value &&v, DoneCallback cb=nullptr, time_point created=time_point::max(), bool permanent=false) |
void | put (const InfoHash &key, Value &&v, DoneCallbackSimple cb, time_point created=time_point::max(), bool permanent=false) |
std::vector< Sp< Value > > | getPut (const InfoHash &h) |
Sp< Value > | getPut (const InfoHash &h, const Value::Id &vid) |
bool | cancelPut (const InfoHash &h, const Value::Id &vid) |
size_t | listen (const InfoHash &key, ValueCallback, Value::Filter={}, Where={}) |
size_t | listen (const InfoHash &key, GetCallback cb, Value::Filter={}, Where w={}) |
size_t | listen (const InfoHash &key, GetCallbackSimple cb, Value::Filter f={}, Where w={}) |
bool | cancelListen (const InfoHash &h, size_t token) |
void | connectivityChanged (sa_family_t af) |
void | connectivityChanged () |
void | forwardAllMessages (bool forward) |
void | setPushNotificationToken (const std::string &token="") |
void | pushNotificationReceived (const std::map< std::string, std::string > ¬ification) |
void | setLoggers (LogMethod error=NOLOG, LogMethod warn=NOLOG, LogMethod debug=NOLOG) |
void | setLogFilter (const InfoHash &f) |
virtual NodeStatus | getStatus (sa_family_t af) const =0 |
virtual NodeStatus | getStatus () const =0 |
virtual const InfoHash & | getNodeId () const =0 |
virtual void | shutdown (ShutdownCallback cb)=0 |
virtual bool | isRunning (sa_family_t af=0) const =0 |
virtual void | registerType (const ValueType &type)=0 |
virtual const ValueType & | getType (ValueType::Id type_id) const =0 |
virtual void | insertNode (const InfoHash &id, const SockAddr &)=0 |
virtual void | insertNode (const InfoHash &id, const sockaddr *sa, socklen_t salen)=0 |
virtual void | insertNode (const NodeExport &n)=0 |
virtual void | pingNode (const sockaddr *, socklen_t, DoneCallbackSimple &&cb={})=0 |
virtual time_point | periodic (const uint8_t *buf, size_t buflen, const SockAddr &)=0 |
virtual time_point | periodic (const uint8_t *buf, size_t buflen, const sockaddr *from, socklen_t fromlen)=0 |
virtual void | get (const InfoHash &key, GetCallback cb, DoneCallback donecb={}, Value::Filter &&f={}, Where &&w={})=0 |
virtual void | get (const InfoHash &key, GetCallback cb, DoneCallbackSimple donecb={}, Value::Filter &&f={}, Where &&w={})=0 |
virtual void | get (const InfoHash &key, GetCallbackSimple cb, DoneCallback donecb={}, Value::Filter &&f={}, Where &&w={})=0 |
virtual void | get (const InfoHash &key, GetCallbackSimple cb, DoneCallbackSimple donecb, Value::Filter &&f={}, Where &&w={})=0 |
virtual void | query (const InfoHash &key, QueryCallback cb, DoneCallback done_cb={}, Query &&q={})=0 |
virtual void | query (const InfoHash &key, QueryCallback cb, DoneCallbackSimple done_cb={}, Query &&q={})=0 |
virtual std::vector< Sp< Value > > | getLocal (const InfoHash &key, Value::Filter f=Value::AllFilter()) const =0 |
virtual Sp< Value > | getLocalById (const InfoHash &key, Value::Id vid) const =0 |
virtual void | put (const InfoHash &key, Sp< Value >, DoneCallback cb=nullptr, time_point created=time_point::max(), bool permanent=false)=0 |
virtual void | put (const InfoHash &key, const Sp< Value > &v, DoneCallbackSimple cb, time_point created=time_point::max(), bool permanent=false)=0 |
virtual void | put (const InfoHash &key, Value &&v, DoneCallback cb=nullptr, time_point created=time_point::max(), bool permanent=false)=0 |
virtual void | put (const InfoHash &key, Value &&v, DoneCallbackSimple cb, time_point created=time_point::max(), bool permanent=false)=0 |
virtual std::vector< Sp< Value > > | getPut (const InfoHash &)=0 |
virtual Sp< Value > | getPut (const InfoHash &, const Value::Id &)=0 |
virtual bool | cancelPut (const InfoHash &, const Value::Id &)=0 |
virtual size_t | listen (const InfoHash &, GetCallback, Value::Filter={}, Where w={})=0 |
virtual size_t | listen (const InfoHash &key, GetCallbackSimple cb, Value::Filter f={}, Where w={})=0 |
virtual size_t | listen (const InfoHash &, ValueCallback, Value::Filter={}, Where w={})=0 |
virtual bool | cancelListen (const InfoHash &, size_t token)=0 |
virtual void | connectivityChanged (sa_family_t)=0 |
virtual void | connectivityChanged ()=0 |
virtual std::vector< NodeExport > | exportNodes ()=0 |
virtual std::vector< ValuesExport > | exportValues () const =0 |
virtual void | importValues (const std::vector< ValuesExport > &)=0 |
virtual NodeStats | getNodesStats (sa_family_t af) const =0 |
virtual std::string | getStorageLog () const =0 |
virtual std::string | getStorageLog (const InfoHash &) const =0 |
virtual std::string | getRoutingTablesLog (sa_family_t) const =0 |
virtual std::string | getSearchesLog (sa_family_t) const =0 |
virtual std::string | getSearchLog (const InfoHash &, sa_family_t af=AF_UNSPEC) const =0 |
virtual void | dumpTables () const =0 |
virtual std::vector< unsigned > | getNodeMessageStats (bool in=false)=0 |
virtual void | setStorageLimit (size_t limit=DEFAULT_STORAGE_LIMIT)=0 |
virtual std::pair< size_t, size_t > | getStoreSize () const =0 |
virtual std::vector< SockAddr > | getPublicAddress (sa_family_t family=0)=0 |
virtual void | setLoggers (LogMethod error=NOLOG, LogMethod warn=NOLOG, LogMethod debug=NOLOG) |
virtual void | setLogFilter (const InfoHash &f) |
virtual void | setPushNotificationToken (const std::string &) |
virtual void | pushNotificationReceived (const std::map< std::string, std::string > &data)=0 |
Static Public Member Functions | |
static dht::Config & | getConfig (SecureDht::Config &conf) |
Additional Inherited Members | |
![]() | |
bool | logFilerEnable_ {} |
InfoHash | logFiler_ {} |
Logger | DHT_LOG |
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.
|
inline |
Definition at line 48 of file securedht.h.
dht::SecureDht::SecureDht | ( | std::unique_ptr< DhtInterface > | dht, |
Config | config | ||
) |
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 287 of file securedht.h.
|
inlinevirtual |
Stop any put/announce operation at the given location, for the value with the given id.
Implements dht::DhtInterface.
Definition at line 278 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 293 of file securedht.h.
|
inlinevirtual |
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 290 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 154 of file securedht.h.
|
inlinevirtual |
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 170 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 173 of file securedht.h.
|
inline |
Definition at line 297 of file securedht.h.
|
virtual |
"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.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 93 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 96 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 99 of file securedht.h.
|
inlinestatic |
Definition at line 40 of file securedht.h.
|
inline |
Definition at line 60 of file securedht.h.
|
inlinevirtual |
Get locally stored data for the given hash.
Implements dht::DhtInterface.
Definition at line 233 of file securedht.h.
|
inlinevirtual |
Get locally stored data for the given key and value id.
Implements dht::DhtInterface.
Definition at line 236 of file securedht.h.
|
inline |
Definition at line 63 of file securedht.h.
|
inlinevirtual |
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 182 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 179 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 194 of file securedht.h.
Get data currently being put at the given hash.
Implements dht::DhtInterface.
Definition at line 272 of file securedht.h.
Get data currently being put at the given hash with the given id.
Implements dht::DhtInterface.
Definition at line 275 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 185 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 188 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 191 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 206 of file securedht.h.
|
inlinevirtual |
Get the current status of the node for the given family.
Implements dht::DhtInterface.
Definition at line 203 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 161 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 164 of file securedht.h.
|
inlinevirtual |
Returns the total memory usage of stored values and the number of stored values.
Implements dht::DhtInterface.
Definition at line 158 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 212 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 176 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 215 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 218 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 221 of file securedht.h.
|
inlinevirtual |
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 209 of file securedht.h.
|
virtual |
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.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 284 of file securedht.h.
|
virtual |
Implements dht::DhtInterface.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 197 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 200 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 224 of file securedht.h.
|
inlinevirtual |
Call linked callback with push_notification
notification | to process |
Implements dht::DhtInterface.
Definition at line 309 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 247 of file securedht.h.
|
inlinevirtual |
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 239 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 256 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 264 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 117 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 107 of file securedht.h.
|
inlinevirtual |
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 227 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 230 of file securedht.h.
|
inline |
Definition at line 82 of file securedht.h.
|
inlinevirtual |
Implements dht::DhtInterface.
Definition at line 74 of file securedht.h.
|
inline |
Definition at line 78 of file securedht.h.
Definition at line 69 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 144 of file securedht.h.
|
inlinevirtual |
Only print logs related to the given InfoHash (if given), or disable filter (if zeroes).
Reimplemented from dht::DhtInterface.
Definition at line 324 of file securedht.h.
|
inlinevirtual |
Enable or disable logging of DHT internal messages
Reimplemented from dht::DhtInterface.
Definition at line 313 of file securedht.h.
|
inlinevirtual |
Reimplemented from dht::DhtInterface.
Definition at line 301 of file securedht.h.
|
inlinevirtual |
Set the in-memory storage limit in bytes
Implements dht::DhtInterface.
Definition at line 167 of file securedht.h.
|
inlinevirtual |
void dht::SecureDht::sign | ( | Value & | v | ) | const |
Take ownership of the value and sign it using our private key.