fix remoteAddress == undefined problem.

This commit is contained in:
Christopher Jeffrey 2016-05-25 11:46:39 -07:00
parent 4aca23e7e8
commit 6ab0b2636c
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

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