diff --git a/include/dhtcpp/dht.h b/include/dhtcpp/dht.h index ecc3d2eb..5986e7dd 100644 --- a/include/dhtcpp/dht.h +++ b/include/dhtcpp/dht.h @@ -247,14 +247,14 @@ private: }; struct Bucket { - Bucket() {} + Bucket() : cached() {} Bucket(sa_family_t af, const InfoHash& f = {}, time_t t = 0) - : af(af), first(f), time(t) {} + : af(af), first(f), time(t), cached() {} sa_family_t af {0}; InfoHash first {}; time_t time {0}; /* time of last reply in this bucket */ std::list nodes {}; - sockaddr_storage cached {}; /* the address of a likely candidate */ + sockaddr_storage cached; /* the address of a likely candidate */ socklen_t cachedlen {0}; /** Return a random node in a bucket. */ @@ -290,8 +290,8 @@ private: }; struct SearchNode { - SearchNode() {} - SearchNode(const InfoHash& id) : id(id) {} + SearchNode() : ss() {} + SearchNode(const InfoHash& id) : id(id), ss() {} struct AnnounceStatus { time_t request_time; /* the time of the last unanswered announce request */ @@ -316,7 +316,7 @@ private: } InfoHash id {}; - sockaddr_storage ss {}; + sockaddr_storage ss; socklen_t sslen {0}; time_t request_time {0}; /* the time of the last unanswered request */ time_t reply_time {0}; /* the time of the last reply with a token */ @@ -470,7 +470,7 @@ private: sockaddr_storage blacklist[BLACKLISTED_MAX] {}; unsigned next_blacklisted = 0; - struct timeval now {}; + struct timeval now {0, 0}; time_t mybucket_grow_time {0}, mybucket6_grow_time {0}; time_t expire_stuff_time {0}; time_t rate_limit_time {0}; diff --git a/include/dhtcpp/securedht.h b/include/dhtcpp/securedht.h index d44dee06..b435a029 100644 --- a/include/dhtcpp/securedht.h +++ b/include/dhtcpp/securedht.h @@ -135,7 +135,8 @@ private: std::map> nodesCertificates_ {}; }; -const ValueType CERTIFICATE_TYPE = {8, "Certificate", 60 * 60 * 24 * 7, +const ValueType CERTIFICATE_TYPE = { + 8, "Certificate", 60 * 60 * 24 * 7, // A certificate can only be stored at it's public key ID. [](InfoHash id, std::shared_ptr& v, InfoHash, const sockaddr*, socklen_t) { try { @@ -145,11 +146,9 @@ const ValueType CERTIFICATE_TYPE = {8, "Certificate", 60 * 60 * 24 * 7, } catch (const std::exception& e) {} return false; }, - [](InfoHash id, const std::shared_ptr& o, std::shared_ptr& n, InfoHash, const sockaddr*, socklen_t) { + [](InfoHash, const std::shared_ptr& o, std::shared_ptr& n, InfoHash, const sockaddr*, socklen_t) { try { - crypto::Certificate crt_old(o->data); - crypto::Certificate crt_new(n->data); - return crt_old.getPublicKey().getId() == crt_new.getPublicKey().getId(); + return crypto::Certificate(o->data).getPublicKey().getId() == crypto::Certificate(n->data).getPublicKey().getId(); } catch (const std::exception& e) {} return false; }