Path: blob/main/plugins/default-browser-emulator/injected-scripts/webrtc.ts
1029 views
const maskLocalIp = args.localIp;1const replacementIp = args.proxyIp;23if ('RTCIceCandidate' in self && RTCIceCandidate.prototype) {4proxyGetter(RTCIceCandidate.prototype, 'candidate', function () {5const result = ReflectCached.apply(...arguments);6return result.replace(maskLocalIp, replacementIp);7});8if ('address' in RTCIceCandidate.prototype) {9// @ts-ignore10proxyGetter(RTCIceCandidate.prototype, 'address', function () {11const result: string = ReflectCached.apply(...arguments);12return result.replace(maskLocalIp, replacementIp);13});14}15proxyFunction(RTCIceCandidate.prototype, 'toJSON', function () {16const json = ReflectCached.apply(...arguments);17if ('address' in json) json.address = json.address.replace(maskLocalIp, replacementIp);18if ('candidate' in json) json.candidate = json.candidate.replace(maskLocalIp, replacementIp);19return json;20});21}2223if ('RTCSessionDescription' in self && RTCSessionDescription.prototype) {24proxyGetter(RTCSessionDescription.prototype, 'sdp', function () {25let result = ReflectCached.apply(...arguments);26while (result.indexOf(maskLocalIp) !== -1) {27result = result.replace(maskLocalIp, replacementIp);28}29return result;30});31}323334