diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2015-01-04 04:03:14 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2015-01-04 04:03:14 +0300 |
commit | ec36d6272fd7bf3fc5f22be04f462240c18a044e (patch) | |
tree | b8a64d90d263caafc9eca81e8b12ee09cc578dc4 /lib | |
parent | 751702df9564980bb8a2b8cd8334a43c56b010f1 (diff) |
add blocklist tests
Diffstat (limited to 'lib')
-rw-r--r-- | lib/torrent.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/torrent.js b/lib/torrent.js index 9f6edde..bf110f9 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -326,19 +326,21 @@ Torrent.prototype.destroy = function (cb) { /** * Add a peer to the swarm * @param {string|SimplePeer} peer + * @return {boolean} true if peer was added, false if peer was blocked */ Torrent.prototype.addPeer = function (peer) { var self = this - // TODO: extract IP address from peer object and check blocklist if (typeof peer === 'string' && self.client.blocked && self.client.blocked.contains(addrToIPPort(peer)[0])) { self.numBlockedPeers += 1 self.emit('blocked-peer', peer) + return false } else { self.emit('peer', peer) self.swarm.addPeer(peer) + return true } } |