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-27 12:54:55 +0300
committerJoas Schilling <coding@schilljs.com>2017-09-28 16:53:59 +0300
commit2a33f7fd1a14dafd726ce912547f6df976b97ae8 (patch)
tree1e8fa0cf61e082d2c39ab8541741da9503666ae6 /lib/Config.php
parentb3ef9248b19368b4107cbfca1d865833774a04ba (diff)
Allow setting multiple STUN servers
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Config.php')
-rw-r--r--lib/Config.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Config.php b/lib/Config.php
index c50c21b94..736115e57 100644
--- a/lib/Config.php
+++ b/lib/Config.php
@@ -47,7 +47,18 @@ class Config {
* @return string
*/
public function getStunServer() {
- return $this->config->getAppValue('spreed', 'stun_server', 'stun.nextcloud.com:443');
+ $config = $this->config->getAppValue('spreed', 'stun_server', 'stun.nextcloud.com:443');
+ $servers = json_decode($config);
+
+ if ($servers === null) {
+ return $config ?: 'stun.nextcloud.com:443';
+ }
+
+ if (is_array($servers) && !empty($servers)) {
+ return $servers[mt_rand(0, count($servers) - 1)];
+ }
+
+ return 'stun.nextcloud.com:443';
}
/**