My Project: dht::DhtProxyClient Class Reference

My Project 3.7.7 C++ Distributed Hash Table

Loading...
Searching...
No Matches
Public Member Functions | List of all members
dht::DhtProxyClient Class Referencefinal
Inheritance diagram for dht::DhtProxyClient:
[legend]
Collaboration diagram for dht::DhtProxyClient:
[legend]

## Public Member Functions
| DhtProxyClient (std::shared_ptr< crypto::Certificate > serverCA, crypto::Identity clientIdentity, std::function< void()> loopSignal, const std::string &serverHost, const std::string &userAgent="", const std::string &pushClientId="", const std::string &pushToken="", const std::string &pushTopic="", const std::string &pushPlatform="", std::shared_ptr< Logger > logger={})
void | setHeaderFields (http::Request &request)
virtual void | setPushNotificationToken (const std::string &token) override
virtual void | setPushNotificationTopic (const std::string &topic) override
virtual void | setPushNotificationPlatform (const std::string &platform) override
const InfoHash & | getNodeId () const override
void | setOnPublicAddressChanged (PublicAddressChangedCb cb) override
NodeStatus | getStatus (sa_family_t af) const override
NodeStatus | getStatus () const override
void | shutdown (ShutdownCallback cb, bool) override
bool | isRunning (sa_family_t af=0) const override
virtual void | get (const InfoHash &key, GetCallback cb, DoneCallback donecb={}, Value::Filter &&f={}, Where &&w={}) override
virtual void | get (const InfoHash &key, GetCallback cb, DoneCallbackSimple donecb={}, Value::Filter &&f={}, Where &&w={}) override
virtual void | get (const InfoHash &key, GetCallbackSimple cb, DoneCallback donecb={}, Value::Filter &&f={}, Where &&w={}) override
virtual void | get (const InfoHash &key, GetCallbackSimple cb, DoneCallbackSimple donecb, Value::Filter &&f={}, Where &&w={}) override
void | put (const InfoHash &key, Sp< Value >, 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
NodeStats | getNodesStats (sa_family_t af) const override
std::vector< SockAddr > | getPublicAddress (sa_family_t family=0) override
virtual size_t | listen (const InfoHash &, ValueCallback, Value::Filter={}, Where={}) override
virtual size_t | listen (const InfoHash &key, GetCallback cb, Value::Filter f={}, Where w={}) override
virtual size_t | listen (const InfoHash &key, GetCallbackSimple cb, Value::Filter f={}, Where w={}) override
virtual bool | cancelListen (const InfoHash &key, size_t token) override
PushNotificationResult | pushNotificationReceived (const std::map< std::string, std::string > &notification) override
time_point | periodic (const uint8_t *, size_t, SockAddr, 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
virtual void | query (const InfoHash &, QueryCallback, DoneCallback={}, Query &&={}) override
virtual void | query (const InfoHash &key, QueryCallback cb, DoneCallbackSimple done_cb={}, Query &&q={}) override
std::vector< Sp< Value > > | getPut (const InfoHash &) const override
Sp< Value > | getPut (const InfoHash &, const Value::Id &) const override
bool | cancelPut (const InfoHash &, const Value::Id &) override
void | pingNode (SockAddr, DoneCallbackSimple &&={}) override
virtual void | registerType (const ValueType &type) override
const ValueType & | getType (ValueType::Id type_id) const override
std::vector< Sp< Value > > | getLocal (const InfoHash &k, const Value::Filter &filter) const override
Sp< Value > | getLocalById (const InfoHash &k, Value::Id id) const override
void | insertNode (const InfoHash &, const SockAddr &) override
void | insertNode (const NodeExport &) override
std::pair< size_t, size_t > | getStoreSize () const override
std::pair< size_t, size_t > | getLocalStoreSize () const override
std::vector< NodeExport > | exportNodes () const override
std::vector< ValuesExport > | exportValues () const override
void | importValues (const std::vector< ValuesExport > &) override
std::string | getStorageLog () const override
std::string | getStorageLog (const InfoHash &) const override
std::string | getRoutingTablesLog (sa_family_t) const override
std::string | getSearchesLog (sa_family_t) const override
std::string | getSearchLog (const InfoHash &, sa_family_t) const override
void | dumpTables () const override
std::vector< unsigned > | getNodeMessageStats (bool) override
void | setStorageLimit (size_t) override
virtual size_t | getStorageLimit () const override
void | setLocalStorageLimit (size_t) override
virtual size_t | getLocalStorageLimit () const override
void | connectivityChanged (sa_family_t) override
void | connectivityChanged () override
void | listenKeepIdle (uint32_t seconds)
uint32_t | listenKeepIdle ()
Public Member Functions inherited from dht::DhtInterface
| DhtInterface (const std::shared_ptr< Logger > &l)
virtual NodeStatus | updateStatus (sa_family_t af)
void | addOnConnectedCallback (std::function< void()> cb)
virtual net::DatagramSocket * | getSocket () const
virtual void | addBootstrap (const std::string &, const std::string &)
virtual void | clearBootstrap ()
virtual void | setLogger (const std::shared_ptr< Logger > &l)
virtual void | setLogFilter (const InfoHash &f)

## Additional Inherited Members
Public Types inherited from dht::DhtInterface
using | Status = NodeStatus
using | NodeExport = dht::NodeExport
Protected Attributes inherited from dht::DhtInterface
std::shared_ptr< Logger > | logger_ {}
std::queue< std::function< void()> > | onConnectCallbacks_ {}

## Detailed Description

Definition at line 32 of file dht_proxy_client.h.

## Member Function Documentation

## ◆ cancelListen()

virtual bool dht::DhtProxyClient::cancelListen | ( | const InfoHash & | key,
|  | size_t | token )
| overridevirtual

Implements dht::DhtInterface.

## ◆ cancelPut()

bool dht::DhtProxyClient::cancelPut | ( | const InfoHash & | ,
|  | const Value::Id & | )
| overridevirtual

Stop any put/announce operation at the given location, for the value with the given id.

Implements dht::DhtInterface.

## ◆ connectivityChanged() [1/2]

void dht::DhtProxyClient::connectivityChanged | ( |  | ) |
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 295 of file dht_proxy_client.h.

## ◆ connectivityChanged() [2/2]

void dht::DhtProxyClient::connectivityChanged | ( | sa_family_t |  | ) |
| 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 294 of file dht_proxy_client.h.

## ◆ dumpTables()

void dht::DhtProxyClient::dumpTables | ( |  | ) | const
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 288 of file dht_proxy_client.h.

## ◆ exportNodes()

std::vector< NodeExport > dht::DhtProxyClient::exportNodes | ( |  | ) | const
| 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 280 of file dht_proxy_client.h.

## ◆ exportValues()

std::vector< ValuesExport > dht::DhtProxyClient::exportValues | ( |  | ) | const
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 281 of file dht_proxy_client.h.

## ◆ get() [1/4]

virtual void dht::DhtProxyClient::get | ( | const InfoHash & | key,
|  | GetCallback | cb,
|  | DoneCallback | donecb = {},
|  | Value::Filter && | f = {},
|  | Where && | w = {} )
| overridevirtual

Get a value by asking the proxy and call the provided get callback when values are found at key. The operation will start as soon as the node is connected to the network.

Parameters

  cb | a function called when new values are found on the network. It should return false to stop the operation.
  donecb | a function called when the operation is complete. cb and donecb won't be called again afterward.
  f | a filter function used to prefilter values.

Implements dht::DhtInterface.

## ◆ get() [2/4]

virtual void dht::DhtProxyClient::get | ( | const InfoHash & | key,
|  | GetCallback | cb,
|  | DoneCallbackSimple | donecb = {},
|  | Value::Filter && | f = {},
|  | Where && | w = {} )
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 109 of file dht_proxy_client.h.

## ◆ get() [3/4]

virtual void dht::DhtProxyClient::get | ( | const InfoHash & | key,
|  | GetCallbackSimple | cb,
|  | DoneCallback | donecb = {},
|  | Value::Filter && | f = {},
|  | Where && | w = {} )
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 117 of file dht_proxy_client.h.

## ◆ get() [4/4]

virtual void dht::DhtProxyClient::get | ( | const InfoHash & | key,
|  | GetCallbackSimple | cb,
|  | DoneCallbackSimple | donecb,
|  | Value::Filter && | f = {},
|  | Where && | w = {} )
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 125 of file dht_proxy_client.h.

## ◆ getLocal()

std::vector< Sp< Value > > dht::DhtProxyClient::getLocal | ( | const InfoHash & | key,
|  | const Value::Filter & | f ) const
| overridevirtual

Get locally stored data for the given hash.

Implements dht::DhtInterface.

## ◆ getLocalById()

Sp< Value > dht::DhtProxyClient::getLocalById | ( | const InfoHash & | key,
|  | Value::Id | vid ) const
| overridevirtual

Get locally stored data for the given key and value id.

Implements dht::DhtInterface.

## ◆ getLocalStorageLimit()

virtual size_t dht::DhtProxyClient::getLocalStorageLimit | ( |  | ) | const
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 293 of file dht_proxy_client.h.

## ◆ getLocalStoreSize()

std::pair< size_t, size_t > dht::DhtProxyClient::getLocalStoreSize | ( |  | ) | const
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 279 of file dht_proxy_client.h.

## ◆ getNodeId()

const InfoHash & dht::DhtProxyClient::getNodeId | ( |  | ) | const
| inlineoverridevirtual

Get the ID of the node.

Implements dht::DhtInterface.

Definition at line 75 of file dht_proxy_client.h.

## ◆ getNodeMessageStats()

std::vector< unsigned > dht::DhtProxyClient::getNodeMessageStats | ( | bool |  | ) |
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 289 of file dht_proxy_client.h.

## ◆ getNodesStats()

NodeStats dht::DhtProxyClient::getNodesStats | ( | sa_family_t | af | ) | const
| overridevirtual

Parameters

  af | the socket family

Returns
  node stats from the proxy

Implements dht::DhtInterface.

## ◆ getPublicAddress()

std::vector< SockAddr > dht::DhtProxyClient::getPublicAddress | ( | sa_family_t | family = 0 | ) |
| overridevirtual

Parameters

  family | the socket family

Returns
  public address

Implements dht::DhtInterface.

## ◆ getPut() [1/2]

std::vector< Sp< Value > > dht::DhtProxyClient::getPut | ( | const InfoHash & |  | ) | const
| overridevirtual

Get data currently being put at the given hash.

Implements dht::DhtInterface.

## ◆ getPut() [2/2]

Sp< Value > dht::DhtProxyClient::getPut | ( | const InfoHash & | ,
|  | const Value::Id & | ) const
| overridevirtual

Get data currently being put at the given hash with the given id.

Implements dht::DhtInterface.

## ◆ getRoutingTablesLog()

std::string dht::DhtProxyClient::getRoutingTablesLog | ( | sa_family_t |  | ) | const
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 285 of file dht_proxy_client.h.

## ◆ getSearchesLog()

std::string dht::DhtProxyClient::getSearchesLog | ( | sa_family_t |  | ) | const
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 286 of file dht_proxy_client.h.

## ◆ getSearchLog()

std::string dht::DhtProxyClient::getSearchLog | ( | const InfoHash & | ,
|  | sa_family_t | ) const
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 287 of file dht_proxy_client.h.

## ◆ getStatus() [1/2]

NodeStatus dht::DhtProxyClient::getStatus | ( |  | ) | const
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 82 of file dht_proxy_client.h.

## ◆ getStatus() [2/2]

NodeStatus dht::DhtProxyClient::getStatus | ( | sa_family_t | af | ) | const
| overridevirtual

Get the current status of the node for the given family.

Implements dht::DhtInterface.

## ◆ getStorageLimit()

virtual size_t dht::DhtProxyClient::getStorageLimit | ( |  | ) | const
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 291 of file dht_proxy_client.h.

## ◆ getStorageLog() [1/2]

std::string dht::DhtProxyClient::getStorageLog | ( |  | ) | const
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 283 of file dht_proxy_client.h.

## ◆ getStorageLog() [2/2]

std::string dht::DhtProxyClient::getStorageLog | ( | const InfoHash & |  | ) | const
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 284 of file dht_proxy_client.h.

## ◆ getStoreSize()

std::pair< size_t, size_t > dht::DhtProxyClient::getStoreSize | ( |  | ) | const
| inlineoverridevirtual

Returns the total memory usage of stored values and the number of stored values.

Implements dht::DhtInterface.

Definition at line 278 of file dht_proxy_client.h.

## ◆ getType()

const ValueType & dht::DhtProxyClient::getType | ( | ValueType::Id | type_id | ) | const
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 267 of file dht_proxy_client.h.

## ◆ importValues()

void dht::DhtProxyClient::importValues | ( | const std::vector< ValuesExport > & |  | ) |
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 282 of file dht_proxy_client.h.

## ◆ insertNode() [1/2]

void dht::DhtProxyClient::insertNode | ( | const InfoHash & | ,
|  | const SockAddr & | )
| inlineoverridevirtual

NOTE: The following methods will not be implemented because the DhtProxyClient doesn't have any storage nor synchronization process

Implements dht::DhtInterface.

Definition at line 276 of file dht_proxy_client.h.

## ◆ insertNode() [2/2]

void dht::DhtProxyClient::insertNode | ( | const NodeExport & |  | ) |
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 277 of file dht_proxy_client.h.

## ◆ isRunning()

bool dht::DhtProxyClient::isRunning | ( | sa_family_t | af = 0 | ) | const
| overridevirtual

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.

## ◆ listen() [1/3]

virtual size_t dht::DhtProxyClient::listen | ( | const InfoHash & | ,
|  | ValueCallback | ,
|  | Value::Filter | = {},
|  | Where | = {} )
| 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.

Returns
  a token to cancel the listener later.

Implements dht::DhtInterface.

## ◆ listen() [2/3]

virtual size_t dht::DhtProxyClient::listen | ( | const InfoHash & | ,
|  | GetCallback | ,
|  | Value::Filter | = {},
|  | Where | w = {} )
| inlineoverridevirtual

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.

Returns
  a token to cancel the listener later.

Implements dht::DhtInterface.

Definition at line 193 of file dht_proxy_client.h.

## ◆ listen() [3/3]

virtual size_t dht::DhtProxyClient::listen | ( | const InfoHash & | key,
|  | GetCallbackSimple | cb,
|  | Value::Filter | f = {},
|  | Where | w = {} )
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 205 of file dht_proxy_client.h.

## ◆ listenKeepIdle() [1/2]

uint32_t dht::DhtProxyClient::listenKeepIdle | ( |  | ) |
| inline

Definition at line 302 of file dht_proxy_client.h.

## ◆ listenKeepIdle() [2/2]

void dht::DhtProxyClient::listenKeepIdle | ( | uint32_t | seconds | ) |
| inline

Definition at line 301 of file dht_proxy_client.h.

## ◆ periodic() [1/2]

time_point dht::DhtProxyClient::periodic | ( | const uint8_t * | ,
|  | size_t | ,
|  | SockAddr | ,
|  | const time_point & | now )
| overridevirtual

Implements dht::DhtInterface.

## ◆ periodic() [2/2]

time_point dht::DhtProxyClient::periodic | ( | const uint8_t * | buf,
|  | size_t | buflen,
|  | const sockaddr * | from,
|  | socklen_t | fromlen,
|  | const time_point & | now )
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 222 of file dht_proxy_client.h.

## ◆ pingNode()

void dht::DhtProxyClient::pingNode | ( | SockAddr | ,
|  | DoneCallbackSimple && | = {} )
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 264 of file dht_proxy_client.h.

## ◆ pushNotificationReceived()

PushNotificationResult dht::DhtProxyClient::pushNotificationReceived | ( | const std::map< std::string, std::string > & | notification | ) |
| overridevirtual

Call linked callback with a push notification

Parameters

  notification | to process

Implements dht::DhtInterface.

## ◆ put() [1/4]

void dht::DhtProxyClient::put | ( | const InfoHash & | key,
|  | const Sp< Value > & | v,
|  | DoneCallbackSimple | cb,
|  | time_point | created = time_point::max(),
|  | bool | permanent = false )
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 146 of file dht_proxy_client.h.

## ◆ put() [2/4]

void dht::DhtProxyClient::put | ( | const InfoHash & | key,
|  | Sp< Value > | ,
|  | DoneCallback | cb = nullptr,
|  | time_point | created = time_point::max(),
|  | bool | permanent = false )
| overridevirtual

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. NOTE: For now, created parameter is ignored.

Implements dht::DhtInterface.

## ◆ put() [3/4]

void dht::DhtProxyClient::put | ( | const InfoHash & | key,
|  | Value && | v,
|  | DoneCallback | cb = nullptr,
|  | time_point | created = time_point::max(),
|  | bool | permanent = false )
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 155 of file dht_proxy_client.h.

## ◆ put() [4/4]

void dht::DhtProxyClient::put | ( | const InfoHash & | key,
|  | Value && | v,
|  | DoneCallbackSimple | cb,
|  | time_point | created = time_point::max(),
|  | bool | permanent = false )
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 163 of file dht_proxy_client.h.

## ◆ query() [1/2]

virtual void dht::DhtProxyClient::query | ( | const InfoHash & | ,
|  | QueryCallback | ,
|  | DoneCallback | = {},
|  | Query && | = {} )
| inlineoverridevirtual

Similar to Dht::get, but sends a Query to filter data remotely.

Parameters

  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 238 of file dht_proxy_client.h.

## ◆ query() [2/2]

virtual void dht::DhtProxyClient::query | ( | const InfoHash & | key,
|  | QueryCallback | cb,
|  | DoneCallbackSimple | done_cb = {},
|  | Query && | q = {} )
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 243 of file dht_proxy_client.h.

## ◆ registerType()

virtual void dht::DhtProxyClient::registerType | ( | const ValueType & | type | ) |
| inlineoverridevirtual

Implements dht::DhtInterface.

Definition at line 266 of file dht_proxy_client.h.

## ◆ setLocalStorageLimit()

void dht::DhtProxyClient::setLocalStorageLimit | ( | size_t | limit | ) |
| inlineoverridevirtual

Set the in-memory storage limit in bytes for locally stored values

Implements dht::DhtInterface.

Definition at line 292 of file dht_proxy_client.h.

## ◆ setOnPublicAddressChanged()

void dht::DhtProxyClient::setOnPublicAddressChanged | ( | PublicAddressChangedCb | cb | ) |
| inlineoverridevirtual

Reimplemented from dht::DhtInterface.

Definition at line 76 of file dht_proxy_client.h.

## ◆ setPushNotificationPlatform()

virtual void dht::DhtProxyClient::setPushNotificationPlatform | ( | const std::string & | platform | ) |
| inlineoverridevirtual

Reimplemented from dht::DhtInterface.

Definition at line 61 of file dht_proxy_client.h.

## ◆ setPushNotificationToken()

virtual void dht::DhtProxyClient::setPushNotificationToken | ( | const std::string & | token | ) |
| overridevirtual

Reimplemented from dht::DhtInterface.

## ◆ setPushNotificationTopic()

virtual void dht::DhtProxyClient::setPushNotificationTopic | ( | const std::string & | topic | ) |
| inlineoverridevirtual

Reimplemented from dht::DhtInterface.

Definition at line 52 of file dht_proxy_client.h.

## ◆ setStorageLimit()

void dht::DhtProxyClient::setStorageLimit | ( | size_t | limit | ) |
| inlineoverridevirtual

Set the in-memory storage limit in bytes for remote values

Implements dht::DhtInterface.

Definition at line 290 of file dht_proxy_client.h.

## ◆ shutdown()

void dht::DhtProxyClient::shutdown | ( | ShutdownCallback | cb,
|  | bool | )
| overridevirtual

Performs final operations before quitting.

Implements dht::DhtInterface.

The documentation for this class was generated from the following file:

- /home/noptrix/ba/blackarch/packages/opendht-c/src/opendht/include/opendht/dht_proxy_client.h