2013-06-21 09:30:13 +02:00
From 7b5dea06abdd8821b9eae340a8168cfb47ef43d8 Mon Sep 17 00:00:00 2001
2013-04-23 03:27:55 +02:00
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
2013-06-20 10:41:59 +02:00
index 0686ba0..1254e63 100644
2013-04-23 03:27:55 +02:00
--- 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 {
2013-06-20 10:41:59 +02:00
+ if (org.spigotmc.SpamHaus.filterIp(pendingConnection)) return; // Spigot
2013-04-23 03:27:55 +02:00
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()));
2013-06-20 10:41:59 +02:00
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;
+
2013-04-23 03:27:55 +02:00
+import java.net.InetAddress;
+import net.minecraft.server.PendingConnection;
+
2013-06-20 10:41:59 +02:00
+public class SpamHaus
+{
2013-04-23 03:27:55 +02:00
+
2013-06-20 10:41:59 +02:00
+ private SpamHaus()
+ {
+ }
+
+ public static boolean filterIp(PendingConnection con)
+ {
+ if ( SpigotConfig.preventProxies )
+ {
+ try
+ {
2013-04-23 03:27:55 +02:00
+ InetAddress address = con.getSocket().getInetAddress();
+ String ip = address.getHostAddress();
+
2013-06-20 10:41:59 +02:00
+ if ( !address.isLoopbackAddress() )
+ {
+ String[] split = ip.split( "\\." );
2013-04-23 03:27:55 +02:00
+ StringBuilder lookup = new StringBuilder();
2013-06-20 10:41:59 +02:00
+ for ( int i = split.length - 1; i >= 0; i-- )
+ {
+ lookup.append( split[i] );
+ lookup.append( "." );
2013-04-23 03:27:55 +02:00
+ }
2013-06-20 10:41:59 +02:00
+ 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" );
2013-04-25 01:58:55 +02:00
+ return true;
2013-04-23 03:27:55 +02:00
+ }
+ }
2013-06-20 10:41:59 +02:00
+ } catch ( Exception ex )
+ {
2013-04-23 03:27:55 +02:00
+ }
+ }
2013-04-25 01:58:55 +02:00
+ return false;
2013-06-20 10:41:59 +02:00
+ }
+}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
2013-06-21 09:30:13 +02:00
index bf297bc..342d883 100644
2013-06-20 10:41:59 +02:00
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
2013-06-21 09:30:13 +02:00
@@ -95,4 +95,10 @@ public class SpigotConfig
config.addDefault( path, def );
return config.getString( path, config.getString( path ) );
2013-06-20 10:41:59 +02:00
}
+
2013-06-21 09:30:13 +02:00
+ public static boolean preventProxies;
2013-06-20 10:41:59 +02:00
+ private static void preventProxies()
+ {
2013-06-21 09:30:13 +02:00
+ preventProxies = getBoolean( "settings.prevent-proxies", false );
2013-04-23 03:27:55 +02:00
+ }
}
--
2013-06-02 07:15:15 +02:00
1.8.1.2
2013-04-23 03:27:55 +02:00