Check firewall only once

This commit is contained in:
linsaftw 2021-04-30 19:58:48 -03:00
parent a93d1293a4
commit cb818c0ceb

View File

@ -1,4 +1,4 @@
From 59870243f92af6df6734c1860ee0038b2205b1ec Mon Sep 17 00:00:00 2001
From e6ce50df78087e26000d0d99f2f5a51b7334b93c Mon Sep 17 00:00:00 2001
From: linsaftw <linsaftw@users.noreply.github.com>
Date: Fri, 30 Apr 2021 19:23:36 -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 d3a89e79..e56b4c68 100644
index d3a89e79..60c9ddcd 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,21 +323,7 @@ index d3a89e79..e56b4c68 100644
import java.util.logging.Level;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.connection.CancelSendSignal;
@@ -41,6 +43,13 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception
{
+ // FlameCord - Firewall system
+ final SocketAddress remoteAddress = ctx.channel().remoteAddress();
+
+ if (remoteAddress != null && FlameCord.getInstance().getFirewallManager().isFirewalled(remoteAddress)) {
+ throw new FirewallException(remoteAddress);
+ }
+
if ( handler != null )
{
channel = new ChannelWrapper( ctx );
@@ -143,7 +152,21 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
@@ -143,7 +145,21 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
// FlameCord - Use flamecord
final FlameCord flameCord = FlameCord.getInstance();
// FlameCord - Log exceptions based on FlameCord