diff options
Diffstat (limited to 'lib/torrent.js')
-rw-r--r-- | lib/torrent.js | 9 |
1 files 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 () { |