diff options
author | Bazyli Brzóska <bazyli.brzoska@gmail.com> | 2016-02-16 02:02:25 +0300 |
---|---|---|
committer | Bazyli Brzóska <bazyli.brzoska@gmail.com> | 2016-02-16 19:40:09 +0300 |
commit | 9b67cb15026e69757792f65e9267dd00bd4becd6 (patch) | |
tree | a45b0e7982fd937a6734d7003e8c736143e386ad /lib | |
parent | 436eea4f423c59ab931d390248409330ff610fdc (diff) |
wrap addrToIPPort in try/catch
it was throwing an error when addr was not parsable
Diffstat (limited to 'lib')
-rw-r--r-- | lib/torrent.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/torrent.js b/lib/torrent.js index 677d546..f574dfe 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -463,7 +463,13 @@ Torrent.prototype.addPeer = function (peer) { if (self.client.blocked) { var addr = typeof peer === 'string' ? peer : peer.remoteAddress - if (addr && self.client.blocked.contains(addrToIPPort(addr)[0])) { + var parts + if (addr) { + try { + parts = addrToIPPort(addr) + } catch (e) { return false } + } + if (addr && self.client.blocked.contains(parts[0])) { self.numBlockedPeers += 1 self.emit('blockedPeer', peer) return false |