mirror of https://github.com/dani/vroom.git
Support several STUN and TURN severs
This commit is contained in:
parent
a394cc4619
commit
6960665111
|
@ -9,9 +9,11 @@
|
|||
;uri = 'https://vroom.exmple.com'
|
||||
|
||||
[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
|
||||
;stun_server = 'stun:stun.l.google.com:19302'
|
||||
; The turn server sent to cliet, you should set it to your own server. Takes a full turn uri as defined by rfc7065
|
||||
; The stun server sent to client. You can set it to your own stun server. Takes a comma separated list of full
|
||||
; stun uri as defined by rfc7064
|
||||
;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'
|
||||
; 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
|
||||
|
|
|
@ -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
|
||||
VROOM to work from anywhere, you'll need use STUN and most likely TURN too.
|
||||
<ul>
|
||||
<li><strong>stun_server</strong>: The STUN server to use. For example <kbd>stun_server = 'stun:stun.l.google.com:19302'</kbd>.
|
||||
This must be a full STUN URI as defined by <a href="https://tools.ietf.org/html/rfc7064" target="_blank">rfc7064</a></li>
|
||||
<li><strong>turn_server</strong>: The TURN server to use (for now you can only define one, it should be possible to define
|
||||
several). For example <kbd>turn_server = 'turns:my-turn-server.net:5349?transport=tcp'</kbd>.
|
||||
This must be a full STUN URI as defined by <a href="https://tools.ietf.org/html/rfc7065" target="_blank">rfc7065</a></li>
|
||||
<li><strong>stun_server</strong>: The STUN server(s) to use. For example*
|
||||
<kbd>stun_server = 'stun:stun.l.google.com:19302','stun:vroom.example.net:3478'</kbd>.
|
||||
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>
|
||||
<li><strong>turn_server</strong>: The TURN server(s) to use. For example
|
||||
<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.
|
||||
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
|
||||
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
|
||||
<strong>/etc/turnserver/turnserver.conf</strong>
|
||||
</ul>
|
||||
|
|
34
vroom.pl
34
vroom.pl
|
@ -1708,9 +1708,7 @@ any '/api' => sub {
|
|||
my $resp = {
|
||||
url => $config->{'signaling.uri'},
|
||||
peerConnectionConfig => {
|
||||
iceServers => [{
|
||||
url => $config->{'turn.stun_server'}
|
||||
}]
|
||||
iceServers => []
|
||||
},
|
||||
autoRequestMedia => Mojo::JSON::true,
|
||||
enableDataChannels => Mojo::JSON::true,
|
||||
|
@ -1736,18 +1734,30 @@ any '/api' => sub {
|
|||
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'}){
|
||||
my $turn = { url => $config->{'turn.turn_server'} };
|
||||
if ($config->{'turn.turn_user'} && $config->{'turn.turn_password'}){
|
||||
$turn->{username} = $config->{'turn.turn_user'};
|
||||
$turn->{credential} = $config->{'turn.turn_password'};
|
||||
if (ref $config->{'turn.turn_server'} ne 'ARRAY'){
|
||||
$config->{'turn.turn_server'} = [ $config->{'turn.turn_server'} ];
|
||||
}
|
||||
else{
|
||||
$turn->{username} = $room->{name};
|
||||
$turn->{credential} = $room->{token};
|
||||
foreach my $t (@{$config->{'turn.turn_server'}}){
|
||||
my $turn = { url => $t };
|
||||
if ($config->{'turn.turn_user'} && $config->{'turn.turn_password'}){
|
||||
$turn->{username} = $config->{'turn.turn_user'};
|
||||
$turn->{credential} = $config->{'turn.turn_password'};
|
||||
}
|
||||
else{
|
||||
$turn->{username} = $room->{name};
|
||||
$turn->{credential} = $room->{token};
|
||||
}
|
||||
push @{$resp->{peerConnectionConfig}->{iceServers}}, $turn;
|
||||
}
|
||||
push @{$resp->{peerConnectionConfig}->{iceServers}}, $turn;
|
||||
}
|
||||
return $self->render(
|
||||
json => {
|
||||
|
|
Loading…
Reference in New Issue