From 86265b9fd42a12c50f4eda9755c87df1f615d26e Mon Sep 17 00:00:00 2001 From: Joe van der Zwet Date: Thu, 20 Aug 2020 19:42:47 +1200 Subject: [PATCH] fix: Add check for invalid modern forwarding config --- .../java/me/joezwet/fabricforwarding/FabricForwarding.java | 3 ++- .../java/me/joezwet/fabricforwarding/api/config/Config.java | 2 ++ .../java/me/joezwet/fabricforwarding/config/ConfigImpl.java | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/joezwet/fabricforwarding/FabricForwarding.java b/src/main/java/me/joezwet/fabricforwarding/FabricForwarding.java index 2c25b42..166f36b 100644 --- a/src/main/java/me/joezwet/fabricforwarding/FabricForwarding.java +++ b/src/main/java/me/joezwet/fabricforwarding/FabricForwarding.java @@ -19,7 +19,8 @@ public class FabricForwarding implements DedicatedServerModInitializer { @Override public void onInitializeServer() { if(Config.getInstance().getMode().equals(ForwardingMode.MODERN) && Config.getInstance().getSecret().length == 0) { - LOGGER.fatal("Modern IP forwarding enabled but no secret provided, please enter the same secret as the one in your proxy's config."); + LOGGER.fatal("Modern IP forwarding enabled but no secret provided, please enter the same secret as the one in your proxy's config. Disabling forwarding."); + Config.getInstance().invalidMode(); } } } diff --git a/src/main/java/me/joezwet/fabricforwarding/api/config/Config.java b/src/main/java/me/joezwet/fabricforwarding/api/config/Config.java index b888f1b..d453983 100644 --- a/src/main/java/me/joezwet/fabricforwarding/api/config/Config.java +++ b/src/main/java/me/joezwet/fabricforwarding/api/config/Config.java @@ -13,4 +13,6 @@ static Config getInstance() { ForwardingMode getMode(); byte[] getSecret(); + + void invalidMode(); } diff --git a/src/main/java/me/joezwet/fabricforwarding/config/ConfigImpl.java b/src/main/java/me/joezwet/fabricforwarding/config/ConfigImpl.java index ef55fc6..1a68577 100644 --- a/src/main/java/me/joezwet/fabricforwarding/config/ConfigImpl.java +++ b/src/main/java/me/joezwet/fabricforwarding/config/ConfigImpl.java @@ -26,4 +26,9 @@ public ForwardingMode getMode() { public byte[] getSecret() { return this.secret.getBytes(Charsets.UTF_8); } + + @Override + public void invalidMode() { + this.mode = "OFF"; + } }