From 028ebc6b4b54a5ccf7a3f65ae47af70d073fc052 Mon Sep 17 00:00:00 2001 From: "Nils Ohlmeier [:drno]" Date: Thu, 8 Dec 2016 22:38:17 -1000 Subject: [PATCH] Bug 1322659: log warnings and error for too many STUN/TURN servers. r=bwc MozReview-Commit-ID: DrMqSjyfn6 --HG-- extra : rebase_source : 5cad28416d6b4fa5635c39b214de949d81d09f8e --- dom/media/PeerConnection.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dom/media/PeerConnection.js b/dom/media/PeerConnection.js index 378c192a86ab..70ea65a80bc5 100644 --- a/dom/media/PeerConnection.js +++ b/dom/media/PeerConnection.js @@ -594,6 +594,8 @@ RTCPeerConnection.prototype = { } }; + var stunServers = 0; + rtcConfig.iceServers.forEach(server => { if (!server.urls) { throw new this._win.DOMException(msg + " - missing urls", "InvalidAccessError"); @@ -616,9 +618,11 @@ RTCPeerConnection.prototype = { " https://bugzil.la/1247616"); } this._hasTurnServer = true; + stunServers += 1; } else if (url.scheme in { stun:1, stuns:1 }) { this._hasStunServer = true; + stunServers += 1; } else if (!(url.scheme in { stun:1, stuns:1 })) { throw new this._win.DOMException(msg + " - improper scheme: " + url.scheme, @@ -627,6 +631,11 @@ RTCPeerConnection.prototype = { if (url.scheme in { stuns:1, turns:1 }) { this.logWarning(url.scheme.toUpperCase() + " is not yet supported."); } + if (stunServers >= 5) { + this.logError("Using five or more STUN/TURN servers causes problems"); + } else if (stunServers > 2) { + this.logWarning("Using more than two STUN/TURN servers slows down discovery"); + } }); }); },