Browse Source

fix some crashes

v4
Mathias Buus 4 years ago
parent
commit
838e42ee74
  1. 9
      index.js
  2. 1
      lib/io.js

9
index.js

@ -145,12 +145,19 @@ class DHT extends EventEmitter {
if (!cmd) return reply(UNSUPPORTED_COMMAND)
let value = null
try {
value = cmd.inputEncoding.decode(message.value)
} catch (_) {
return
}
const query = {
type,
command: message.command,
node: peer,
target: message.target,
value: cmd.inputEncoding.decode(message.value)
value
}
if (type === IO.UPDATE) cmd.update(query, reply)

1
lib/io.js

@ -101,6 +101,7 @@ class IO {
}
_onmessage (buf, rinfo) {
if (!rinfo.port) return
const message = decodeMessage(buf)
if (!message) return
if (message.id && message.id.length !== 32) return

Loading…
Cancel
Save