Bug 1322659: log warnings and error for too many STUN/TURN servers. r=bwc

MozReview-Commit-ID: DrMqSjyfn6

--HG--
extra : rebase_source : 5cad28416d6b4fa5635c39b214de949d81d09f8e
This commit is contained in:
Nils Ohlmeier [:drno] 2016-12-08 22:38:17 -10:00
Родитель d91dbe2d3a
Коммит 028ebc6b4b
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -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");
}
});
});
},