diff --git a/app/src/Room.js b/app/src/Room.js index 6a271abe..96b255f9 100644 --- a/app/src/Room.js +++ b/app/src/Room.js @@ -31,6 +31,7 @@ module.exports = class Room { this.survey = config.survey; this.redirect = config.redirect; this.peers = new Map(); + this.bannedPeers = []; this.router = null; this.createTheRouter(); } @@ -325,6 +326,24 @@ module.exports = class Room { this.peers.get(socket_id).closeProducer(producer_id); } + // #################################################### + // HANDLE BANNED PEERS + // #################################################### + + addBannedPeer(uuid) { + if (!this.bannedPeers.includes(uuid)) { + this.bannedPeers.push(uuid); + log.debug('Added to the banned list', { + uuid: uuid, + banned: this.bannedPeers, + }); + } + } + + isBanned(uuid) { + return this.bannedPeers.includes(uuid); + } + // #################################################### // ROOM STATUS // #################################################### diff --git a/app/src/Server.js b/app/src/Server.js index d8f47e27..775a037e 100644 --- a/app/src/Server.js +++ b/app/src/Server.js @@ -40,7 +40,7 @@ dependencies: { * @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon * @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970 * @author Miroslav Pejic - miroslav.pejic.85@gmail.com - * @version 1.3.57 + * @version 1.3.58 * */ @@ -782,6 +782,8 @@ function startServer() { const room = roomList.get(socket.room_id); + if (data.action === 'eject') room.addBannedPeer(data.to_peer_uuid); + data.broadcast ? room.broadCast(data.peer_id, 'peerAction', data) : room.sendTo(data.peer_id, 'peerAction', data); @@ -969,8 +971,7 @@ function startServer() { // User Auth required, we check if peer valid if (hostCfg.user_auth) { - const peer_username = data.peer_info.peer_username; - const peer_password = data.peer_info.peer_password; + const { peer_username, peer_password } = data.peer_info; const isPeerValid = isAuthPeer(peer_username, peer_password); @@ -989,6 +990,24 @@ function startServer() { const room = roomList.get(socket.room_id); + // check if banned... + const peerUUID = data.peer_info.peer_uuid; + if (room.isBanned(peerUUID)) { + const { peer_name, peer_uuid, os_name, os_version, browser_name, browser_version } = data.peer_info; + log.info('[Join] - peer is banned!', { + room_id: data.room_id, + peer: { + name: peer_name, + uuid: peer_uuid, + os_name: os_name, + os_version: os_version, + browser_name: browser_name, + browser_version: browser_version, + }, + }); + return cb('isBanned'); + } + room.addPeer(new Peer(socket.id, data)); const activeRooms = getActiveRooms(); diff --git a/package.json b/package.json index f4824673..e321ff57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mirotalksfu", - "version": "1.3.57", + "version": "1.3.58", "description": "WebRTC SFU browser-based video calls", "main": "Server.js", "scripts": { @@ -48,7 +48,7 @@ "crypto-js": "4.2.0", "express": "4.18.2", "httpolyglot": "0.1.2", - "mediasoup": "3.13.16", + "mediasoup": "3.13.17", "mediasoup-client": "3.7.2", "ngrok": "^4.3.3", "openai": "^4.26.0", diff --git a/public/js/Room.js b/public/js/Room.js index 5527e6a2..657d5362 100644 --- a/public/js/Room.js +++ b/public/js/Room.js @@ -11,7 +11,7 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h * @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon * @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970 * @author Miroslav Pejic - miroslav.pejic.85@gmail.com - * @version 1.3.57 + * @version 1.3.58 * */ @@ -3091,6 +3091,14 @@ function wbDrawing(status) { // HANDLE PARTICIPANTS // #################################################### +async function getRemotePeerInfo(peer_id) { + const peers = await getRoomPeers(); + for (let peer of Array.from(peers.keys()).filter((id) => id === peer_id)) { + return peers.get(peer).peer_info; + } + return false; +} + async function getRoomPeers() { let room_info = await rc.getRoomInfo(); return new Map(JSON.parse(room_info.peers)); diff --git a/public/js/RoomClient.js b/public/js/RoomClient.js index 331988a0..330adc54 100644 --- a/public/js/RoomClient.js +++ b/public/js/RoomClient.js @@ -9,7 +9,7 @@ * @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon * @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970 * @author Miroslav Pejic - miroslav.pejic.85@gmail.com - * @version 1.3.57 + * @version 1.3.58 * */ @@ -356,6 +356,10 @@ class RoomClient { console.log('00-WARNING ----> Room Lobby Enabled, Wait to confirm my join'); return this.waitJoinConfirm(); } + if (room === 'isBanned') { + console.log('00-WARNING ----> You are Banned from the Room!'); + return this.isBanned(); + } const peers = new Map(JSON.parse(room.peers)); for (let peer of Array.from(peers.keys()).filter((id) => id !== this.peer_id)) { let peer_info = peers.get(peer).peer_info; @@ -5232,6 +5236,25 @@ class RoomClient { }); } + isBanned() { + this.sound('alert'); + Swal.fire({ + allowOutsideClick: false, + allowEscapeKey: false, + showDenyButton: false, + showConfirmButton: true, + background: swalBackground, + imageUrl: image.forbidden, + title: 'Banned', + text: 'You are banned from this room!', + confirmButtonText: `Ok`, + showClass: { popup: 'animate__animated animate__fadeInDown' }, + hideClass: { popup: 'animate__animated animate__fadeOutUp' }, + }).then(() => { + this.exit(); + }); + } + // #################################################### // HANDLE AUDIO VOLUME // #################################################### @@ -5394,7 +5417,7 @@ class RoomClient { // PEER ACTION // #################################################### - peerAction(from_peer_name, id, action, emit = true, broadcast = false, info = true, msg = '') { + async peerAction(from_peer_name, id, action, emit = true, broadcast = false, info = true, msg = '') { const words = id.split('___'); const peer_id = words[0]; @@ -5403,6 +5426,7 @@ class RoomClient { from_peer_name: this.peer_name, from_peer_id: this.peer_id, from_peer_uuid: this.peer_uuid, + to_peer_uuid: '', peer_id: peer_id, action: action, message: '', @@ -5481,6 +5505,13 @@ class RoomClient { } } break; + case 'eject': + if (!isRulesActive || isPresenter) { + const peer_info = await getRemotePeerInfo(peer_id); + console.log('EJECT PEER', peer_info); + if (peer_info) data.to_peer_uuid = peer_info.peer_uuid; + } + break; default: break; }