13
0
geforkt von Mirrors/Paper

Added configurable Connection Throttle. Addresses BUKKIT-1274

Dieser Commit ist enthalten in:
EvilSeph 2012-03-22 08:03:24 -04:00
Ursprung dda37aa18c
Commit c2cdeac09b
3 geänderte Dateien mit 9 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -10,6 +10,8 @@ class NetworkAcceptThread extends Thread {
final NetworkListenThread listenThread; final NetworkListenThread listenThread;
long connectionThrottle; // CraftBukkit
NetworkAcceptThread(NetworkListenThread networklistenthread, String s, MinecraftServer minecraftserver) { NetworkAcceptThread(NetworkListenThread networklistenthread, String s, MinecraftServer minecraftserver) {
super(s); super(s);
this.listenThread = networklistenthread; this.listenThread = networklistenthread;
@ -24,9 +26,10 @@ class NetworkAcceptThread extends Thread {
if (socket != null) { if (socket != null) {
synchronized (NetworkListenThread.getRecentConnectionAttempts(this.listenThread)) { synchronized (NetworkListenThread.getRecentConnectionAttempts(this.listenThread)) {
InetAddress inetaddress = socket.getInetAddress(); InetAddress inetaddress = socket.getInetAddress();
connectionThrottle = this.a.server.getConnectionThrottle(); // CraftBukkit
// CraftBukkit // CraftBukkit
if (NetworkListenThread.getRecentConnectionAttempts(this.listenThread).containsKey(inetaddress) && System.currentTimeMillis() - ((Long) NetworkListenThread.getRecentConnectionAttempts(this.listenThread).get(inetaddress)).longValue() < 4000L) { if (NetworkListenThread.getRecentConnectionAttempts(this.listenThread).containsKey(inetaddress) && System.currentTimeMillis() - ((Long) NetworkListenThread.getRecentConnectionAttempts(this.listenThread).get(inetaddress)).longValue() < connectionThrottle) {
NetworkListenThread.getRecentConnectionAttempts(this.listenThread).put(inetaddress, Long.valueOf(System.currentTimeMillis())); NetworkListenThread.getRecentConnectionAttempts(this.listenThread).put(inetaddress, Long.valueOf(System.currentTimeMillis()));
socket.close(); socket.close();
continue; continue;

Datei anzeigen

@ -424,6 +424,10 @@ public final class CraftServer implements Server {
return this.configuration.getInt("settings.ping-packet-limit", 100); return this.configuration.getInt("settings.ping-packet-limit", 100);
} }
public long getConnectionThrottle() {
return this.configuration.getInt("settings.connection-throttle");
}
public int getTicksPerAnimalSpawns() { public int getTicksPerAnimalSpawns() {
return this.configuration.getInt("ticks-per.animal-spawns"); return this.configuration.getInt("ticks-per.animal-spawns");
} }

Datei anzeigen

@ -22,6 +22,7 @@ settings:
ping-packet-limit: 100 ping-packet-limit: 100
use-exact-login-location: false use-exact-login-location: false
plugin-profiling: false plugin-profiling: false
connection-throttle: 4000
ticks-per: ticks-per:
animal-spawns: 400 animal-spawns: 400
monster-spawns: 1 monster-spawns: 1