From 9b67cb15026e69757792f65e9267dd00bd4becd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bazyli=20Brzo=CC=81ska?= Date: Tue, 16 Feb 2016 00:02:25 +0100 Subject: [PATCH] wrap addrToIPPort in try/catch it was throwing an error when addr was not parsable --- lib/torrent.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/torrent.js b/lib/torrent.js index 677d546f..f574dfea 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