Does anyone have an idea How to mock webrtc local and public ip?
I can see in some softwares like multilogin, they are to let you set any value for the local and public ip.
so is there any way to do the same by Javascript or playwright or any other browser automation control on c#
thank you
so far we have tried to use some sample we found in StackOverflow in javascript as below but not working:
function wrapPeerConnectionEvent(window, eventNameToWrap, wrapper) {if (!window.RTCPeerConnection) {return;}const proto = window.RTCPeerConnection.prototype;const nativeAddEventListener = proto.addEventListener;proto.addEventListener = function(nativeEventName, cb) {if (nativeEventName !== eventNameToWrap) {return nativeAddEventListener.apply(this, arguments);}const wrappedCallback = (e) => {const modifiedEvent = wrapper(e);if (modifiedEvent) {cb(modifiedEvent);}};this._eventMap = this._eventMap || {};this._eventMap[cb] = wrappedCallback;return nativeAddEventListener.apply(this, [nativeEventName,wrappedCallback]);};
const nativeRemoveEventListener = proto.removeEventListener;proto.removeEventListener = function(nativeEventName, cb) {if (nativeEventName !== eventNameToWrap || !this._eventMap|| !this._eventMap[cb]) {return nativeRemoveEventListener.apply(this, arguments);}const unwrappedCb = this._eventMap[cb];delete this._eventMap[cb];return nativeRemoveEventListener.apply(this, [nativeEventName,unwrappedCb]);};
Object.defineProperty(proto, 'on' + eventNameToWrap, {get() {return this['_on' + eventNameToWrap];},set(cb) {if (this['_on' + eventNameToWrap]) {this.removeEventListener(eventNameToWrap,this['_on' + eventNameToWrap]);delete this['_on' + eventNameToWrap];}if (cb) {this.addEventListener(eventNameToWrap,this['_on' + eventNameToWrap] = cb);}},enumerable: true,configurable: true});}
wrapPeerConnectionEvent(window, 'icecandidate', (e) => {
//console.log(e);if (e.candidate) {
const parts = e.candidate.candidate.split(' ');
parts[4] = '127.0.0.1'; // replace the local ip with 127.0.0.1
parts[9] = '65.65.0.0'e.candidate.candidate = parts.join(' ');
console.log(parts);
console.log(e.candidate.candidate);}return e;})