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:
Diffstat (limited to 'lib/Config.php')
-rw-r--r--lib/Config.php74
1 files changed, 24 insertions, 50 deletions
diff --git a/lib/Config.php b/lib/Config.php
index 0388e1028..3bef58717 100644
--- a/lib/Config.php
+++ b/lib/Config.php
@@ -1,4 +1,5 @@
<?php
+
declare(strict_types=1);
/**
* @author Joachim Bauch <mail@joachim-bauch.de>
@@ -29,9 +30,9 @@ use OCP\IUser;
use OCP\Security\ISecureRandom;
class Config {
-
public const SIGNALING_INTERNAL = 'internal';
public const SIGNALING_EXTERNAL = 'external';
+ public const SIGNALING_CLUSTER_CONVERSATION = 'conversation_cluster';
/** @var IConfig */
protected $config;
@@ -94,49 +95,6 @@ class Config {
return $this->config->getUserValue($userId, 'spreed', 'attachment_folder', '/Talk');
}
- public function getSettings(?string $userId): array {
- $stun = [];
- $stunServer = $this->getStunServer();
- if ($stunServer) {
- $stun[] = [
- 'url' => 'stun:' . $stunServer,
- ];
- }
- $turn = [];
- $turnSettings = $this->getTurnSettings();
- if (!empty($turnSettings['server'])) {
- $protocols = explode(',', $turnSettings['protocols']);
- foreach ($protocols as $proto) {
- $turn[] = [
- 'url' => ['turn:' . $turnSettings['server'] . '?transport=' . $proto],
- 'urls' => ['turn:' . $turnSettings['server'] . '?transport=' . $proto],
- 'username' => $turnSettings['username'],
- 'credential' => $turnSettings['password'],
- ];
- }
- }
-
- $signaling = [];
- $servers = $this->getSignalingServers();
- if (!empty($servers)) {
- try {
- $signaling = $servers[random_int(0, count($servers) - 1)];
- } catch (\Exception $e) {
- $signaling = $servers[0];
- }
- $signaling = $signaling['server'];
- }
-
- return [
- 'userId' => $userId,
- 'hideWarning' => !empty($signaling) || $this->getHideSignalingWarning(),
- 'server' => $signaling,
- 'ticket' => $this->getSignalingTicket($userId),
- 'stunservers' => $stun,
- 'turnservers' => $turn,
- ];
- }
-
/**
* @return string[]
*/
@@ -196,7 +154,7 @@ class Config {
}
if (!$this->config->getSystemValueBool('has_internet_connection', true)) {
- $servers = array_filter($servers, static function($server) {
+ $servers = array_filter($servers, static function ($server) {
return $server !== 'stun.nextcloud.com:443';
});
}
@@ -269,19 +227,36 @@ class Config {
$username = $timestamp . ':' . $rnd;
$password = base64_encode(hash_hmac('sha1', $username, $server['secret'], true));
- return array(
+ return [
'server' => $server['server'],
'username' => $username,
'password' => $password,
'protocols' => $server['protocols'],
- );
+ ];
}
public function getSignalingMode(): string {
- if (empty($this->getSignalingServers())) {
+ $validModes = [
+ self::SIGNALING_INTERNAL,
+ self::SIGNALING_EXTERNAL,
+ self::SIGNALING_CLUSTER_CONVERSATION,
+ ];
+
+ $mode = $this->config->getAppValue('spreed', 'signaling_mode', null);
+ if ($mode === self::SIGNALING_INTERNAL) {
return self::SIGNALING_INTERNAL;
}
- return self::SIGNALING_EXTERNAL;
+
+ $numSignalingServers = count($this->getSignalingServers());
+ if ($numSignalingServers === 0) {
+ return self::SIGNALING_INTERNAL;
+ }
+ if ($numSignalingServers === 1
+ && $this->config->getAppValue('spreed', 'signaling_dev', 'no') === 'no') {
+ return self::SIGNALING_EXTERNAL;
+ }
+
+ return \in_array($mode, $validModes, true) ? $mode : self::SIGNALING_EXTERNAL;
}
/**
@@ -374,5 +349,4 @@ class Config {
$hash = hash_hmac('sha256', $data, $secret);
return hash_equals($hash, substr($ticket, $lastColon + 1));
}
-
}