From d08572be91c311a24f7636ce29edab79dbfd0577 Mon Sep 17 00:00:00 2001
From: Luca Moser <moser.luca@gmail.com>
Date: Thu, 23 Jan 2020 14:12:42 +0100
Subject: [PATCH] adds bind address parameter for the web api

---
 config.json                  |  5 ++++-
 plugins/webapi/parameters.go | 13 +++++++++++++
 plugins/webapi/plugin.go     |  3 ++-
 3 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100644 plugins/webapi/parameters.go

diff --git a/config.json b/config.json
index e28d03a9..d5f7713c 100644
--- a/config.json
+++ b/config.json
@@ -8,7 +8,7 @@
     "entrynodes": [
       "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626"
     ],
-    "port":14626
+    "port": 14626
   },
   "database": {
     "directory": "mainnetdb"
@@ -16,6 +16,9 @@
   "gossip": {
     "port": 14666
   },
+  "webapi": {
+    "bindAddress": "0.0.0.0:8080"
+  },
   "graph": {
     "webrootPath": "./IOTAtangle/webroot",
     "socketioPath": "./socket.io-client/dist/socket.io.js",
diff --git a/plugins/webapi/parameters.go b/plugins/webapi/parameters.go
new file mode 100644
index 00000000..e5703ce3
--- /dev/null
+++ b/plugins/webapi/parameters.go
@@ -0,0 +1,13 @@
+package webapi
+
+import (
+	flag "github.com/spf13/pflag"
+)
+
+const (
+	BIND_ADDRESS = "webapi.bindAddress"
+)
+
+func init() {
+	flag.String(BIND_ADDRESS, "0.0.0.0:8080", "the bind address for the web API")
+}
diff --git a/plugins/webapi/plugin.go b/plugins/webapi/plugin.go
index c7bd41f3..79365c87 100644
--- a/plugins/webapi/plugin.go
+++ b/plugins/webapi/plugin.go
@@ -4,6 +4,7 @@ import (
 	"context"
 	"time"
 
+	"github.com/iotaledger/goshimmer/packages/parameter"
 	"github.com/iotaledger/goshimmer/packages/shutdown"
 	"github.com/iotaledger/hive.go/daemon"
 	"github.com/iotaledger/hive.go/logger"
@@ -30,7 +31,7 @@ func run(plugin *node.Plugin) {
 		log.Info("Starting Web Server ... done")
 
 		go func() {
-			if err := Server.Start(":8080"); err != nil {
+			if err := Server.Start(parameter.NodeConfig.GetString(BIND_ADDRESS)); err != nil {
 				log.Info("Stopping Web Server ... done")
 			}
 		}()
-- 
GitLab