From 473bc62f2a9ebe84e64b88e98e198679b6940ee0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Fran=C3=A7ois?= <thibault@octopuce.fr>
Date: Thu, 22 Apr 2021 09:42:58 +0200
Subject: [PATCH] [add] enable bbb-webhooks to bind nodejs localhost, and make
 it default

---
 bbb-webhooks/application.js             |  2 +-
 bbb-webhooks/config/default.example.yml |  1 +
 bbb-webhooks/web_server.js              | 17 +++++++++--------
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/bbb-webhooks/application.js b/bbb-webhooks/application.js
index 148979a051..f36223d340 100644
--- a/bbb-webhooks/application.js
+++ b/bbb-webhooks/application.js
@@ -22,7 +22,7 @@ module.exports = class Application {
       UserMapping.initialize(() => {
         IDMapping.initialize(()=> {
           async.parallel([
-            (callback) => { this.webServer.start(config.get("server.port"), callback) },
+            (callback) => { this.webServer.start(config.get("server.port"), config.get("server.bind"), callback) },
             (callback) => { this.webServer.createPermanents(callback) },
             (callback) => { this.webHooks.start(callback) }
           ], (err,results) => {
diff --git a/bbb-webhooks/config/default.example.yml b/bbb-webhooks/config/default.example.yml
index 1ca2983dc8..362bd81dec 100644
--- a/bbb-webhooks/config/default.example.yml
+++ b/bbb-webhooks/config/default.example.yml
@@ -8,6 +8,7 @@ bbb:
 
 # The port in which the API server will run.
 server:
+  bind: 127.0.0.1
   port: 3005
 
 # Web hooks configs
diff --git a/bbb-webhooks/web_server.js b/bbb-webhooks/web_server.js
index c95b43bb6f..c5461bda10 100644
--- a/bbb-webhooks/web_server.js
+++ b/bbb-webhooks/web_server.js
@@ -17,14 +17,15 @@ module.exports = class WebServer {
     this._registerRoutes();
   }
 
-  start(port, callback) {
-    this.server = this.app.listen(port);
-    if (this.server.address() == null) {
-      Logger.error("[WebServer] aborting, could not bind to port", port,
-      process.exit(1));
-    }
-    Logger.info("[WebServer] listening on port", port, "in", this.app.settings.env.toUpperCase(), "mode");
-    typeof callback === 'function' ? callback(null,"k") : undefined;
+  start(port, bind, callback) {
+    this.server = this.app.listen(port, bind, () => {
+      if (this.server.address() == null) {
+        Logger.error("[WebServer] aborting, could not bind to port", port,
+        process.exit(1));
+      }
+      Logger.info("[WebServer] listening on port", port, "in", this.app.settings.env.toUpperCase(), "mode");
+      typeof callback === 'function' ? callback(null,"k") : undefined;
+    });
   }
 
   _registerRoutes() {
-- 
GitLab