diff --git a/index.js b/index.js index 7b63daa..c071430 100644 --- a/index.js +++ b/index.js @@ -343,11 +343,15 @@ class DHT extends EventEmitter { } // ask the user to handle it or reply back with a bad command - if (this.emit('request', req) === false) { + if (this.onrequest(req) === false) { req.sendReply(BAD_COMMAND, null, false, true) } } + onrequest (req) { + return this.emit('request', req) + } + _onresponse (res, external) { this._addNodeFromNetwork(!external, res.from, res.to) }