mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-21 07:09:21 +08:00
87 lines
3.3 KiB
Diff
87 lines
3.3 KiB
Diff
From a26c2eedc264aed6e095e02b5db0e497e7efccee Mon Sep 17 00:00:00 2001
|
|
From: md_5 <md_5@live.com.au>
|
|
Date: Tue, 23 Apr 2013 11:22:07 +1000
|
|
Subject: [PATCH] Proxy IP Filter
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
|
|
index 0686ba0..1254e63 100644
|
|
--- a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
|
|
+++ b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
|
|
@@ -28,6 +28,7 @@ class ThreadLoginVerifier extends Thread {
|
|
|
|
public void run() {
|
|
try {
|
|
+ if (org.spigotmc.SpamHaus.filterIp(pendingConnection)) return; // Spigot
|
|
String s = (new BigInteger(MinecraftEncryption.a(PendingConnection.a(this.pendingConnection), PendingConnection.b(this.pendingConnection).F().getPublic(), PendingConnection.c(this.pendingConnection)))).toString(16);
|
|
URL url = new URL("http://session.minecraft.net/game/checkserver.jsp?user=" + URLEncoder.encode(PendingConnection.d(this.pendingConnection), "UTF-8") + "&serverId=" + URLEncoder.encode(s, "UTF-8"));
|
|
BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(url.openStream()));
|
|
diff --git a/src/main/java/org/spigotmc/SpamHaus.java b/src/main/java/org/spigotmc/SpamHaus.java
|
|
new file mode 100644
|
|
index 0000000..55d8d12
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/spigotmc/SpamHaus.java
|
|
@@ -0,0 +1,44 @@
|
|
+package org.spigotmc;
|
|
+
|
|
+import java.net.InetAddress;
|
|
+import net.minecraft.server.PendingConnection;
|
|
+
|
|
+public class SpamHaus
|
|
+{
|
|
+
|
|
+ private SpamHaus()
|
|
+ {
|
|
+ }
|
|
+
|
|
+ public static boolean filterIp(PendingConnection con)
|
|
+ {
|
|
+ if ( SpigotConfig.preventProxies )
|
|
+ {
|
|
+ try
|
|
+ {
|
|
+ InetAddress address = con.getSocket().getInetAddress();
|
|
+ String ip = address.getHostAddress();
|
|
+
|
|
+ if ( !address.isLoopbackAddress() )
|
|
+ {
|
|
+ String[] split = ip.split( "\\." );
|
|
+ StringBuilder lookup = new StringBuilder();
|
|
+ for ( int i = split.length - 1; i >= 0; i-- )
|
|
+ {
|
|
+ lookup.append( split[i] );
|
|
+ lookup.append( "." );
|
|
+ }
|
|
+ lookup.append( "xbl.spamhaus.org." );
|
|
+ if ( InetAddress.getByName( lookup.toString() ) != null )
|
|
+ {
|
|
+ con.disconnect( "Your IP address (" + ip + ") is flagged as unsafe by spamhaus.org/xbl" );
|
|
+ return true;
|
|
+ }
|
|
+ }
|
|
+ } catch ( Exception ex )
|
|
+ {
|
|
+ }
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
index 933500d..cbd05af 100644
|
|
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
|
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
@@ -110,4 +110,10 @@ public class SpigotConfig
|
|
config.addDefault( path, def );
|
|
return config.getString( path, config.getString( path ) );
|
|
}
|
|
+
|
|
+ public static boolean preventProxies;
|
|
+ private static void preventProxies()
|
|
+ {
|
|
+ preventProxies = getBoolean( "settings.prevent-proxies", false );
|
|
+ }
|
|
}
|
|
--
|
|
1.8.1.2
|
|
|