Cleanup Firewall patch

This commit is contained in:
linsaftw 2021-04-30 23:55:15 -03:00
parent 9009c39b3c
commit f2671f0f5d
2 changed files with 15 additions and 14 deletions

View File

@ -1,4 +1,4 @@
From 905138c1dee4cee34aec8e308afd4e596bd211d7 Mon Sep 17 00:00:00 2001
From ca9f27058c584094c899099636c5459df82b7290 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 f0b25b53..3deb8b9a 100644
index f0b25b53..5de0414e 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,10 +323,12 @@ index f0b25b53..3deb8b9a 100644
import java.util.logging.Level;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.connection.CancelSendSignal;
@@ -143,6 +145,23 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
// FlameCord - Use flamecord
final FlameCord flameCord = FlameCord.getInstance();
@@ -140,8 +142,22 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
{
boolean logExceptions = !( handler instanceof PingHandler );
- // FlameCord - Use flamecord
- final FlameCord flameCord = FlameCord.getInstance();
+ // FlameCord - Don't log firewall exceptions
+ logExceptions = cause instanceof FirewallException ? false : logExceptions;
+
@ -335,18 +337,17 @@ index f0b25b53..3deb8b9a 100644
+ final SocketAddress remoteAddress = ctx.channel().remoteAddress();
+
+ if (remoteAddress != null) {
+ flameCord.getFirewallManager().addFirewalled(remoteAddress);
+ FlameCord.getInstance().getFirewallManager().addFirewalled(remoteAddress);
+ }
+ }
+
+ // FlameCord - Handle firewall exceptions
+ if (cause instanceof FirewallException) {
+ flameCord.getFirewallManager().logBlocked(ctx.channel().remoteAddress());
+ FlameCord.getInstance().getFirewallManager().logBlocked(ctx.channel().remoteAddress());
+ }
+
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 1d86aa63..81987ca3 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java

View File

@ -1,6 +1,6 @@
From e874ac159c2697f62a3f00f878ed9140da9ae3a5 Mon Sep 17 00:00:00 2001
From 83d77a25bc63fe25486d0171e7fae3ddc1aa1ab2 Mon Sep 17 00:00:00 2001
From: linsaftw <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 30 Apr 2021 23:42:15 -0300
Date: Fri, 30 Apr 2021 23:51:51 -0300
Subject: [PATCH] FlameCord logger options
@ -50,7 +50,7 @@ index 18bab507..86869e5b 100644
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
index 5de0414e..9f70323e 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
@ -98,8 +98,8 @@ index 3deb8b9a..29d9f5fa 100644
+ // FlameCord - Option to log exceptions
+ logExceptions = FlameCord.getInstance().getFlameCordConfiguration().isLoggerExceptions() ? logExceptions : false;
+
// FlameCord - Use flamecord
final FlameCord flameCord = FlameCord.getInstance();
// FlameCord - Don't log firewall exceptions
logExceptions = cause instanceof FirewallException ? false : logExceptions;
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