From 9a6e8546091837fe0b62af91ed89f1974984cc9b Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sun, 3 May 2015 16:53:37 -0700 Subject: [PATCH] Limit number of WebRTC offers to only 5 --- lib/common.js | 2 +- lib/websocket-tracker.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/common.js b/lib/common.js index 3b255e4..a6f191a 100644 --- a/lib/common.js +++ b/lib/common.js @@ -6,7 +6,7 @@ var extend = require('xtend/mutable') exports.DEFAULT_ANNOUNCE_INTERVAL = 30 * 60 * 1000 // 30 minutes -exports.DEFAULT_ANNOUNCE_PEERS = process.browser ? 5 : 50 +exports.DEFAULT_ANNOUNCE_PEERS = 50 exports.MAX_ANNOUNCE_PEERS = 82 exports.binaryToHex = function (str) { diff --git a/lib/websocket-tracker.js b/lib/websocket-tracker.js index 874490f..d433c0a 100644 --- a/lib/websocket-tracker.js +++ b/lib/websocket-tracker.js @@ -59,6 +59,10 @@ WebSocketTracker.prototype.announce = function (opts) { opts.info_hash = self.client._infoHash.toString('binary') opts.peer_id = self.client._peerId.toString('binary') + // Limit number of offers to only 5 (temporarily) + // TODO: remove this when we cleanup old RTCPeerConnections cleanly + if (opts.numWant > 5) opts.numWant = 5 + self._generateOffers(opts.numWant, function (offers) { opts.offers = offers