From c3ff88cd7839dba5065905c5c4a783eb9741381e Mon Sep 17 00:00:00 2001
From: Philipp Memmel <philipp.memmel@gmail.com>
Date: Tue, 30 Mar 2021 11:57:37 +0200
Subject: [PATCH] config overlay for bbb-web turn server config

---
 .../grails-app/conf/spring/resources.groovy    | 18 +++++++++++++++++-
 .../grails-app/conf/spring/resources.xml       |  3 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/bigbluebutton-web/grails-app/conf/spring/resources.groovy b/bigbluebutton-web/grails-app/conf/spring/resources.groovy
index 1d5839c3ef..8534c259aa 100755
--- a/bigbluebutton-web/grails-app/conf/spring/resources.groovy
+++ b/bigbluebutton-web/grails-app/conf/spring/resources.groovy
@@ -1,6 +1,22 @@
 // Place your Spring DSL code here
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+Logger logger = LoggerFactory.getLogger("org.bigbluebutton.web.services.turn.StunTurnService")
+
 beans = {
+  def turnConfigFilePath = "/etc/bigbluebutton/turn-stun-servers.xml"
+  def turnConfigFile = new File(turnConfigFilePath)
+  if (turnConfigFile.canRead()) {
+    logger.info("Reading stun/turn server config from overlay config file " + turnConfigFilePath)
+    importBeans('file:' + turnConfigFilePath)
+  } else {
+    logger.info("Overlay stun/turn server config file " + turnConfigFilePath
+      + " not found/readable, reading from default config file location")
+    importBeans('spring/turn-stun-servers.xml')
+  }
 }
+
 /*
 Add back applicationContext.xml
 
@@ -36,4 +52,4 @@ Add back applicationContext.xml
     <bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean" />
 </beans>
 
-*/
\ No newline at end of file
+*/
diff --git a/bigbluebutton-web/grails-app/conf/spring/resources.xml b/bigbluebutton-web/grails-app/conf/spring/resources.xml
index f9ff00ca05..f0af467295 100755
--- a/bigbluebutton-web/grails-app/conf/spring/resources.xml
+++ b/bigbluebutton-web/grails-app/conf/spring/resources.xml
@@ -168,5 +168,6 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
 
     <import resource="doc-conversion.xml"/>
     <import resource="bbb-redis-messaging.xml"/>
-    <import resource="turn-stun-servers.xml"/>
+    <!-- moved the following import statement for turn-stun-servers.xml to resources.groovy to be able to use overlay config for turn/stun servers -->
+    <!--	 <import resource="turn-stun-servers.xml"/>-->
 </beans>
-- 
GitLab