Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ulixee
GitHub Repository: ulixee/secret-agent
Path: blob/main/plugins/default-browser-emulator/injected-scripts/webrtc.ts
1029 views
1
const maskLocalIp = args.localIp;
2
const replacementIp = args.proxyIp;
3
4
if ('RTCIceCandidate' in self && RTCIceCandidate.prototype) {
5
proxyGetter(RTCIceCandidate.prototype, 'candidate', function () {
6
const result = ReflectCached.apply(...arguments);
7
return result.replace(maskLocalIp, replacementIp);
8
});
9
if ('address' in RTCIceCandidate.prototype) {
10
// @ts-ignore
11
proxyGetter(RTCIceCandidate.prototype, 'address', function () {
12
const result: string = ReflectCached.apply(...arguments);
13
return result.replace(maskLocalIp, replacementIp);
14
});
15
}
16
proxyFunction(RTCIceCandidate.prototype, 'toJSON', function () {
17
const json = ReflectCached.apply(...arguments);
18
if ('address' in json) json.address = json.address.replace(maskLocalIp, replacementIp);
19
if ('candidate' in json) json.candidate = json.candidate.replace(maskLocalIp, replacementIp);
20
return json;
21
});
22
}
23
24
if ('RTCSessionDescription' in self && RTCSessionDescription.prototype) {
25
proxyGetter(RTCSessionDescription.prototype, 'sdp', function () {
26
let result = ReflectCached.apply(...arguments);
27
while (result.indexOf(maskLocalIp) !== -1) {
28
result = result.replace(maskLocalIp, replacementIp);
29
}
30
return result;
31
});
32
}
33
34