ignore misbehaving leeches.

This commit is contained in:
Christopher Jeffrey 2016-05-24 16:24:03 -07:00
parent c5fc69ee93
commit 1de2df0c3a
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -429,10 +429,22 @@ Pool.prototype.listen = function listen(callback) {
}
this.server.on('connection', function(socket) {
var hostname;
if (self.peers.leeches.length >= self.maxLeeches) {
hostname = utils.hostname(socket.remoteAddress, socket.remotePort);
bcoin.debug('Ignoring leech: too many leeches (%s).', hostname);
socket.destroy();
return;
}
if (self.isMisbehaving(socket.remoteAddress)) {
hostname = utils.hostname(socket.remoteAddress, socket.remotePort);
bcoin.debug('Ignoring misbehaving leech (%s).', hostname);
socket.destroy();
return;
}
self._addLeech(socket);
});