Skip to content

Commit

Permalink
Basic WebRTC hooks and flag
Browse files Browse the repository at this point in the history
  • Loading branch information
MovByte committed Dec 30, 2022
1 parent 32676a7 commit 198e7e7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const flags = {
advancedScoping: false,
corsEmulation: false,
nestedWorkers: false,
wrtc: false,
};
const debug = {
url: false,
Expand Down
25 changes: 25 additions & 0 deletions hooks/wrtc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
if ($aero.config.flags.wrtc) {
const customIceServers = [];

RTCPeerConnection = new Proxy(RTCPeerConnection, {
construct(target, args) {
[config] = args;

if (config.iceServers && customIceServers.length > 0)
config.iceServers = customIceServers;

return new target(...args);
},
});

RTCPeerConnection.prototype.addIceCandidate = new Proxy(
RTCPeerConnection.prototype.addIceCandidate,
{
apply(target, that, args) {
[canidate] = args;

return Reflect.apply(...arguments);
},
}
);
}

0 comments on commit 198e7e7

Please sign in to comment.