Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
b3f96830
Commit
b3f96830
authored
2 years ago
by
Sébastien Blin
Committed by
Adrien Béraud
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
securedht: avoid to update cache if not necessary
parent
6d1819ac
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/opendht/value.h
+6
-0
6 additions, 0 deletions
include/opendht/value.h
src/securedht.cpp
+5
-2
5 additions, 2 deletions
src/securedht.cpp
with
11 additions
and
2 deletions
include/opendht/value.h
+
6
−
0
View file @
b3f96830
...
...
@@ -625,6 +625,12 @@ struct OPENDHT_PUBLIC Value
*/
unsigned
priority
{
0
};
inline
bool
isSignatureChecked
()
const
{
return
signatureChecked
;
}
inline
bool
isDecrypted
()
const
{
return
decrypted
;
}
bool
checkSignature
();
Sp
<
Value
>
decrypt
(
const
crypto
::
PrivateKey
&
key
);
...
...
This diff is collapsed.
Click to expand it.
src/securedht.cpp
+
5
−
2
View file @
b3f96830
...
...
@@ -238,8 +238,10 @@ SecureDht::checkValue(const Sp<Value>& v)
return
{};
}
try
{
auto
isDecrypted
=
v
->
isDecrypted
();
if
(
auto
decrypted_val
=
v
->
decrypt
(
*
key_
))
{
if
(
decrypted_val
->
owner
)
auto
cacheValue
=
not
isDecrypted
and
decrypted_val
->
owner
;
if
(
cacheValue
)
nodesPubKeys_
[
decrypted_val
->
owner
->
getId
()]
=
decrypted_val
->
owner
;
return
decrypted_val
;
}
...
...
@@ -250,8 +252,9 @@ SecureDht::checkValue(const Sp<Value>& v)
}
// Check signed values
else
if
(
v
->
isSigned
())
{
auto
cacheValue
=
not
v
->
isSignatureChecked
()
and
enableCache_
and
v
->
owner
;
if
(
v
->
checkSignature
())
{
if
(
enableCache_
and
v
->
owner
)
if
(
cacheValue
)
nodesPubKeys_
[
v
->
owner
->
getId
()]
=
v
->
owner
;
return
v
;
}
else
if
(
logger_
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment