From c23335df7c1e07ae353becff58f9ed27f035fb8c Mon Sep 17 00:00:00 2001 From: "Blue (Lukas Rieger)" Date: Sat, 8 Aug 2020 10:39:22 +0200 Subject: [PATCH] Add 0.0.0.0 support for webserver and make it the default config value --- BlueMapBukkit/src/main/resources/bluemap-bukkit.conf | 3 ++- BlueMapCLI/src/main/resources/bluemap-cli.conf | 5 +++-- .../java/de/bluecolored/bluemap/core/config/MainConfig.java | 5 ++++- BlueMapFabric/src/main/resources/bluemap-fabric.conf | 3 ++- BlueMapForge/src/main/resources/bluemap-forge.conf | 3 ++- BlueMapSponge/src/main/resources/bluemap-sponge.conf | 3 ++- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/BlueMapBukkit/src/main/resources/bluemap-bukkit.conf b/BlueMapBukkit/src/main/resources/bluemap-bukkit.conf index d5070bb3..c3a60ee9 100644 --- a/BlueMapBukkit/src/main/resources/bluemap-bukkit.conf +++ b/BlueMapBukkit/src/main/resources/bluemap-bukkit.conf @@ -47,8 +47,9 @@ webserver { enabled: true # The IP-Adress that the webserver binds to. - # If this setting is commented out, bluemap tries to find the default ip-adress of your system. + # Use "0.0.0.0" to bind to all available local adresses. # If you only want to access it locally use "localhost". + # Default is "0.0.0.0" #ip: "localhost" #ip: "127.0.0.1" diff --git a/BlueMapCLI/src/main/resources/bluemap-cli.conf b/BlueMapCLI/src/main/resources/bluemap-cli.conf index d2e1ee4f..5ee2904e 100644 --- a/BlueMapCLI/src/main/resources/bluemap-cli.conf +++ b/BlueMapCLI/src/main/resources/bluemap-cli.conf @@ -44,10 +44,11 @@ webserver { # With this setting you can enable the integrated web-server. # Default is disabled enabled: false - + # The IP-Adress that the webserver binds to. - # If this setting is commented out, bluemap tries to find the default ip-adress of your system. + # Use "0.0.0.0" to bind to all available local adresses. # If you only want to access it locally use "localhost". + # Default is "0.0.0.0" #ip: "localhost" #ip: "127.0.0.1" diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/config/MainConfig.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/config/MainConfig.java index 767be0d4..1e1b820e 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/config/MainConfig.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/config/MainConfig.java @@ -27,6 +27,7 @@ import java.io.File; import java.io.IOException; import java.net.InetAddress; +import java.net.InetSocketAddress; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -109,7 +110,9 @@ private void loadWebConfig(ConfigurationNode node) throws IOException { if (webserverEnabled) { //ip String webserverBindAdressString = node.getNode("ip").getString(""); - if (webserverBindAdressString.isEmpty()) { + if (webserverBindAdressString.isEmpty() || webserverBindAdressString.equals("0.0.0.0") || webserverBindAdressString.equals("::0")) { + webserverBindAdress = new InetSocketAddress(0).getAddress(); // 0.0.0.0 + } else if (webserverBindAdressString.equals("#getLocalHost")) { webserverBindAdress = InetAddress.getLocalHost(); } else { webserverBindAdress = InetAddress.getByName(webserverBindAdressString); diff --git a/BlueMapFabric/src/main/resources/bluemap-fabric.conf b/BlueMapFabric/src/main/resources/bluemap-fabric.conf index 8b740ce2..af9edf92 100644 --- a/BlueMapFabric/src/main/resources/bluemap-fabric.conf +++ b/BlueMapFabric/src/main/resources/bluemap-fabric.conf @@ -47,8 +47,9 @@ webserver { enabled: true # The IP-Adress that the webserver binds to. - # If this setting is commented out, bluemap tries to find the default ip-adress of your system. + # Use "0.0.0.0" to bind to all available local adresses. # If you only want to access it locally use "localhost". + # Default is "0.0.0.0" #ip: "localhost" #ip: "127.0.0.1" diff --git a/BlueMapForge/src/main/resources/bluemap-forge.conf b/BlueMapForge/src/main/resources/bluemap-forge.conf index 8b740ce2..af9edf92 100644 --- a/BlueMapForge/src/main/resources/bluemap-forge.conf +++ b/BlueMapForge/src/main/resources/bluemap-forge.conf @@ -47,8 +47,9 @@ webserver { enabled: true # The IP-Adress that the webserver binds to. - # If this setting is commented out, bluemap tries to find the default ip-adress of your system. + # Use "0.0.0.0" to bind to all available local adresses. # If you only want to access it locally use "localhost". + # Default is "0.0.0.0" #ip: "localhost" #ip: "127.0.0.1" diff --git a/BlueMapSponge/src/main/resources/bluemap-sponge.conf b/BlueMapSponge/src/main/resources/bluemap-sponge.conf index 22784691..c97e6ea8 100644 --- a/BlueMapSponge/src/main/resources/bluemap-sponge.conf +++ b/BlueMapSponge/src/main/resources/bluemap-sponge.conf @@ -42,8 +42,9 @@ webserver { enabled: true # The IP-Adress that the webserver binds to. - # If this setting is commented out, bluemap tries to find the default ip-adress of your system. + # Use "0.0.0.0" to bind to all available local adresses. # If you only want to access it locally use "localhost". + # Default is "0.0.0.0" #ip: "localhost" #ip: "127.0.0.1"