mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 04:21:51 +00:00
dhtrunner: unpack value
This commit is contained in:
1 parent
73c53cc0ec
commit
d5ff0e2187
2 files changed
+6
-2
No files matched your search
@@ -86,7 +86,8 @@ public:
|
||||
get(hash, [=](const std::vector<std::shared_ptr<Value>>& vals) {
|
||||
for (const auto& v : vals) {
|
||||
try {
|
||||
auto msg = unpack<T>(v->data);
|
||||
T msg;
|
||||
msg.unpackValue(*v);
|
||||
if (not cb(std::move(msg)))
|
||||
return false;
|
||||
} catch (const std::exception&) {
|
||||
@@ -145,7 +146,8 @@ public:
|
||||
return listen(hash, [=](const std::vector<std::shared_ptr<Value>>& vals) {
|
||||
for (const auto& v : vals) {
|
||||
try {
|
||||
auto msg = unpack<T>(v->data);
|
||||
T msg;
|
||||
msg.unpackValue(*v);
|
||||
if (not cb(std::move(msg)))
|
||||
return false;
|
||||
} catch (const std::exception&) {
|
||||
|
||||
@@ -369,6 +369,8 @@ SecureDht::decrypt(const Value& v)
|
||||
auto msg = msgpack::unpack((const char*)decrypted.data(), decrypted.size());
|
||||
ret.msgpack_unpack_body(msg.get());
|
||||
|
||||
if (ret.recipient != getId())
|
||||
throw crypto::DecryptError("Recipient mismatch");
|
||||
if (not ret.owner.checkSignature(ret.getToSign(), ret.signature))
|
||||
throw crypto::DecryptError("Signature mismatch");
|
||||
|
||||
|
||||
Reference in new issue
Block a user