diff --git a/src/main/java/de/cubeattack/neoprotect/bungee/proxyprotocol/ProxyProtocol.java b/src/main/java/de/cubeattack/neoprotect/bungee/proxyprotocol/ProxyProtocol.java index 88203a4..d67a139 100644 --- a/src/main/java/de/cubeattack/neoprotect/bungee/proxyprotocol/ProxyProtocol.java +++ b/src/main/java/de/cubeattack/neoprotect/bungee/proxyprotocol/ProxyProtocol.java @@ -51,14 +51,14 @@ protected void initChannel(Channel channel) { initChannelMethod.invoke(bungeeChannelInitializer, channel); - if (channel.localAddress().toString().startsWith("local:")) { + AtomicReference playerAddress = new AtomicReference<>(); + String sourceAddress = ((InetSocketAddress) channel.remoteAddress()).getAddress().getHostAddress(); + + if (channel.localAddress().toString().startsWith("local:") || sourceAddress.equals(Config.getGeyserServerIP())) { instance.getCore().debug("Detected bedrock player (return)"); return; } - AtomicReference playerAddress = new AtomicReference<>(); - String sourceAddress = ((InetSocketAddress) channel.remoteAddress()).getAddress().getHostAddress(); - if (!instance.getCore().getDirectConnectWhitelist().contains(sourceAddress)) { if (instance.getCore().isSetup() && (instance.getCore().getRestAPI().getNeoServerIPs() == null || instance.getCore().getRestAPI().getNeoServerIPs().toList().stream().noneMatch(ipRange -> isIPInRange((String) ipRange, sourceAddress)))) { diff --git a/src/main/java/de/cubeattack/neoprotect/core/Config.java b/src/main/java/de/cubeattack/neoprotect/core/Config.java index 118a708..c4b7c83 100644 --- a/src/main/java/de/cubeattack/neoprotect/core/Config.java +++ b/src/main/java/de/cubeattack/neoprotect/core/Config.java @@ -16,6 +16,7 @@ public class Config { private static String BackendID; private static boolean updateIP; private static boolean debugMode; + private static String geyserServerIP; private static String updateSetting; private static Core core; @@ -33,6 +34,7 @@ public static void loadConfig(Core core, FileUtils config) { BackendID = config.getString("gameshield.backendId", ""); updateIP = config.getBoolean("gameshield.autoUpdateIP", false); debugMode = config.getBoolean("DebugMode", false); + geyserServerIP = config.getString("geyserServerIP", "127.0.0.1"); if (APIKey.length() != 64) { core.severe("Failed to load API-Key. Key is null or not valid"); @@ -80,6 +82,10 @@ public static boolean isDebugMode() { return debugMode; } + public static String getGeyserServerIP() { + return geyserServerIP; + } + public static VersionUtils.UpdateSetting getAutoUpdaterSettings() { return VersionUtils.UpdateSetting.getByNameOrDefault(updateSetting); } diff --git a/src/main/java/de/cubeattack/neoprotect/spigot/proxyprotocol/ProxyProtocol.java b/src/main/java/de/cubeattack/neoprotect/spigot/proxyprotocol/ProxyProtocol.java index 6e87614..66edd82 100644 --- a/src/main/java/de/cubeattack/neoprotect/spigot/proxyprotocol/ProxyProtocol.java +++ b/src/main/java/de/cubeattack/neoprotect/spigot/proxyprotocol/ProxyProtocol.java @@ -178,7 +178,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) { instance.getCore().debug("Open channel (" + channel.remoteAddress().toString() + ")"); - if (channel.localAddress().toString().startsWith("local:")) { + if (channel.localAddress().toString().startsWith("local:") || ((InetSocketAddress) channel.remoteAddress()).getAddress().getHostAddress().equals(Config.getGeyserServerIP())) { instance.getCore().debug("Detected bedrock player (return)"); return; } diff --git a/src/main/java/de/cubeattack/neoprotect/velocity/proxyprotocol/ProxyProtocol.java b/src/main/java/de/cubeattack/neoprotect/velocity/proxyprotocol/ProxyProtocol.java index d8b2922..a7e2483 100644 --- a/src/main/java/de/cubeattack/neoprotect/velocity/proxyprotocol/ProxyProtocol.java +++ b/src/main/java/de/cubeattack/neoprotect/velocity/proxyprotocol/ProxyProtocol.java @@ -56,14 +56,14 @@ protected void initChannel(Channel channel) { initChannelMethod.getMethod().setAccessible(true); initChannelMethod.invoke(oldInitializer, channel); - if (channel.localAddress().toString().startsWith("local:")) { + AtomicReference playerAddress = new AtomicReference<>(); + String sourceAddress = ((InetSocketAddress) channel.remoteAddress()).getAddress().getHostAddress(); + + if (channel.localAddress().toString().startsWith("local:") || sourceAddress.equals(Config.getGeyserServerIP())) { instance.getCore().debug("Detected bedrock player (return)"); return; } - AtomicReference playerAddress = new AtomicReference<>(); - String sourceAddress = ((InetSocketAddress) channel.remoteAddress()).getAddress().getHostAddress(); - if (!instance.getCore().getDirectConnectWhitelist().contains(sourceAddress)) { if (instance.getCore().isSetup() && (instance.getCore().getRestAPI().getNeoServerIPs() == null || instance.getCore().getRestAPI().getNeoServerIPs().toList().stream().noneMatch(ipRange -> isIPInRange((String) ipRange, sourceAddress)))) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index a89d287..b11fd3e 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -6,4 +6,5 @@ gameshield: serverId: '' # The serverID is set automatically during setup backendId: '' # The backendID is set automatically during setup autoUpdateIP: false # This setting automatically sets the IP of the NeoProtect backend every 10 seconds +geyserServerIP: '127.0.0.1' #IMPORTANT ONLY FOR GEYSER STANDALONE DebugMode: false # IMPORTANT Please ensure that you activate this option solely upon receiving a prompt from a NeoProtect maintainer.