1
0
mirror of https://github.com/pavlobu/deskreen.git synced 2025-05-19 00:40:11 -07:00

fix sharing session docs, comments on code

This commit is contained in:
Pavlo Buidenkov 2021-01-22 18:20:28 +02:00
parent b7e089c763
commit 849dc5cf72
7 changed files with 11 additions and 5 deletions

View File

@ -142,7 +142,7 @@ export default class PeerConnection {
this.socket.emit('USER_ENTER', { this.socket.emit('USER_ENTER', {
username: user.username, username: user.username,
publicKey: user.publicKey, publicKey: user.publicKey,
ip: myIP, ip: myIP, // TODO: remove as it is not used
}); });
} }

View File

@ -60,6 +60,7 @@ export default (peerConnection: PeerConnection) => {
if (!peerConnection.partner) return; if (!peerConnection.partner) return;
// TODO: ADD_USER is actually not used, so will remove this code from host and client, this is no use...
peerConnection.sendEncryptedMessage({ peerConnection.sendEncryptedMessage({
type: 'ADD_USER', type: 'ADD_USER',
payload: { payload: {
@ -72,8 +73,9 @@ export default (peerConnection: PeerConnection) => {
peerConnection.sendEncryptedMessage({ peerConnection.sendEncryptedMessage({
type: 'DEVICE_DETAILS', type: 'DEVICE_DETAILS',
// TODO: add deviceIP in this payload
payload: { payload: {
socketID: peerConnection.socket.io.engine.id, socketID: peerConnection.socket.io.engine.id, // TODO: maybe this socketID can be actually retrieved by host? so there will be no use for client to send it? need to check
os: peerConnection.myDeviceDetails.myOS, os: peerConnection.myDeviceDetails.myOS,
deviceType: peerConnection.myDeviceDetails.myDeviceType, deviceType: peerConnection.myDeviceDetails.myDeviceType,
browser: peerConnection.myDeviceDetails.myBrowser, browser: peerConnection.myDeviceDetails.myBrowser,

View File

@ -34,6 +34,7 @@ export default async function handleRecieveEncryptedMessage(
'GET_IP_BY_SOCKET_ID', 'GET_IP_BY_SOCKET_ID',
message.payload.socketID, message.payload.socketID,
(deviceIP: string) => { (deviceIP: string) => {
// TODO: need to add myIP in client message.payload.myIP, then if retrieved deviceIP and myIP from client don't match, we were spoofed, then we can interrupt connection immediately!
handleDeviceIPMessage(deviceIP, peerConnection, message); handleDeviceIPMessage(deviceIP, peerConnection, message);
} }
); );

View File

@ -10,6 +10,7 @@ export default (
[peerConnection.partner] = filteredPartner; [peerConnection.partner] = filteredPartner;
// TODO: ADD_USER is actually not used, so will remove this code from host and client, this is no use...
peerConnection.sendEncryptedMessage({ peerConnection.sendEncryptedMessage({
type: 'ADD_USER', type: 'ADD_USER',
payload: { payload: {

View File

@ -90,6 +90,7 @@ export default class Socket implements SocketOPTS {
}); });
this.socket.on('GET_IP_BY_SOCKET_ID', (socketID, acknowledgeFunction) => { this.socket.on('GET_IP_BY_SOCKET_ID', (socketID, acknowledgeFunction) => {
// TODO: for security only allow localhost to use this socket event! right now it may be emitted by client which may be not secure. The purpose of this event is for host to get the actual IP of connected client socket and compare them with what was sent by client in DEVICE_DETAILS.
acknowledgeFunction(socketsIPService.getSocketIPByID(socketID)); acknowledgeFunction(socketsIPService.getSocketIPByID(socketID));
}); });
@ -142,7 +143,7 @@ export default class Socket implements SocketOPTS {
isOwner: this.socket.request.connection.remoteAddress.includes( isOwner: this.socket.request.connection.remoteAddress.includes(
LOCALHOST_SOCKET_IP LOCALHOST_SOCKET_IP
), ),
ip: payload.ip ? payload.ip : '', ip: payload.ip ? payload.ip : '', // TODO: remove as it is not used
}, },
], ],
}; };
@ -158,6 +159,7 @@ export default class Socket implements SocketOPTS {
}); });
this.socket.on('TOGGLE_LOCK_ROOM', async () => { this.socket.on('TOGGLE_LOCK_ROOM', async () => {
// TODO: in here if there is somehow already more than ONE client connected, then we were spoofed! Need to add code to interrupt connection immediately.
const room: Room = (await this.fetchRoom()) as Room; const room: Room = (await this.fetchRoom()) as Room;
const user = (room.users || []).find( const user = (room.users || []).find(
(u) => u.socketId === this.socket.id && u.isOwner (u) => u.socketId === this.socket.id && u.isOwner

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 257 KiB

After

Width:  |  Height:  |  Size: 262 KiB