*Change logic to abort if the signature fails

This commit is contained in:
Derrick Hammer 2022-12-07 02:29:20 -05:00
parent d65d33aa18
commit 58252606a6
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 5 additions and 3 deletions

View File

@ -319,11 +319,13 @@ export default class DHTCache extends EventEmitter {
let bufId = b4a.from(toId as Uint8Array) as Buffer;
if (signature && crypto.verify(bufData, signature, id)) {
this._addEntityConnection(id, bufId as Buffer);
this._setEntity(bufId as Buffer, { heartbeat: Date.now() });
if (!(signature && crypto.verify(bufData, signature, id))) {
return;
}
this._addEntityConnection(id, bufId as Buffer);
this._setEntity(bufId as Buffer, { heartbeat: Date.now() });
this.log.debug(
`Bootstrap response received from ${bufId.toString("hex")}`
);