From 4ddc4a34e56b2dafb288004f69d0b1740d170daf Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sat, 23 May 2015 06:46:57 +0200 Subject: fix crash on 'port' message from web peer --- lib/torrent.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/torrent.js b/lib/torrent.js index 625b32f..acb4c3e 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -526,9 +526,12 @@ Torrent.prototype._onWire = function (wire, addr) { // When peer sends PORT, add them to the routing table wire.on('port', function (port) { - debug('port: %s (from %s)', port, addr) - var parts = addrToIPPort(addr) - if (self.client.dht) self.client.dht.addNode(parts[0] + ':' + port) + if (!wire.remoteAddress) { + debug('ignoring port from peer with no address') + return + } + debug('port: %s (from %s)', port, wire.remoteAddress + ':' + wire.remotePort) + if (self.client.dht) self.client.dht.addNode(wire.remoteAddress + ':' + port) }) wire.on('timeout', function () { -- cgit v1.2.3