From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: nostalgic853 Date: Sat, 22 Oct 2022 17:23:09 +0800 Subject: [PATCH] Options of warnings Let users decide if we should warn while running in a root user Let users decide if we should warn while running in offline mode Let users decide if we should warn while running in proxy mode diff --git a/src/main/java/cc/keyimc/keyi/KeyiConfig.java b/src/main/java/cc/keyimc/keyi/KeyiConfig.java index 8b9a2f06b0a61cfdd493eeddde512f0abd17f49e..98705c4206906404fed31c87fb03737fe3771b0a 100644 --- a/src/main/java/cc/keyimc/keyi/KeyiConfig.java +++ b/src/main/java/cc/keyimc/keyi/KeyiConfig.java @@ -133,6 +133,16 @@ public final class KeyiConfig { KeyiConfig.init((File) MinecraftServer.getServer().options.valueOf("keyi-settings")); } + public static boolean enableRootUserWarning = true; + public static boolean enableOfflineModeWarning = true; + public static boolean enableProxyUnsafeWarning = true; + + private static void misc() { + enableRootUserWarning = getBoolean("misc.enable-root-user-warning", enableRootUserWarning); + enableOfflineModeWarning = getBoolean("misc.enable-offline-mode-warning", enableOfflineModeWarning); + enableProxyUnsafeWarning = getBoolean("misc.enable-proxy-unsafe-warning", enableProxyUnsafeWarning); + } + // Suki start - only refresh lootables for players public static boolean onlyRefreshForPlayers = false; diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java index bb4e33f0cbc33ffe2fed783fab411564338bd228..7f3d258bc52ba1b1dfc3dd630ef061365198d61f 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -185,7 +185,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } // Paper start - detect running as root - if (io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) { + if (io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin() && cc.keyimc.keyi.KeyiConfig.enableRootUserWarning) { // KeYi start - let user decide if we should warn DedicatedServer.LOGGER.warn("****************************"); DedicatedServer.LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED."); DedicatedServer.LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS."); @@ -330,10 +330,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface // CraftBukkit end if (!this.usesAuthentication()) { - DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); - DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); + // KeYi start - let users choose if we should warn while running in offline mode + if (cc.keyimc.keyi.KeyiConfig.enableOfflineModeWarning) { + DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); + DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); + DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); // KeYi - move up + } + // KeYi end // Spigot start - if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()) { // Purpur + if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && cc.keyimc.keyi.KeyiConfig.enableProxyUnsafeWarning) { // Purpur // KeYi - Let users decide if we should warn while running in proxy mode DedicatedServer.LOGGER.warn("Whilst this makes it possible to use BungeeCord or Velocity, unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose."); // Purpur DedicatedServer.LOGGER.warn("Please see http://www.spigotmc.org/wiki/firewall-guide/ for further information."); } else { @@ -341,7 +346,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface DedicatedServer.LOGGER.warn("You will not be offered any support as long as the server allows offline-mode players to join."); // Purpur } // Spigot end - DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); }