|
|
@ -15,6 +15,7 @@ use File::stat; |
|
|
|
use File::Basename; |
|
|
|
use File::Basename; |
|
|
|
use Etherpad::API; |
|
|
|
use Etherpad::API; |
|
|
|
use Session::Token; |
|
|
|
use Session::Token; |
|
|
|
|
|
|
|
use Config::Simple; |
|
|
|
|
|
|
|
|
|
|
|
# List The different components we rely on. |
|
|
|
# List The different components we rely on. |
|
|
|
# Used to generate thanks on the about template |
|
|
|
# Used to generate thanks on the about template |
|
|
@ -105,30 +106,37 @@ our $musics = { |
|
|
|
|
|
|
|
|
|
|
|
app->log->level('info'); |
|
|
|
app->log->level('info'); |
|
|
|
# Read conf file, and set default values |
|
|
|
# Read conf file, and set default values |
|
|
|
our $config = plugin Config => { |
|
|
|
my $cfg = new Config::Simple(); |
|
|
|
file => 'conf/vroom.conf', |
|
|
|
$cfg->read('conf/settings.ini'); |
|
|
|
default => { |
|
|
|
our $config = $cfg->vars(); |
|
|
|
dbi => 'DBI:mysql:database=vroom;host=localhost', |
|
|
|
|
|
|
|
dbUser => 'vroom', |
|
|
|
$config->{'database.dsn'} ||= 'DBI:mysql:database=vroom;host=localhost'; |
|
|
|
dbPassword => 'vroom', |
|
|
|
$config->{'database.user'} ||= 'vroom'; |
|
|
|
signalingServer => 'https://vroom.example.com/', |
|
|
|
$config->{'database.password'} ||= 'vroom'; |
|
|
|
stunServer => 'stun.l.google.com:19302', |
|
|
|
$config->{'signaling.uri'} ||= 'https://vroom.example.com/'; |
|
|
|
realm => 'vroom', |
|
|
|
$config->{'turn.stun_server'} ||= 'stun.l.google.com:19302'; |
|
|
|
emailFrom => 'vroom@example.com', |
|
|
|
$config->{'turn.turn_server'} ||= ''; |
|
|
|
feedbackRecipient => 'admin@example.com', |
|
|
|
$config->{'turn.realm'} ||= 'vroom'; |
|
|
|
poweredBy => '<a href="http://www.firewall-services.com" target="_blank">Firewall Services</a>', |
|
|
|
$config->{'email.from '} ||= 'vroom@example.com'; |
|
|
|
template => 'default', |
|
|
|
$config->{'email.contact'} ||= 'admin@example.com'; |
|
|
|
inactivityTimeout => 3600, |
|
|
|
$config->{'email.sendmail'} ||= '/sbin/sendmail'; |
|
|
|
reservedInactivityTimeout => 5184000, |
|
|
|
$config->{'interface.powered_by'} ||= '<a href="http://www.firewall-services.com" target="_blank">Firewall Services</a>'; |
|
|
|
commonRoomNames => [ qw() ], |
|
|
|
$config->{'interface.template'} ||= 'default'; |
|
|
|
logLevel => 'info', |
|
|
|
$config->{'interface.chrome_extension_id'} ||= 'ecicdpoejfllflombfanbhfpgcimjddn'; |
|
|
|
chromeExtensionId => 'ecicdpoejfllflombfanbhfpgcimjddn', |
|
|
|
$config->{'cookie.secret'} ||= 'secret'; |
|
|
|
etherpadUri => '', |
|
|
|
$config->{'cookie.name'} ||= 'vroom'; |
|
|
|
etherpadApiKey => '', |
|
|
|
$config->{'rooms.inactivity_timeout'} ||= 3600; |
|
|
|
etherpadBaseDomain => '', |
|
|
|
$config->{'rooms.reserved_inactivity_timeout'} ||= 5184000; |
|
|
|
sendmail => '/sbin/sendmail' |
|
|
|
$config->{'rooms.common_names'} ||= ''; |
|
|
|
} |
|
|
|
$config->{'log.level'} ||= 'info'; |
|
|
|
}; |
|
|
|
$config->{'etherpad.uri'} ||= ''; |
|
|
|
|
|
|
|
$config->{'etherpad.api_key'} ||= ''; |
|
|
|
|
|
|
|
$config->{'etherpad.base_domain'} ||= ''; |
|
|
|
|
|
|
|
$config->{'daemon.listen_ip'} ||= '127.0.0.1'; |
|
|
|
|
|
|
|
$config->{'daemon.listen_port'} ||= '8090'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Set log level |
|
|
|
|
|
|
|
app->log->level($config->{'log.level'}); |
|
|
|
|
|
|
|
|
|
|
|
our @js_locales = qw( |
|
|
|
our @js_locales = qw( |
|
|
|
ERROR_MAIL_INVALID |
|
|
|
ERROR_MAIL_INVALID |
|
|
@ -190,15 +198,13 @@ our @js_locales = qw( |
|
|
|
|
|
|
|
|
|
|
|
# Create etherpad api client if required |
|
|
|
# Create etherpad api client if required |
|
|
|
our $ec = undef; |
|
|
|
our $ec = undef; |
|
|
|
if ($config->{etherpadUri} =~ m/https?:\/\/.*/ && $config->{etherpadApiKey} ne ''){ |
|
|
|
if ($config->{'etherpad.uri'} =~ m/https?:\/\/.*/ && $config->{'etherpad.api_key'} ne ''){ |
|
|
|
$ec = Etherpad::API->new({ |
|
|
|
$ec = Etherpad::API->new({ |
|
|
|
url => $config->{etherpadUri}, |
|
|
|
url => $config->{'etherpad.uri'}, |
|
|
|
apikey => $config->{etherpadApiKey} |
|
|
|
apikey => $config->{'etherpad.api_key'} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
app->log->level($config->{logLevel}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Load I18N, and declare supported languages |
|
|
|
# Load I18N, and declare supported languages |
|
|
|
plugin I18N => { |
|
|
|
plugin I18N => { |
|
|
|
namespace => 'Vroom::I18N', |
|
|
|
namespace => 'Vroom::I18N', |
|
|
@ -207,15 +213,15 @@ plugin I18N => { |
|
|
|
|
|
|
|
|
|
|
|
# Connect to the database |
|
|
|
# Connect to the database |
|
|
|
plugin database => { |
|
|
|
plugin database => { |
|
|
|
dsn => $config->{dbi}, |
|
|
|
dsn => $config->{'database.dsn'}, |
|
|
|
username => $config->{dbUser}, |
|
|
|
username => $config->{'database.user'}, |
|
|
|
password => $config->{dbPassword}, |
|
|
|
password => $config->{'database.password'}, |
|
|
|
options => { mysql_enable_utf8 => 1 } |
|
|
|
options => { mysql_enable_utf8 => 1 } |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
# Load mail plugin with its default values |
|
|
|
# Load mail plugin with its default values |
|
|
|
plugin mail => { |
|
|
|
plugin mail => { |
|
|
|
from => $config->{emailFrom}, |
|
|
|
from => $config->{'email.from'}, |
|
|
|
type => 'text/html', |
|
|
|
type => 'text/html', |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -256,7 +262,7 @@ helper create_room => sub { |
|
|
|
} || return undef; |
|
|
|
} || return undef; |
|
|
|
# Gen a random token. Will be used as a turnPassword |
|
|
|
# Gen a random token. Will be used as a turnPassword |
|
|
|
my $tp = $self->get_random(256); |
|
|
|
my $tp = $self->get_random(256); |
|
|
|
$sth->execute($name,time(),time(),$owner,$tp,$config->{realm}) || return undef; |
|
|
|
$sth->execute($name,time(),time(),$owner,$tp,$config->{'turn.realm'}) || return undef; |
|
|
|
$self->app->log->info("Room $name created by " . $self->session('name')); |
|
|
|
$self->app->log->info("Room $name created by " . $self->session('name')); |
|
|
|
# Etherpad integration ? |
|
|
|
# Etherpad integration ? |
|
|
|
if ($ec){ |
|
|
|
if ($ec){ |
|
|
@ -427,7 +433,7 @@ helper delete_participants => sub { |
|
|
|
helper delete_rooms => sub { |
|
|
|
helper delete_rooms => sub { |
|
|
|
my $self = shift; |
|
|
|
my $self = shift; |
|
|
|
$self->app->log->debug('Removing unused rooms'); |
|
|
|
$self->app->log->debug('Removing unused rooms'); |
|
|
|
my $timeout = time()-$config->{inactivityTimeout}; |
|
|
|
my $timeout = time()-$config->{'rooms.inactivity_timeout'}; |
|
|
|
my $sth = eval { |
|
|
|
my $sth = eval { |
|
|
|
$self->db->prepare("SELECT `name` FROM `rooms` WHERE `activity_timestamp` < $timeout AND `persistent`='0' AND `owner_password` IS NULL;") |
|
|
|
$self->db->prepare("SELECT `name` FROM `rooms` WHERE `activity_timestamp` < $timeout AND `persistent`='0' AND `owner_password` IS NULL;") |
|
|
|
} || return undef; |
|
|
|
} || return undef; |
|
|
@ -437,8 +443,8 @@ helper delete_rooms => sub { |
|
|
|
push @toDeleteName, $room; |
|
|
|
push @toDeleteName, $room; |
|
|
|
} |
|
|
|
} |
|
|
|
my @toDeleteId = (); |
|
|
|
my @toDeleteId = (); |
|
|
|
if ($config->{reservedInactivityTimeout} > 0){ |
|
|
|
if ($config->{'rooms.reserved_inactivity_timeout'} > 0){ |
|
|
|
$timeout = time()-$config->{reservedInactivityTimeout}; |
|
|
|
$timeout = time()-$config->{'rooms.reserved_inactivity_timeout'}; |
|
|
|
$sth = eval { |
|
|
|
$sth = eval { |
|
|
|
$self->db->prepare("SELECT `name` FROM `rooms` WHERE `activity_timestamp` < $timeout AND `persistent`='0' AND `owner_password` IS NOT NULL;") |
|
|
|
$self->db->prepare("SELECT `name` FROM `rooms` WHERE `activity_timestamp` < $timeout AND `persistent`='0' AND `owner_password` IS NOT NULL;") |
|
|
|
} || return undef; |
|
|
|
} || return undef; |
|
|
@ -844,9 +850,8 @@ helper create_etherpad_session => sub { |
|
|
|
my $etherpadSession = $ec->create_session($data->{etherpad_group}, $id, time + 86400); |
|
|
|
my $etherpadSession = $ec->create_session($data->{etherpad_group}, $id, time + 86400); |
|
|
|
$self->session($room)->{etherpadSessionId} = $etherpadSession; |
|
|
|
$self->session($room)->{etherpadSessionId} = $etherpadSession; |
|
|
|
my $etherpadCookieParam = {}; |
|
|
|
my $etherpadCookieParam = {}; |
|
|
|
if ($config->{etherpadBaseDomain} && $config->{etherpadBaseDomain} ne ''){ |
|
|
|
if ($config->{'etherpad.base_domain'} && $config->{'etherpad.base_domain'} ne ''){ |
|
|
|
$etherpadCookieParam->{domain} = $config->{etherpadBaseDomain}; |
|
|
|
$etherpadCookieParam->{domain} = $config->{'etherpad.base_domain'}; |
|
|
|
$self->app->log->debug("Creating an etherpad SesionID cookie for domaine " . $config->{etherpadBaseDomain}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
$self->cookie(sessionID => $etherpadSession, $etherpadCookieParam); |
|
|
|
$self->cookie(sessionID => $etherpadSession, $etherpadCookieParam); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -905,7 +910,7 @@ post '/feedback' => sub { |
|
|
|
my $email = $self->param('email') || ''; |
|
|
|
my $email = $self->param('email') || ''; |
|
|
|
my $comment = $self->param('comment'); |
|
|
|
my $comment = $self->param('comment'); |
|
|
|
my $sent = $self->mail( |
|
|
|
my $sent = $self->mail( |
|
|
|
to => $config->{feedbackRecipient}, |
|
|
|
to => $config->{'email.contact'}, |
|
|
|
subject => $self->l("FEEDBACK_FROM_VROOM"), |
|
|
|
subject => $self->l("FEEDBACK_FROM_VROOM"), |
|
|
|
data => $self->render_mail('feedback', |
|
|
|
data => $self->render_mail('feedback', |
|
|
|
email => $email, |
|
|
|
email => $email, |
|
|
@ -1309,7 +1314,7 @@ post '/*action' => [action => [qw/action admin\/action/]] => sub { |
|
|
|
if ($prefix eq 'admin' || $self->session($room)->{role} eq 'owner'){ |
|
|
|
if ($prefix eq 'admin' || $self->session($room)->{role} eq 'owner'){ |
|
|
|
if ($type eq 'owner'){ |
|
|
|
if ($type eq 'owner'){ |
|
|
|
# Forbid a few common room names to be reserved |
|
|
|
# Forbid a few common room names to be reserved |
|
|
|
if (grep { $room eq $_ } @{$config->{commonRoomNames}}){ |
|
|
|
if (grep { $room eq $_ } (split /[,;]/, $config->{'rooms.common_names'})){ |
|
|
|
$msg = $self->l('ERROR_COMMON_ROOM_NAME'); |
|
|
|
$msg = $self->l('ERROR_COMMON_ROOM_NAME'); |
|
|
|
} |
|
|
|
} |
|
|
|
elsif ($self->set_owner_pass($room,$pass)){ |
|
|
|
elsif ($self->set_owner_pass($room,$pass)){ |
|
|
@ -1577,22 +1582,24 @@ post '/*action' => [action => [qw/action admin\/action/]] => sub { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
# use the templates defined in the config |
|
|
|
# use the templates defined in the config |
|
|
|
push @{app->renderer->paths}, 'templates/'.$config->{template}; |
|
|
|
push @{app->renderer->paths}, 'templates/'.$config->{'interface.template'}; |
|
|
|
# Set the secret used to sign cookies |
|
|
|
# Set the secret used to sign cookies |
|
|
|
app->secret($config->{secret}); |
|
|
|
app->secret($config->{'cookie.secret'}); |
|
|
|
app->sessions->secure(1); |
|
|
|
app->sessions->secure(1); |
|
|
|
app->sessions->cookie_name('vroom'); |
|
|
|
app->sessions->cookie_name($config->{'cookie.name'}); |
|
|
|
app->hook(before_dispatch => sub { |
|
|
|
app->hook(before_dispatch => sub { |
|
|
|
my $self = shift; |
|
|
|
my $self = shift; |
|
|
|
# Switch to the desired language |
|
|
|
# Switch to the desired language |
|
|
|
if ($self->session('language')){ |
|
|
|
if ($self->session('language')){ |
|
|
|
$self->languages($self->session('language')); |
|
|
|
$self->languages($self->session('language')); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
# Stash the configuration hashref |
|
|
|
|
|
|
|
$self->stash(config => $config); |
|
|
|
}); |
|
|
|
}); |
|
|
|
# Are we running in hypnotoad ? |
|
|
|
# Are we running in hypnotoad ? |
|
|
|
app->config( |
|
|
|
app->config( |
|
|
|
hypnotoad => { |
|
|
|
hypnotoad => { |
|
|
|
listen => ['http://127.0.0.1:8090'], |
|
|
|
listen => ['http://' . $config->{'daemon.listen_ip'} . ':' . $config->{'daemon.listen_port'}], |
|
|
|
pid_file => '/tmp/vroom.pid', |
|
|
|
pid_file => '/tmp/vroom.pid', |
|
|
|
proxy => 1 |
|
|
|
proxy => 1 |
|
|
|
} |
|
|
|
} |
|
|
|