diff options
Diffstat (limited to 'lib/torrent.js')
-rw-r--r-- | lib/torrent.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/torrent.js b/lib/torrent.js index c374741..0a1a03a 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -456,8 +456,12 @@ Torrent.prototype.addPeer = function (peer) { if (self.destroyed) throw new Error('torrent is destroyed') function addPeer () { - self.swarm.addPeer(peer) - self.emit('peer', peer) + var wasAdded = self.swarm.addPeer(peer) + if (wasAdded) { + self.emit('peer', peer) + } else { + self.emit('invalidPeer', peer) + } } if (self.client.blocked) { @@ -467,6 +471,7 @@ Torrent.prototype.addPeer = function (peer) { try { parts = addrToIPPort(peer) } catch (e) { + self.emit('invalidPeer', peer) return false } host = parts[0] |