2013-06-02 13:15:15 +08:00
From c1f139d1b8556e177e82a4af5427668e932bacb1 Mon Sep 17 00:00:00 2001
2013-04-23 09:27:55 +08: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-04-25 07:58:55 +08:00
index 0686ba0..fcd4136 100644
2013-04-23 09:27:55 +08: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-04-25 07:58:55 +08:00
+ if (org.bukkit.craftbukkit.Spigot.filterIp(pendingConnection)) return; // Spigot
2013-04-23 09:27:55 +08: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()));
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
2013-04-25 07:58:55 +08:00
index 2cd806e..fd90979 100644
2013-04-23 09:27:55 +08:00
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
2013-04-25 07:58:55 +08:00
@@ -1,19 +1,49 @@
2013-04-23 09:27:55 +08:00
package org.bukkit.craftbukkit;
+import java.net.InetAddress;
+import net.minecraft.server.PendingConnection;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.configuration.file.YamlConfiguration;
public class Spigot {
+ private static boolean filterIps;
+
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
server.whitelistMessage = configuration.getString("settings.whitelist-message", server.whitelistMessage);
server.stopMessage = configuration.getString("settings.stop-message", server.stopMessage);
server.logCommands = configuration.getBoolean("settings.log-commands", true);
server.commandComplete = configuration.getBoolean("settings.command-complete", true);
server.spamGuardExclusions = configuration.getStringList("settings.spam-exclusions");
+ filterIps = configuration.getBoolean("settings.filter-unsafe-ips", false);
if (server.chunkGCPeriod == 0) {
server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!");
}
}
+
2013-04-25 07:58:55 +08:00
+ public static boolean filterIp(PendingConnection con) {
2013-04-23 09:27:55 +08:00
+ if (filterIps) {
+ 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");
2013-04-25 07:58:55 +08:00
+ return true;
2013-04-23 09:27:55 +08:00
+ }
+ }
+ } catch (Exception ex) {
+ }
+ }
2013-04-25 07:58:55 +08:00
+ return false;
2013-04-23 09:27:55 +08:00
+ }
}
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index f2ce75e..b7c0376 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -30,6 +30,7 @@ settings:
command-complete: true
spam-exclusions:
- /skill
+ filter-unsafe-ips: false
world-settings:
default:
growth-chunks-per-tick: 650
--
2013-06-02 13:15:15 +08:00
1.8.1.2
2013-04-23 09:27:55 +08:00