Waterfall/BungeeCord-Patches/0046-Optionally-log-InitialHandler-connections.patch
2018-07-22 17:45:31 +01:00

79 lines
3.5 KiB
Diff

From 2d00fa974c95d7e2cffaebfe40f937b41883f5c7 Mon Sep 17 00:00:00 2001
From: Gabriele C <sgdc3.mail@gmail.com>
Date: Thu, 8 Feb 2018 19:10:52 +0100
Subject: [PATCH] Optionally log InitialHandler connections
diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
index 6187d6f0..8a9c3c17 100644
--- a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
+++ b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
@@ -163,6 +163,11 @@ public interface ProxyConfig
*/
boolean isLogServerListPing();
+ /**
+ * Whether we log InitialHandler connections
+ */
+ boolean isLogInitialHandlerConnections();
+
/**
* The supported versions
*/
diff --git a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
index 5c92768a..090c550b 100644
--- a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
@@ -16,6 +16,13 @@ public class WaterfallConfiguration extends Configuration {
*/
private boolean logServerListPing = false;
+ /**
+ * Whether we log InitialHandler connections
+ * <p>
+ * Default is true
+ */
+ private boolean logInitialHandlerConnections = true;
+
/**
* The supported versions displayed to the client
* <p>Default is a comma separated list of supported versions. For example 1.8.x, 1.9.x, 1.10.x</p>
@@ -47,6 +54,7 @@ public class WaterfallConfiguration extends Configuration {
YamlConfig config = new YamlConfig(new File("waterfall.yml"));
config.load(false); // Load, but no permissions
logServerListPing = config.getBoolean( "log_server_list_ping", logServerListPing );
+ logInitialHandlerConnections = config.getBoolean( "log_initial_handler_connections", logInitialHandlerConnections );
gameVersion = config.getString("game_version", "").isEmpty() ? Joiner.on(", ").join(ProtocolConstants.SUPPORTED_VERSIONS) : config.getString("game_version", "");
useNettyDnsResolver = config.getBoolean("use_netty_dns_resolver", useNettyDnsResolver);
// Throttling options
@@ -58,6 +66,11 @@ public class WaterfallConfiguration extends Configuration {
return logServerListPing;
}
+ @Override
+ public boolean isLogInitialHandlerConnections() {
+ return logInitialHandlerConnections;
+ }
+
@Override
public String getGameVersion() {
return gameVersion;
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
index 2347654c..c6e109c5 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
@@ -312,7 +312,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection
break;
case 2:
// Login
- bungee.getLogger().log( Level.INFO, "{0} has connected", this );
+ if (BungeeCord.getInstance().getConfig().isLogInitialHandlerConnections()) {
+ bungee.getLogger().log( Level.INFO, "{0} has connected", this );
+ }
thisState = State.USERNAME;
ch.setProtocol( Protocol.LOGIN );
--
2.18.0