From 45806953a52aed891ef93957b445659be2511e19 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 5 Mar 2015 18:27:34 +0100 Subject: [PATCH] Check if websocket connection should be allowed --- vroom.pl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/vroom.pl b/vroom.pl index 39ceb9e..7e5499f 100755 --- a/vroom.pl +++ b/vroom.pl @@ -1075,10 +1075,20 @@ websocket '/socket.io/:ver/websocket/:id' => sub { if ($msg->type eq 'event'){ if ($msg->{data}->{name} eq 'join'){ my $room = $msg->{data}->{args}[0]; + # Is this peer allowed to join the room ? + if (!$self->session($room) || + !$self->session($room)->{role} || + $self->session($room)->{role} !~ m/^owner|participant$/){ + $self->app->log->debug("Failed to connect to the signaling channel, " . $self->session('name') . + " (session ID " . $self->session('id') . ") has no role for this room"); + $self->send( Protocol::SocketIO::Message->new( type => 'disconnect' ) ); + $self->finish; + return; + } my $others = {}; - foreach my $peers (keys %$peers){ - next if ($peers eq $id); - $others->{$peers} = $peers->{$peers}->{details}; + foreach my $peer (keys %$peers){ + next if ($peer eq $id); + $others->{$peer} = $peers->{$peer}->{details}; } $peers->{$id}->{details} = { screen => \0, @@ -1086,7 +1096,7 @@ websocket '/socket.io/:ver/websocket/:id' => sub { audio => \0 }; $peers->{$id}->{room} = $room; - $self->app->log->debug("client ID " . $id . " joined room " . $room); + $self->app->log->debug("Client id " . $id . " joined room " . $room); # $self->app->log->debug(Dumper($others)); $self->send( Protocol::SocketIO::Message->new(