File size: 879 Bytes
3d7d9b5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | (function() {
'use strict';
// Prevent WebRTC from leaking local IP addresses
const OriginalRTC = window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection;
if (!OriginalRTC) return;
window.RTCPeerConnection = function(config, constraints) {
if (config && config.iceServers) {
config.iceServers = config.iceServers.filter(server => {
const urls = Array.isArray(server.urls) ? server.urls : [server.urls || server.url];
return !urls.some(u => u && u.toString().startsWith('stun:'));
});
}
return new OriginalRTC(config, constraints);
};
window.RTCPeerConnection.prototype = OriginalRTC.prototype;
Object.setPrototypeOf(window.RTCPeerConnection, OriginalRTC);
if (window.webkitRTCPeerConnection) {
window.webkitRTCPeerConnection = window.RTCPeerConnection;
}
})();
|