summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2024-06-19 20:11:14 +0200
committerGitHub <noreply@github.com>2024-06-19 20:11:14 +0200
commit807578b499c3a9375b3a32d1f7dfd4c7968cb00d (patch)
tree22aea8ce389ebdb83c2d37d8ba4292aae351929a /lib
parentd87d7fb2da4a88de2e872ccef31752cd3b35229f (diff)
parent34f46f67b04103584b14a34a41e3ddf7aea973c6 (diff)
Merge pull request #12531 from nextcloud/skalidindi53/11852/Duplicate-Stun-and-Turn-Servers
fix: duplicate stun and turn servers cannot be added
Diffstat (limited to 'lib')
-rw-r--r--lib/Command/Stun/Add.php8
-rw-r--r--lib/Command/Turn/Add.php13
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/Command/Stun/Add.php b/lib/Command/Stun/Add.php
index 9c47eb31b..2e7bbaba8 100644
--- a/lib/Command/Stun/Add.php
+++ b/lib/Command/Stun/Add.php
@@ -50,6 +50,14 @@ class Add extends Base {
$servers = [];
}
+ // check if the server is already in the list
+ foreach ($servers as $existingServer) {
+ if ($existingServer === "$host:$port") {
+ $output->writeln('<error>Server already exists.</error>');
+ return 1;
+ }
+ }
+
$servers[] = "$host:$port";
$this->config->setAppValue('spreed', 'stun_servers', json_encode($servers));
diff --git a/lib/Command/Turn/Add.php b/lib/Command/Turn/Add.php
index 7bae8645c..6cec353d3 100644
--- a/lib/Command/Turn/Add.php
+++ b/lib/Command/Turn/Add.php
@@ -98,6 +98,19 @@ class Add extends Base {
$servers = [];
}
+ //Checking if the server is already added
+ foreach ($servers as $existingServer) {
+ if (
+ $existingServer['schemes'] === $schemes &&
+ $existingServer['server'] === $server &&
+ $existingServer['protocols'] === $protocols
+ ) {
+ $output->writeln('<error>Server already exists with the same configuration.</error>');
+ return 1;
+ }
+ }
+
+
$servers[] = [
'schemes' => $schemes,
'server' => $server,