diff --git a/index.js b/index.js index 3c22f1d..9e770f4 100644 --- a/index.js +++ b/index.js @@ -51,7 +51,7 @@ class LSD extends EventEmitter { const parsedAnnounce = this._parseAnnounce(msg.toString()) - if (parsedAnnounce == null) return + if (parsedAnnounce === null) return if (parsedAnnounce.cookie === this.cookie) return parsedAnnounce.infoHash.forEach(infoHash => { @@ -70,7 +70,7 @@ class LSD extends EventEmitter { _parseAnnounce (announce) { const checkHost = (host) => { - return /^(239.192.152.143|\[ff15::efc0:988f\]):6771$/.test(host) + return /^(239.192.152.143|\[ff15::efc0:988f]):6771$/.test(host) } const checkPort = (port) => { diff --git a/test/basic.js b/test/basic.js index d6f65f3..1faf919 100644 --- a/test/basic.js +++ b/test/basic.js @@ -53,12 +53,12 @@ test('should emit peer when receiving a valid announce', t => { }) lsd.on('peer', (peerAddress, infoHash) => { - const ip = Object.values(os.networkInterfaces()) + const addresses = Object.values(os.networkInterfaces()) .flatMap(i => i) .filter(i => !i.internal && i.family === 'IPv4') - .reduce((acc, cur) => cur.address, '') + .map(i => `${i.address}:${port}`) - t.equal(peerAddress, `${ip}:${port}`) + t.ok(addresses.includes(peerAddress)) t.equal(infoHash, infoHash) lsd.destroy(() => t.end())