From 8f0d5a7f283567ff636c6690093d8d413d2bd496 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Mon, 28 Mar 2016 15:32:38 -0700 Subject: [PATCH] Only add new ut_pex peers when we're not seeding Otherwise, we get into a loop of connect, get pex messages, disconnect because they don't have pieces we need (because we're seeding), try connecting to the pex peers, etc. etc. --- lib/torrent.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/torrent.js b/lib/torrent.js index 4ccd26e5..ed47e5b0 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -654,6 +654,8 @@ Torrent.prototype._onWire = function (wire, addr) { wire.use(ut_pex()) wire.ut_pex.on('peer', function (peer) { + // Only add potential new peers when we're not seeding + if (self.done) return self._debug('ut_pex: got peer: %s (from %s)', peer, addr) self.addPeer(peer) }) @@ -669,7 +671,7 @@ Torrent.prototype._onWire = function (wire, addr) { }) } - // Hook to allow user-defined `bittorrent-protocol extensions + // Hook to allow user-defined `bittorrent-protocol` extensions // More info: https://github.com/feross/bittorrent-protocol#extension-api self.emit('wire', wire, addr)