Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-09-28 16:52:51 +0300
committerJoas Schilling <coding@schilljs.com>2017-09-28 16:53:59 +0300
commit9e2e39a614a034fd830e014e0176c3b651d3e967 (patch)
treee93f29d623fd0dcd2cf0b42dfced527240aed1fb /lib/Config.php
parent2a33f7fd1a14dafd726ce912547f6df976b97ae8 (diff)
Allow multiple turn servers
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Config.php')
-rw-r--r--lib/Config.php24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/Config.php b/lib/Config.php
index 736115e57..1049af0a5 100644
--- a/lib/Config.php
+++ b/lib/Config.php
@@ -55,6 +55,7 @@ class Config {
}
if (is_array($servers) && !empty($servers)) {
+ // For now we use a random server from the list
return $servers[mt_rand(0, count($servers) - 1)];
}
@@ -67,12 +68,10 @@ class Config {
* @return array
*/
public function getTurnSettings() {
- // generate from shared secret
- $turnServer = $this->config->getAppValue('spreed', 'turn_server', '');
- $turnServerSecret = $this->config->getAppValue('spreed', 'turn_server_secret', '');
- $turnServerProtocols = $this->config->getAppValue('spreed', 'turn_server_protocols', '');
+ $config = $this->config->getAppValue('spreed', 'stun_server');
+ $servers = json_decode($config);
- if ($turnServer === '' || $turnServerSecret === '' || $turnServerProtocols === '') {
+ if ($servers === null || !empty($servers) || !is_array($servers)) {
return [
'server' => '',
'username' => '',
@@ -81,16 +80,19 @@ class Config {
];
}
- // the credentials are valid for 24h - FIXME add the TTL to the response and properly reconnect then
+ // For now we use a random server from the list
+ $server = $servers[mt_rand(0, count($servers) - 1)];
+
+ // Credentials are valid for 24h
+ // FIXME add the TTL to the response and properly reconnect then
$username = $this->timeFactory->getTime() + 86400;
- $hashedString = hash_hmac('sha1', $username, $turnServerSecret, true);
- $password = base64_encode($hashedString);
+ $password = base64_encode(hash_hmac('sha1', $username, $server['secret'], true));
return array(
- 'server' => $turnServer,
- 'username' => (string)$username,
+ 'server' => $server['server'],
+ 'username' => (string) $username,
'password' => $password,
- 'protocols' => $turnServerProtocols,
+ 'protocols' => $server['protocols'],
);
}