2022-07-14 22:04:01 +02:00
|
|
|
From 8dd5f12ca0bc67b8f7ea7257e4a2b1f8c2b4e7f6 Mon Sep 17 00:00:00 2001
|
2021-05-01 04:47:36 +02:00
|
|
|
From: linsaftw <25271111+linsaftw@users.noreply.github.com>
|
2021-05-01 04:55:15 +02:00
|
|
|
Date: Fri, 30 Apr 2021 23:51:51 -0300
|
2021-05-01 04:47:36 +02:00
|
|
|
Subject: [PATCH] FlameCord logger options
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
2022-04-26 15:50:57 +02:00
|
|
|
index c8148e90..c327841a 100644
|
2021-05-01 04:47:36 +02:00
|
|
|
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
|
|
|
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
2022-04-26 15:50:57 +02:00
|
|
|
@@ -12,6 +12,17 @@ import net.md_5.bungee.config.Configuration;
|
2021-05-01 15:24:17 +02:00
|
|
|
import net.md_5.bungee.config.ConfigurationProvider;
|
|
|
|
|
2022-03-06 15:57:48 +01:00
|
|
|
public class FlameCordConfiguration extends FlameConfig {
|
2021-05-01 15:24:17 +02:00
|
|
|
+ @Getter
|
|
|
|
+ private boolean loggerInitialhandler = false;
|
|
|
|
+ @Getter
|
|
|
|
+ private boolean loggerExceptions = false;
|
|
|
|
+ @Getter
|
|
|
|
+ private boolean loggerDump = false;
|
2021-05-01 04:47:36 +02:00
|
|
|
+ @Getter
|
2021-05-01 15:24:17 +02:00
|
|
|
+ private boolean loggerHaProxy = false;
|
2022-04-26 15:50:57 +02:00
|
|
|
+ @Getter
|
|
|
|
+ private boolean loggerDetailedConnection = false;
|
2021-07-20 01:35:26 +02:00
|
|
|
+
|
2022-03-04 17:38:12 +01:00
|
|
|
public FlameCordConfiguration(final ConfigurationProvider configurationProvider) {
|
|
|
|
try {
|
|
|
|
final String fileName = "./flamecord.yml";
|
2022-04-26 15:50:57 +02:00
|
|
|
@@ -25,6 +36,12 @@ public class FlameCordConfiguration extends FlameConfig {
|
2021-05-01 15:24:17 +02:00
|
|
|
configuration = configurationProvider.load(configurationFile);
|
|
|
|
}
|
|
|
|
|
2021-06-09 01:33:36 +02:00
|
|
|
+ this.loggerInitialhandler = setIfUnexistant("logger.initialhandler", this.loggerInitialhandler, configuration);
|
2021-05-01 15:24:17 +02:00
|
|
|
+ this.loggerExceptions = setIfUnexistant("logger.exceptions", this.loggerExceptions, configuration);
|
|
|
|
+ this.loggerDump = setIfUnexistant("logger.dump", this.loggerDump, configuration);
|
2022-04-26 15:50:57 +02:00
|
|
|
+ this.loggerHaProxy = setIfUnexistant("logger.haproxy", this.loggerHaProxy, configuration);
|
|
|
|
+ this.loggerDetailedConnection = setIfUnexistant("logger.detailed-connect-errors", this.loggerDetailedConnection, configuration);
|
2021-06-09 01:33:36 +02:00
|
|
|
+
|
2022-03-06 15:57:48 +01:00
|
|
|
configurationProvider.save(configuration, configurationFile);
|
|
|
|
} catch (final IOException e) {
|
|
|
|
e.printStackTrace();
|
2022-04-26 15:50:57 +02:00
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
2022-07-14 22:04:01 +02:00
|
|
|
index e48f7713..7c0c2fff 100644
|
2022-04-26 15:50:57 +02:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
|
|
@@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
|
|
|
|
import com.google.common.collect.HashMultimap;
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
|
import com.google.common.collect.Multimap;
|
|
|
|
+import dev._2lstudios.flamecord.FlameCord;
|
|
|
|
import io.netty.bootstrap.Bootstrap;
|
|
|
|
import io.netty.channel.Channel;
|
|
|
|
import io.netty.channel.ChannelFuture;
|
2022-06-08 01:38:15 +02:00
|
|
|
@@ -406,7 +407,10 @@ public final class UserConnection implements ProxiedPlayer
|
2022-04-26 15:50:57 +02:00
|
|
|
|
|
|
|
private String connectionFailMessage(Throwable cause)
|
|
|
|
{
|
|
|
|
- bungee.getLogger().log(Level.WARNING, "Error occurred processing connection for " + this.name + " " + Util.exception( cause, false )); // Waterfall
|
|
|
|
+ //FlameCord - Allow for toggle the logging of connection failures
|
|
|
|
+ if(FlameCord.getInstance().getFlameCordConfiguration().isLoggerDetailedConnection()) {
|
|
|
|
+ bungee.getLogger().log(Level.WARNING, "Error occurred processing connection for " + this.name + " " + Util.exception(cause, false)); // Waterfall
|
|
|
|
+ }
|
|
|
|
return ""; // Waterfall
|
|
|
|
}
|
|
|
|
|
2021-05-01 04:47:36 +02:00
|
|
|
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
|
2022-07-14 22:04:01 +02:00
|
|
|
index 3bf47365..af128f0b 100644
|
2021-05-01 04:47:36 +02:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
2022-07-14 22:04:01 +02:00
|
|
|
@@ -392,7 +392,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
2021-05-01 04:47:36 +02:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
// Ping
|
|
|
|
- if ( bungee.getConfig().isLogPings() )
|
|
|
|
+ // FlameCord - Option to log initialhandler
|
|
|
|
+ if ( bungee.getConfig().isLogPings() && FlameCord.getInstance().getFlameCordConfiguration().isLoggerInitialhandler() )
|
|
|
|
{
|
|
|
|
bungee.getLogger().log( Level.INFO, "{0} has pinged", this );
|
|
|
|
}
|
2022-07-14 22:04:01 +02:00
|
|
|
@@ -401,7 +402,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
2021-05-01 04:47:36 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
// Login
|
|
|
|
- if (BungeeCord.getInstance().getConfig().isLogInitialHandlerConnections() ) // Waterfall
|
|
|
|
+ // FlameCord - Option to log initialhandler
|
|
|
|
+ if (BungeeCord.getInstance().getConfig().isLogInitialHandlerConnections() && FlameCord.getInstance().getFlameCordConfiguration().isLoggerInitialhandler() ) // Waterfall
|
|
|
|
{
|
|
|
|
bungee.getLogger().log( Level.INFO, "{0} has connected", this );
|
|
|
|
}
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
|
2022-07-14 22:04:01 +02:00
|
|
|
index 694ecdb0..14e3004f 100644
|
2021-05-01 04:47:36 +02:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
|
2022-03-04 17:38:12 +01:00
|
|
|
@@ -46,7 +46,8 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
|
2021-05-01 04:47:36 +02:00
|
|
|
channel = new ChannelWrapper( ctx );
|
|
|
|
handler.connected( channel );
|
|
|
|
|
|
|
|
- if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) )
|
|
|
|
+ // FlameCord - Option to log initialhandler
|
|
|
|
+ if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) && FlameCord.getInstance().getFlameCordConfiguration().isLoggerInitialhandler() )
|
|
|
|
{
|
|
|
|
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has connected", handler );
|
|
|
|
}
|
2022-03-04 17:38:12 +01:00
|
|
|
@@ -61,7 +62,8 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
|
2021-06-09 01:33:36 +02:00
|
|
|
channel.markClosed();
|
2021-05-01 04:47:36 +02:00
|
|
|
handler.disconnected( channel );
|
|
|
|
|
|
|
|
- if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) )
|
|
|
|
+ // FlameCord - Option to log initialhandler
|
|
|
|
+ if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) && FlameCord.getInstance().getFlameCordConfiguration().isLoggerInitialhandler() )
|
|
|
|
{
|
|
|
|
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has disconnected", handler );
|
|
|
|
}
|
2022-03-04 17:38:12 +01:00
|
|
|
@@ -98,10 +100,12 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
|
2021-07-20 01:35:26 +02:00
|
|
|
{
|
|
|
|
InetSocketAddress newAddress = new InetSocketAddress( proxy.sourceAddress(), proxy.sourcePort() );
|
2021-05-01 04:47:36 +02:00
|
|
|
|
2021-07-20 01:35:26 +02:00
|
|
|
- ProxyServer.getInstance().getLogger().log( Level.FINE, "Set remote address via PROXY {0} -> {1}", new Object[]
|
|
|
|
- {
|
|
|
|
- channel.getRemoteAddress(), newAddress
|
|
|
|
- } );
|
|
|
|
+ // FlameCord - Option to log haproxy
|
|
|
|
+ if ( FlameCord.getInstance().getFlameCordConfiguration().isLoggerHaProxy() )
|
|
|
|
+ ProxyServer.getInstance().getLogger().log( Level.FINE, "Set remote address via PROXY {0} -> {1}", new Object[]
|
|
|
|
+ {
|
|
|
|
+ channel.getRemoteAddress(), newAddress
|
|
|
|
+ } );
|
2021-05-01 04:47:36 +02:00
|
|
|
|
2021-07-20 01:35:26 +02:00
|
|
|
channel.setRemoteAddress( newAddress );
|
|
|
|
}
|
2022-03-04 17:38:12 +01:00
|
|
|
@@ -146,6 +150,9 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
|
2021-05-01 04:47:36 +02:00
|
|
|
{
|
|
|
|
boolean logExceptions = !( handler instanceof PingHandler );
|
|
|
|
|
2022-03-04 17:38:12 +01:00
|
|
|
+ // FlameCord - Option to log exceptions
|
|
|
|
+ logExceptions = FlameCord.getInstance().getFlameCordConfiguration().isLoggerExceptions() ? logExceptions : false;
|
2022-02-14 23:57:35 +01:00
|
|
|
+
|
2021-05-01 18:00:30 +02:00
|
|
|
if ( logExceptions )
|
|
|
|
{
|
|
|
|
if ( cause instanceof ReadTimeoutException )
|
2021-05-01 04:47:36 +02:00
|
|
|
--
|
2022-07-14 22:04:01 +02:00
|
|
|
2.37.0.windows.1
|
2021-05-01 04:47:36 +02:00
|
|
|
|