Partly splitted logger options

This commit is contained in:
linsaftw 2021-04-30 23:47:36 -03:00
parent 135369e4b4
commit 09e30b5744
3 changed files with 133 additions and 65 deletions

View File

@ -1,4 +1,4 @@
From b13fd1a5fea303546f2c3ae160889d8cf7c88667 Mon Sep 17 00:00:00 2001
From a60eb8a4096cfa24f46b4747774218fdb36751f0 Mon Sep 17 00:00:00 2001
From: Juan Cruz Linsalata <LinsaFTW@users.noreply.github.com>
Date: Mon, 12 Oct 2020 15:40:53 -0300
Subject: [PATCH] FlameCord General Patch
@ -666,7 +666,7 @@ index 159119c1..7c4c8f8a 100644
b.connect().addListener( listener );
}
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 e7542b1c..64861313 100644
index e7542b1c..18bab507 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
@@ -16,6 +16,8 @@ import java.util.logging.Level;
@ -696,26 +696,6 @@ index e7542b1c..64861313 100644
}
}
@@ -365,7 +369,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{
case 1:
// Ping
- if ( bungee.getConfig().isLogPings() )
+ // FlameCord - Toggle for initialhandler logger
+ if ( bungee.getConfig().isLogPings() && FlameCord.getInstance().getFlameCordConfiguration().isLoggerInitialhandler() )
{
bungee.getLogger().log( Level.INFO, "{0} has pinged", this );
}
@@ -374,7 +379,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
break;
case 2:
// Login
- if (BungeeCord.getInstance().getConfig().isLogInitialHandlerConnections() ) // Waterfall
+ // FlameCord - Toggle for initialhandler logger
+ 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/connection/PingHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
index 6cd71071..24195ed1 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
@ -748,7 +728,7 @@ index 6cd71071..24195ed1 100644
}
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
index b8e50855..e4208b59 100644
index b8e50855..f0b25b53 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
@@ -1,6 +1,8 @@
@ -760,41 +740,18 @@ index b8e50855..e4208b59 100644
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.CorruptedFrameException;
@@ -44,7 +46,8 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
channel = new ChannelWrapper( ctx );
handler.connected( channel );
- if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) )
+ // FlameCord - Added isLoggerInitialhandler boolean
+ if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) && FlameCord.getInstance().getFlameCordConfiguration().isLoggerInitialhandler() )
{
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has connected", handler );
}
@@ -60,7 +63,8 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
channel.close();
handler.disconnected( channel );
- if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) )
+ // FlameCord - Added isLoggerInitialhandler boolean
+ if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) && FlameCord.getInstance().getFlameCordConfiguration().isLoggerInitialhandler() )
{
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has disconnected", handler );
}
@@ -138,6 +142,12 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
@@ -138,6 +140,9 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
{
boolean logExceptions = !( handler instanceof PingHandler );
+ // FlameCord - Use flamecord
+ final FlameCord flameCord = FlameCord.getInstance();
+
+ // FlameCord - Log exceptions based on FlameCord
+ logExceptions = flameCord.getFlameCordConfiguration().isLoggerExceptions();
+
if ( logExceptions )
{
if ( cause instanceof ReadTimeoutException )
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
index 4996a7b4..d9d00fa5 100644
index 4996a7b4..1d86aa63 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
@@ -1,6 +1,8 @@
@ -806,17 +763,6 @@ index 4996a7b4..d9d00fa5 100644
import io.github.waterfallmc.waterfall.event.ConnectionInitEvent;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.channel.Channel;
@@ -107,7 +109,9 @@ public class PipelineUtils
// FlameCord - Close on exception caught
@Override
public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
- cause.printStackTrace();
+ if (FlameCord.getInstance().getFlameCordConfiguration().isLoggerExceptions()) {
+ cause.printStackTrace();
+ }
ctx.close();
}
--
2.31.1

View File

@ -1,4 +1,4 @@
From 9e823cf6478f0b35c293a90ca846f00ba51142da Mon Sep 17 00:00:00 2001
From 905138c1dee4cee34aec8e308afd4e596bd211d7 Mon Sep 17 00:00:00 2001
From: linsaftw <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 30 Apr 2021 22:54:44 -0300
Subject: [PATCH] Firewall System
@ -304,7 +304,7 @@ index bf6f8538..fa0b59c2 100644
// FlameCord - Collect ips from servers
final Collection<String> whitelistedAddresses = new HashSet<>();
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
index e4208b59..3b5bb7db 100644
index f0b25b53..3deb8b9a 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
@@ -3,6 +3,7 @@ package net.md_5.bungee.netty;
@ -323,9 +323,9 @@ index e4208b59..3b5bb7db 100644
import java.util.logging.Level;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.connection.CancelSendSignal;
@@ -148,6 +150,23 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
// FlameCord - Log exceptions based on FlameCord
logExceptions = flameCord.getFlameCordConfiguration().isLoggerExceptions();
@@ -143,6 +145,23 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
// FlameCord - Use flamecord
final FlameCord flameCord = FlameCord.getInstance();
+ // FlameCord - Don't log firewall exceptions
+ logExceptions = cause instanceof FirewallException ? false : logExceptions;
@ -348,7 +348,7 @@ index e4208b59..3b5bb7db 100644
{
if ( cause instanceof ReadTimeoutException )
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
index d9d00fa5..fa6ab3e9 100644
index 1d86aa63..81987ca3 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
@@ -3,6 +3,7 @@ package net.md_5.bungee.netty;

View File

@ -0,0 +1,122 @@
From e874ac159c2697f62a3f00f878ed9140da9ae3a5 Mon Sep 17 00:00:00 2001
From: linsaftw <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 30 Apr 2021 23:42:15 -0300
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
index b7268e1d..ea641bcf 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -16,6 +16,8 @@ public class FlameCordConfiguration {
private boolean loggerInitialhandler = false, loggerExceptions = false, loggerDump = false, firewallNotify = true,
firewallEnabled = true;
@Getter
+ private boolean loggerHaProxy = false;
+ @Getter
private int firewallSeconds = 60;
@Getter
private Collection<String> firewallNames = new HashSet<>(Arrays.asList(new String[] { "mcspam" }));
@@ -37,6 +39,7 @@ public class FlameCordConfiguration {
configuration);
this.loggerExceptions = setIfUnexistant("logger.exceptions", this.loggerExceptions, configuration);
this.loggerDump = setIfUnexistant("logger.dump", this.loggerDump, configuration);
+ this.loggerHaProxy = setIfUnexistant("logger.haproxy", this.loggerHaProxy, configuration);
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
index 18bab507..86869e5b 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
@@ -369,7 +369,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{
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 );
}
@@ -378,7 +379,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
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
index 3deb8b9a..29d9f5fa 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
@@ -48,7 +48,8 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
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 );
}
@@ -64,7 +65,8 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
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 );
}
@@ -95,10 +97,13 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
{
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
@@ -142,6 +147,9 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
{
boolean logExceptions = !( handler instanceof PingHandler );
+ // FlameCord - Option to log exceptions
+ logExceptions = FlameCord.getInstance().getFlameCordConfiguration().isLoggerExceptions() ? logExceptions : false;
+
// FlameCord - Use flamecord
final FlameCord flameCord = FlameCord.getInstance();
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
index 81987ca3..8808a989 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
@@ -115,7 +115,10 @@ public class PipelineUtils
// 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