mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-11-16 23:35:22 +01:00
Use external services for proxy check
This commit is contained in:
parent
6dc9dd1956
commit
24a60ab157
@ -1,4 +1,4 @@
|
||||
From 3e15de1f48767b39db352670c7f987334de4ab75 Mon Sep 17 00:00:00 2001
|
||||
From 0f74c662fa03c20ad745a5b6b70a92e1125fdf02 Mon Sep 17 00:00:00 2001
|
||||
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
|
||||
Date: Fri, 4 Mar 2022 13:35:53 -0300
|
||||
Subject: [PATCH] Antibot System
|
||||
@ -1095,10 +1095,10 @@ index 00000000..68555de3
|
||||
+}
|
||||
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/ProxyCheck.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/ProxyCheck.java
|
||||
new file mode 100644
|
||||
index 00000000..ef64fd8c
|
||||
index 00000000..a387a473
|
||||
--- /dev/null
|
||||
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/ProxyCheck.java
|
||||
@@ -0,0 +1,103 @@
|
||||
@@ -0,0 +1,157 @@
|
||||
+package dev._2lstudios.flamecord.antibot;
|
||||
+
|
||||
+import java.io.BufferedReader;
|
||||
@ -1132,7 +1132,8 @@ index 00000000..ef64fd8c
|
||||
+ };
|
||||
+
|
||||
+ // send updating proxies message
|
||||
+ FlameCord.getInstance().getLoggerWrapper().getLogger().info("Updating proxy database from " + websites.length + " websites...");
|
||||
+ FlameCord.getInstance().getLoggerWrapper().getLogger()
|
||||
+ .info("Updating proxy database from " + websites.length + " websites...");
|
||||
+
|
||||
+ // create a string builder to store the content
|
||||
+ StringBuilder content = new StringBuilder();
|
||||
@ -1185,22 +1186,75 @@ index 00000000..ef64fd8c
|
||||
+ }
|
||||
+
|
||||
+ public boolean check(SocketAddress address) {
|
||||
+ if (!config.isAntibotProxyEnabled()) return false;
|
||||
+ if (!config.isAntibotProxyEnabled())
|
||||
+ return false;
|
||||
+
|
||||
+ AddressData addressData = addressDataManager.getAddressData(address);
|
||||
+ String ip = addressData.getHostString();
|
||||
+
|
||||
+ // Check if it's a proxy
|
||||
+ if (!proxies.equals("") && proxies.contains(ip)) {
|
||||
+ if ((!proxies.equals("") && proxies.contains(ip)) || isVPN(ip)) {
|
||||
+ if (config.isAntibotProxyLog()) {
|
||||
+ logger.log(Level.INFO, "[FlameCord] [{0}] was blocked for using a VPN/Proxy service", address);
|
||||
+ }
|
||||
+
|
||||
+ if (config.isAntibotProxyFirewall()) {
|
||||
+ addressData.firewall("Using VPN/proxy services");
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // Method to check if an IP address is a VPN using getipintel API
|
||||
+ public boolean isVPN(String ip) {
|
||||
+ try {
|
||||
+ // Create a URL object with the API endpoint and the IP parameter
|
||||
+ URL url = new URL("https://check.getipintel.net/check.php?ip=" + ip + "&contact=linsaftw@gmail.com");
|
||||
+
|
||||
+ // Open a connection to the URL
|
||||
+ HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
+
|
||||
+ // Set the request method to GET
|
||||
+ con.setRequestMethod("GET");
|
||||
+
|
||||
+ // Get the response code
|
||||
+ int responseCode = con.getResponseCode();
|
||||
+
|
||||
+ // If the response code is 200 (OK), read the input stream
|
||||
+ if (responseCode == 200) {
|
||||
+ // Read the response from the input stream
|
||||
+ BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
+ String line;
|
||||
+ StringBuilder response = new StringBuilder();
|
||||
+
|
||||
+ while ((line = in.readLine()) != null) {
|
||||
+ response.append(line);
|
||||
+ }
|
||||
+ in.close();
|
||||
+
|
||||
+ // Parse the response as a double
|
||||
+ double result = Double.parseDouble(response.toString());
|
||||
+
|
||||
+ // If the result is greater than 0.99, it is a VPN
|
||||
+ if (result > 0.99) {
|
||||
+ System.out.println("5");
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ System.out.println("4");
|
||||
+ return false;
|
||||
+ }
|
||||
+ } else {
|
||||
+ System.out.println("2");
|
||||
+ return false;
|
||||
+ }
|
||||
+ } catch (Exception e) {
|
||||
+ System.out.println("1");
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/RatelimitCheck.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/antibot/RatelimitCheck.java
|
||||
new file mode 100644
|
||||
@ -1401,10 +1455,10 @@ index 00000000..44d773ab
|
||||
+ }
|
||||
+}
|
||||
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 14665b1f..9d095964 100644
|
||||
index 14665b1f..9e34075d 100644
|
||||
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||
@@ -15,6 +15,197 @@ import net.md_5.bungee.config.Configuration;
|
||||
@@ -15,6 +15,200 @@ import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
|
||||
public class FlameCordConfiguration extends FlameConfig {
|
||||
@ -1525,6 +1579,8 @@ index 14665b1f..9d095964 100644
|
||||
+ private boolean antibotProxyEnabled = true;
|
||||
+ @Getter
|
||||
+ private boolean antibotProxyLog = true;
|
||||
+ @Getter
|
||||
+ private boolean antibotProxyFirewall = true;
|
||||
+
|
||||
+ public void loadAntibot(final Configuration config, final Collection<String> whitelistedAddresses) {
|
||||
+ // Antibot accounts
|
||||
@ -1597,12 +1653,13 @@ index 14665b1f..9d095964 100644
|
||||
+ // Antibot-proxy
|
||||
+ this.antibotProxyEnabled = setIfUnexistant("antibot.proxy.enabled", this.antibotProxyEnabled, config);
|
||||
+ this.antibotProxyLog = setIfUnexistant("antibot.proxy.log", this.antibotProxyLog, config);
|
||||
+ this.antibotProxyFirewall = setIfUnexistant("antibot.proxy.firewall", this.antibotProxyFirewall, config);
|
||||
+ }
|
||||
+
|
||||
// FlameCord - TCP Fast Open
|
||||
@Getter
|
||||
private int tcpFastOpen = 3;
|
||||
@@ -132,6 +323,9 @@ public class FlameCordConfiguration extends FlameConfig {
|
||||
@@ -132,6 +326,9 @@ public class FlameCordConfiguration extends FlameConfig {
|
||||
this.fakePlayersMode = setIfUnexistant("custom-motd.fakeplayers.mode", this.fakePlayersMode, configuration);
|
||||
|
||||
this.tcpFastOpen = setIfUnexistant("tcp-fast-open", this.tcpFastOpen, configuration);
|
||||
@ -1840,7 +1897,7 @@ index fb81adee..173b47f3 100644
|
||||
}
|
||||
}
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
index 6d798917..23d89781 100644
|
||||
index bf126c81..0a75abc3 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
@@ -533,6 +533,11 @@ public class BungeeCord extends ProxyServer
|
||||
@ -1856,7 +1913,7 @@ index 6d798917..23d89781 100644
|
||||
// Need to close loggers after last message!
|
||||
org.apache.logging.log4j.LogManager.shutdown(); // Waterfall
|
||||
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 d65884ae..8d7bb6bf 100644
|
||||
index d65884ae..e76c0284 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
|
||||
@@ -22,8 +22,8 @@ import javax.crypto.SecretKey;
|
||||
@ -1893,25 +1950,19 @@ index d65884ae..8d7bb6bf 100644
|
||||
this.handshake = handshake;
|
||||
ch.setVersion( handshake.getProtocolVersion() );
|
||||
ch.getHandle().pipeline().remove( PipelineUtils.LEGACY_KICKER );
|
||||
@@ -442,6 +458,17 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@@ -442,6 +458,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
return;
|
||||
}
|
||||
|
||||
+ // FlameCord start - Antibot System
|
||||
+ AddressData addressData = FlameCord.getInstance().getAddressDataManager().getAddressData( ch.getRemoteAddress() );
|
||||
+ CheckManager checkManager = FlameCord.getInstance().getCheckManager();
|
||||
+
|
||||
+ if ( checkManager.getProxyCheck().check( ch.getRemoteAddress() ) )
|
||||
+ {
|
||||
+ disconnect( bungee.getTranslation( "antibot_proxy" ) );
|
||||
+ return;
|
||||
+ }
|
||||
+ // FlameCord end - Antibot System
|
||||
+
|
||||
switch ( handshake.getRequestedProtocol() )
|
||||
{
|
||||
case 1:
|
||||
@@ -453,6 +480,17 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@@ -453,6 +474,17 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
}
|
||||
thisState = State.STATUS;
|
||||
ch.setProtocol( Protocol.STATUS );
|
||||
@ -1929,7 +1980,7 @@ index d65884ae..8d7bb6bf 100644
|
||||
break;
|
||||
case 2:
|
||||
// Login
|
||||
@@ -464,6 +502,16 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@@ -464,6 +496,22 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
thisState = State.USERNAME;
|
||||
ch.setProtocol( Protocol.LOGIN );
|
||||
|
||||
@ -1941,6 +1992,12 @@ index d65884ae..8d7bb6bf 100644
|
||||
+ disconnect( bungee.getTranslation( "antibot_ratelimit", addressData.getConnectionsSecond() ) );
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if ( checkManager.getProxyCheck().check( ch.getRemoteAddress() ) )
|
||||
+ {
|
||||
+ disconnect( bungee.getTranslation( "antibot_proxy" ) );
|
||||
+ return;
|
||||
+ }
|
||||
+ // FlameCord end - Antibot System
|
||||
+
|
||||
if ( !ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) )
|
||||
|
@ -1,11 +1,11 @@
|
||||
From 66097efeee329a42b72bf50e458ad8eb090334c2 Mon Sep 17 00:00:00 2001
|
||||
From 824fd89885d7acaa5957fef782ec33517baf7dab Mon Sep 17 00:00:00 2001
|
||||
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
|
||||
Date: Fri, 4 Mar 2022 14:09:35 -0300
|
||||
Subject: [PATCH] Allow Invalid Names
|
||||
|
||||
|
||||
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 9d095964..996d94ea 100644
|
||||
index 9e34075d..b34daed7 100644
|
||||
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||
@@ -15,6 +15,10 @@ import net.md_5.bungee.config.Configuration;
|
||||
@ -19,7 +19,7 @@ index 9d095964..996d94ea 100644
|
||||
// Antibot accounts
|
||||
@Getter
|
||||
private boolean antibotAccountsEnabled = true;
|
||||
@@ -327,6 +331,9 @@ public class FlameCordConfiguration extends FlameConfig {
|
||||
@@ -330,6 +334,9 @@ public class FlameCordConfiguration extends FlameConfig {
|
||||
// FlameCord - Antibot System
|
||||
loadAntibot(configuration, whitelistedAddresses);
|
||||
|
||||
@ -30,7 +30,7 @@ index 9d095964..996d94ea 100644
|
||||
}
|
||||
}
|
||||
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 8d7bb6bf..95f0e52c 100644
|
||||
index e76c0284..bdef72db 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
|
||||
@@ -534,7 +534,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
|
@ -1,11 +1,11 @@
|
||||
From 63c29065199a914dad97bfeed9c8ded1ee8ff340 Mon Sep 17 00:00:00 2001
|
||||
From d6f0cb1c437b43d272932b3c2f457921d9282b4e Mon Sep 17 00:00:00 2001
|
||||
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
|
||||
Date: Sun, 22 Jan 2023 09:41:36 -0300
|
||||
Subject: [PATCH] InitialHandler Processing State
|
||||
|
||||
|
||||
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 d2406a7e..348a91b2 100644
|
||||
index cf390c5f..c96f9da8 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
|
||||
@@ -135,6 +135,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@ -64,7 +64,7 @@ index d2406a7e..348a91b2 100644
|
||||
// FlameCord start - Antibot System
|
||||
// Close and firewall on invalid protocol
|
||||
int protocol = handshake.getRequestedProtocol();
|
||||
@@ -491,6 +510,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@@ -485,6 +504,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
}
|
||||
// FlameCord end - Antibot System
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
From 97c2f1c36b9e83d5a75c673d9265c4caa9ef3555 Mon Sep 17 00:00:00 2001
|
||||
From d303d32c4a69eb36d79d5457411ab60da98416ad Mon Sep 17 00:00:00 2001
|
||||
From: xIsm4 <soportexism4@gmail.com>
|
||||
Date: Fri, 27 Jan 2023 14:12:44 +0100
|
||||
Subject: [PATCH] Implement libdeflate
|
||||
|
||||
|
||||
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 996d94ea..05321f0e 100644
|
||||
index b34daed7..4e9f4dc4 100644
|
||||
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||
@@ -59,6 +59,8 @@ public class FlameCordConfiguration extends FlameConfig {
|
||||
@ -17,7 +17,7 @@ index 996d94ea..05321f0e 100644
|
||||
private boolean antibotFirewallLog = true;
|
||||
@Getter
|
||||
private boolean antibotFirewallIpset = true;
|
||||
@@ -334,6 +336,9 @@ public class FlameCordConfiguration extends FlameConfig {
|
||||
@@ -337,6 +339,9 @@ public class FlameCordConfiguration extends FlameConfig {
|
||||
// FlameCord - Allow Invalid Names
|
||||
this.allowInvalidNames = setIfUnexistant("allow-invalid-names", this.allowInvalidNames, configuration);
|
||||
|
||||
@ -2118,7 +2118,7 @@ index 02625018..37abc9f7 100644
|
||||
<groupId>io.github.waterfallmc</groupId>
|
||||
<artifactId>waterfall-module-cmd-alert</artifactId>
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
index 63ba56f4..a9fb2388 100644
|
||||
index a59dfab3..be6a0d63 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
@@ -17,6 +17,7 @@ import dev._2lstudios.flamecord.commands.FlameCordCommand;
|
||||
|
Loading…
Reference in New Issue
Block a user