Bug 1322659: log warnings and error for too many STUN/TURN servers. r=bwc
MozReview-Commit-ID: DrMqSjyfn6
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -589,16 +589,18 @@ RTCPeerConnection.prototype = {
try {
return ios.newURI(uriStr, null, null);
} catch (e if (e.result == Cr.NS_ERROR_MALFORMED_URI)) {
throw new this._win.DOMException(msg + " - malformed URI: " + uriStr,
"SyntaxError");
}
};
+ var stunServers = 0;
+
rtcConfig.iceServers.forEach(server => {
if (!server.urls) {
throw new this._win.DOMException(msg + " - missing urls", "InvalidAccessError");
}
server.urls.forEach(urlStr => {
let url = nicerNewURI(urlStr);
if (url.scheme in { turn:1, turns:1 }) {
if (server.username == undefined) {
@@ -611,27 +613,34 @@ RTCPeerConnection.prototype = {
}
if (server.credentialType != "password") {
this.logWarning("RTCConfiguration TURN credentialType \""+
server.credentialType +
"\" is not yet implemented. Treating as password."+
" 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,
"SyntaxError");
}
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");
+ }
});
});
},
// Ideally, this should be of the form _checkState(state),
// where the state is taken from an enumeration containing
// the valid peer connection states defined in the WebRTC
// spec. See Bug 831756.