diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2015-05-23 07:46:57 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2015-05-23 07:46:57 +0300 |
commit | 4ddc4a34e56b2dafb288004f69d0b1740d170daf (patch) | |
tree | 638d52cf0ac556c500fa1b7525d75b0c101a5b62 | |
parent | 40c1095199ad76ce54cda002b95b4a36cba18f17 (diff) |
fix crash on 'port' message from web peer
-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 () { |