Waterfall/Waterfall-Proxy-Patches/0029-FlameCord-logger-options.patch

135 lines
7.2 KiB
Diff
Raw Normal View History

2021-05-01 19:19:47 +02:00
From 59dcb230fde16df56f6a30ea041a4c20fb2d2794 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
2021-05-01 18:00:30 +02:00
index 8bb61ac1..8822c6d3 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
2021-05-01 15:24:17 +02:00
@@ -12,6 +12,15 @@ import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration {
+ @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;
+
@Getter
private boolean firewallNotify = true;
2021-05-01 04:47:36 +02:00
@Getter
2021-05-01 15:24:17 +02:00
@@ -34,6 +43,12 @@ public class FlameCordConfiguration {
configuration = configurationProvider.load(configurationFile);
}
+ this.loggerInitialhandler = setIfUnexistant("logger.initialhandler", this.loggerInitialhandler,
+ configuration);
+ this.loggerExceptions = setIfUnexistant("logger.exceptions", this.loggerExceptions, configuration);
+ this.loggerDump = setIfUnexistant("logger.dump", this.loggerDump, configuration);
2021-05-01 04:47:36 +02:00
+ this.loggerHaProxy = setIfUnexistant("logger.haproxy", this.loggerHaProxy, configuration);
2021-05-01 15:24:17 +02:00
+
2021-05-01 04:47:36 +02:00
this.firewallEnabled = setIfUnexistant("firewall.enabled", this.firewallEnabled, configuration);
this.firewallNotify = setIfUnexistant("firewall.notify", this.firewallNotify, configuration);
this.firewallSeconds = setIfUnexistant("firewall.seconds", this.firewallSeconds, configuration);
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
2021-05-01 18:00:30 +02:00
index 3720825a..03c5aa07 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
2021-05-01 16:17:29 +02:00
@@ -370,7 +370,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 );
}
2021-05-01 16:17:29 +02:00
@@ -379,7 +380,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
2021-05-01 18:00:30 +02:00
index 616651ba..7bf30b23 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
2021-05-01 18:00:30 +02:00
@@ -47,7 +47,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 );
}
2021-05-01 18:00:30 +02:00
@@ -63,7 +64,8 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
2021-05-01 04:47:36 +02:00
channel.close();
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 );
}
2021-05-01 18:00:30 +02:00
@@ -94,10 +96,13 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
2021-05-01 04:47:36 +02:00
{
InetSocketAddress newAddress = new InetSocketAddress( proxy.sourceAddress(), proxy.sourcePort() );
- 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
+ } );
+ }
channel.setRemoteAddress( newAddress );
} finally
2021-05-01 18:00:30 +02:00
@@ -141,6 +146,9 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
2021-05-01 04:47:36 +02:00
{
boolean logExceptions = !( handler instanceof PingHandler );
+ // FlameCord - Option to log exceptions
+ logExceptions = FlameCord.getInstance().getFlameCordConfiguration().isLoggerExceptions() ? logExceptions : false;
+
2021-05-01 18:00:30 +02:00
if ( logExceptions )
{
if ( cause instanceof ReadTimeoutException )
2021-05-01 04:47:36 +02:00
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
2021-05-01 18:00:30 +02:00
index 915c162f..a6722b41 100644
2021-05-01 04:47:36 +02:00
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
2021-05-01 18:00:30 +02:00
@@ -116,7 +116,10 @@ public class PipelineUtils
2021-05-01 04:47:36 +02:00
// FlameCord - Close on exception caught
@Override
public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
- cause.printStackTrace();
+ // FlameCord - Option to log exceptions
+ if (FlameCord.getInstance().getFlameCordConfiguration().isLoggerExceptions()) {
+ cause.printStackTrace();
+ }
ctx.close();
}
--
2.31.1