Support several STUN and TURN severs

master
Daniel Berteaud 10 years ago
parent a394cc4619
commit 6960665111
  1. 8
      conf/settings.ini.dist
  2. 13
      templates/default/documentation.html.ep
  3. 20
      vroom.pl

@ -9,9 +9,11 @@
;uri = 'https://vroom.exmple.com' ;uri = 'https://vroom.exmple.com'
[turn] [turn]
; The stun server sent to client. You can set it to your own stun server. Takes a full stun uri as defined by rfc7064 ; The stun server sent to client. You can set it to your own stun server. Takes a comma separated list of full
;stun_server = 'stun:stun.l.google.com:19302' ; stun uri as defined by rfc7064
; The turn server sent to cliet, you should set it to your own server. Takes a full turn uri as defined by rfc7065 ;stun_server = 'stun:stun.l.google.com:19302','stun:vroom.example.net:3478'
; The turn server sent to cliet, you should set it to your own server. Takes a comma separated list of full
; turn uri as defined by rfc7065
;turn_server = 'turns:my-turn-server.net:5349?transport=tcp' ;turn_server = 'turns:my-turn-server.net:5349?transport=tcp'
; You can use fixed username/login to access turn. If you omit this, VROOM will generate credentials on the fly ; You can use fixed username/login to access turn. If you omit this, VROOM will generate credentials on the fly
; for rfc5766-turn-server in its database ; for rfc5766-turn-server in its database

@ -288,15 +288,16 @@ cp /opt/vroom/conf/settings.ini.dist /opt/vroom/conf/settings.ini</pre>
If you plan to use VROOM only on a local network, where each peer can connect to each others, you can just omit this part. But if you want If you plan to use VROOM only on a local network, where each peer can connect to each others, you can just omit this part. But if you want
VROOM to work from anywhere, you'll need use STUN and most likely TURN too. VROOM to work from anywhere, you'll need use STUN and most likely TURN too.
<ul> <ul>
<li><strong>stun_server</strong>: The STUN server to use. For example <kbd>stun_server = 'stun:stun.l.google.com:19302'</kbd>. <li><strong>stun_server</strong>: The STUN server(s) to use. For example*
This must be a full STUN URI as defined by <a href="https://tools.ietf.org/html/rfc7064" target="_blank">rfc7064</a></li> <kbd>stun_server = 'stun:stun.l.google.com:19302','stun:vroom.example.net:3478'</kbd>.
<li><strong>turn_server</strong>: The TURN server to use (for now you can only define one, it should be possible to define This must be a comma separated list of full STUN URI as defined by <a href="https://tools.ietf.org/html/rfc7064" target="_blank">rfc7064</a></li>
several). For example <kbd>turn_server = 'turns:my-turn-server.net:5349?transport=tcp'</kbd>. <li><strong>turn_server</strong>: The TURN server(s) to use. For example
This must be a full STUN URI as defined by <a href="https://tools.ietf.org/html/rfc7065" target="_blank">rfc7065</a></li> <kbd>turn_server = 'turns:vroom.example.net:5349','turns:vroom.example.net:5349?transport=tcp'</kbd>.
This must be a comma separated list of full STUN URI as defined by <a href="https://tools.ietf.org/html/rfc7065" target="_blank">rfc7065</a></li>
<li><strong>turn_user</strong> and <strong>turn_password</strong>: To use your TURN server, you'll most likely require credentials. <li><strong>turn_user</strong> and <strong>turn_password</strong>: To use your TURN server, you'll most likely require credentials.
You can either enter them here. If you let this empty, VROOM assumes that you're using You can either enter them here. If you let this empty, VROOM assumes that you're using
<a href="https://code.google.com/p/rfc5766-turn-server/" target="_blank">rfc5766-turn-server</a> and will generate one user and password <a href="https://code.google.com/p/rfc5766-turn-server/" target="_blank">rfc5766-turn-server</a> and will generate one user and password
for each room. See the Configure rfc5766-turn-server section</li> for each room. See the Configure rfc5766-turn-server section. Note that the same credentials will be used for every TURN server you define</li>
<li><strong>realm</strong>: If you use rfc5766-turn-server with dynamic credentials, you must set here the realm configured in <li><strong>realm</strong>: If you use rfc5766-turn-server with dynamic credentials, you must set here the realm configured in
<strong>/etc/turnserver/turnserver.conf</strong> <strong>/etc/turnserver/turnserver.conf</strong>
</ul> </ul>

@ -1708,9 +1708,7 @@ any '/api' => sub {
my $resp = { my $resp = {
url => $config->{'signaling.uri'}, url => $config->{'signaling.uri'},
peerConnectionConfig => { peerConnectionConfig => {
iceServers => [{ iceServers => []
url => $config->{'turn.stun_server'}
}]
}, },
autoRequestMedia => Mojo::JSON::true, autoRequestMedia => Mojo::JSON::true,
enableDataChannels => Mojo::JSON::true, enableDataChannels => Mojo::JSON::true,
@ -1736,9 +1734,20 @@ any '/api' => sub {
muted => Mojo::JSON::true muted => Mojo::JSON::true
} }
}; };
# TODO: Support several TURN server in config if ($config->{'turn.stun_server'}){
if (ref $config->{'turn.stun_server'} ne 'ARRAY'){
$config->{'turn.stun_server'} = [ $config->{'turn.stun_server'} ];
}
foreach my $s (@{$config->{'turn.stun_server'}}){
push @{$resp->{peerConnectionConfig}->{iceServers}}, { url => $s };
}
}
if ($config->{'turn.turn_server'}){ if ($config->{'turn.turn_server'}){
my $turn = { url => $config->{'turn.turn_server'} }; if (ref $config->{'turn.turn_server'} ne 'ARRAY'){
$config->{'turn.turn_server'} = [ $config->{'turn.turn_server'} ];
}
foreach my $t (@{$config->{'turn.turn_server'}}){
my $turn = { url => $t };
if ($config->{'turn.turn_user'} && $config->{'turn.turn_password'}){ if ($config->{'turn.turn_user'} && $config->{'turn.turn_password'}){
$turn->{username} = $config->{'turn.turn_user'}; $turn->{username} = $config->{'turn.turn_user'};
$turn->{credential} = $config->{'turn.turn_password'}; $turn->{credential} = $config->{'turn.turn_password'};
@ -1749,6 +1758,7 @@ any '/api' => sub {
} }
push @{$resp->{peerConnectionConfig}->{iceServers}}, $turn; push @{$resp->{peerConnectionConfig}->{iceServers}}, $turn;
} }
}
return $self->render( return $self->render(
json => { json => {
config => $resp config => $resp

Loading…
Cancel
Save