Skip to content

Commit

Permalink
securedht: fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
aberaud committed Apr 15, 2021
1 parent 55c5953 commit 578ed31
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
4 changes: 1 addition & 3 deletions include/opendht/securedht.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class OPENDHT_PUBLIC SecureDht final : public DhtInterface {
* id: the identity to use for the crypto layer and to compute
* our own hash on the Dht.
*/
SecureDht(std::unique_ptr<DhtInterface> dht, Config config, const IdentityAnnouncedCb& iacb = {});
SecureDht(std::unique_ptr<DhtInterface> dht, Config config, IdentityAnnouncedCb iacb = {});

virtual ~SecureDht();

Expand Down Expand Up @@ -348,8 +348,6 @@ class OPENDHT_PUBLIC SecureDht final : public DhtInterface {
ValueCallback getCallbackFilter(const ValueCallback&, Value::Filter&&);
GetCallback getCallbackFilter(const GetCallback&, Value::Filter&&);

IdentityAnnouncedCb iacb_ {};

Sp<crypto::PrivateKey> key_ {};
Sp<crypto::Certificate> certificate_ {};

Expand Down
15 changes: 7 additions & 8 deletions src/securedht.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ extern "C" {

namespace dht {

SecureDht::SecureDht(std::unique_ptr<DhtInterface> dht, SecureDht::Config conf, const IdentityAnnouncedCb& iacb)
: dht_(std::move(dht)), key_(conf.id.first), certificate_(conf.id.second), enableCache_(conf.cert_cache_all), iacb_(iacb)
SecureDht::SecureDht(std::unique_ptr<DhtInterface> dht, SecureDht::Config conf, IdentityAnnouncedCb iacb)
: dht_(std::move(dht)), key_(conf.id.first), certificate_(conf.id.second), enableCache_(conf.cert_cache_all)
{
if (!dht_) return;
for (const auto& type : DEFAULT_TYPES)
Expand All @@ -53,16 +53,15 @@ SecureDht::SecureDht(std::unique_ptr<DhtInterface> dht, SecureDht::Config conf,
if (key_ and certId != key_->getPublicKey().getId())
throw DhtException("SecureDht: provided certificate doesn't match private key.");

dht_->addOnConnectedCallback([&]{
dht_->addOnConnectedCallback([&, cb=std::move(iacb)]{
dht_->put(certId, Value {
CERTIFICATE_TYPE,
*certificate_,
1
}, [this, certId](bool ok) {
if (iacb_) iacb_(ok);
if (ok)
if (logger_)
logger_->d(certId, "SecureDht: public key announced successfully");
}, [this, certId, cb=std::move(cb)](bool ok) {
if (cb) cb(ok);
if (logger_)
logger_->d(certId, "SecureDht: certificate announcement %s", ok ? "succeeded" : "failed");
}, {}, true);
});
}
Expand Down

0 comments on commit 578ed31

Please sign in to comment.