Skip to content

Commit

Permalink
webrtc: reduce preference of turn
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Nov 27, 2023
1 parent 2d2c5c4 commit 33e2291
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions plugins/webrtc/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/webrtc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scrypted/webrtc",
"version": "0.1.81",
"version": "0.2.1",
"scripts": {
"scrypted-setup-project": "scrypted-setup-project",
"prescrypted-setup-project": "scrypted-package-json",
Expand Down
24 changes: 14 additions & 10 deletions plugins/webrtc/src/werift-signaling-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,21 @@ export class WeriftSignalingSession implements RTCSignalingSession {
async addIceCandidate(candidate: RTCIceCandidateInit) {
this.remoteHasV6 ||= isV6Only(candidate.candidate?.split(' ')?.[4]);

// todo: fix this in werift or verify it still occurs at later point
// werift seems to choose whatever candidate pair results in the fastest connection.
// this makes it sometimes choose the STUN or TURN candidate even when
// on the local network.
if (candidate.candidate?.includes('relay')) {
if (this.remoteHasV6 && !this.localHasV6) {
this.console.log('Possible mobile network IPv6to4 translation detected.');
}
else {
await sleep(500);
}
// note: this code is done, werift was modified to ban bad ips like 6to4 relays from tmobile.

// todo: fix this in werift or verify it still occurs at later point
// werift seems to choose whatever candidate pair results in the fastest connection.
// this makes it sometimes choose the STUN or TURN candidate even when
// on the local network.
// if (this.remoteHasV6 && !this.localHasV6) {
// this.console.log('Possible mobile network IPv6to4 translation detected.');
// }
// else {
// await sleep(500);
// }

await sleep(500);
}
else if (candidate.candidate?.includes('srflx')) {
await sleep(250);
Expand Down

0 comments on commit 33e2291

Please sign in to comment.