open-chat-labs / open-chat

This is the main repository for the OpenChat application which runs on the Internet Computer
https://oc.app
GNU Affero General Public License v3.0
168 stars 51 forks source link

Enhance peerjs server #3576

Open julianjelfs opened 1 year ago

julianjelfs commented 1 year ago

There are a few potential problems with our peerjs signalling server.

1) shared service controlled by someone else - this is a vulnerability if not a current problem 2) The server maps a userId to at most one connection. This does not cover the common case where a user has more than one device open. 3) Signalling messages are not authenticated in any way which means that in principle it would be possible to fake a webrtc message if you know another user's userId (which is not secret information).

There is potential to fix all three of these problems by forking the peerjs server and modifying it and then hosting it ourselves.

Since this implies multiple webrtc connections to a single peer (on multiple devices) this would also require changes to peerjs client. At which point it might be simpler to switch to simple-peer and use a completely custom signalling server that meets our requirements exactly.

priyankgandhi0 commented 1 year ago

local stream microphone not working while share screen + system audio shared in HTML JS

Screenshot 2023-07-19 182435

Here is code HTML + JS ✅

 function startScreenShare() {
        if (screenSharing) {
            stopScreenSharing()
        }
        navigator.mediaDevices.getDisplayMedia(
            { video: { mediaSource: "screen" }, audio: true }
        ).then((stream) => {
            setScreenSharingStream(stream);

            screenStream = stream;
            let videoTrack = screenStream.getAudioTracks()[0];
            videoTrack.onended = () => {
                stopScreenSharing()
            }
            if (peer) {
                let sender = currentPeer.peerConnection.getSenders().find(function (s) {
                    return s.track.kind == videoTrack.kind;
                })
                sender.replaceTrack(videoTrack)
                screenSharing = true
            }
            console.log(screenStream)
        })
    }

We have tried to share screen audio. When sharing the screen, microphone and screen-sharing audio do not work together. Mic does not work when system audio is on. System audio does not working if end mic is on. please explain me what is the about issue.