mirror of
https://github.com/PaperMC/Paper.git
synced 2026-11-25 10:29:41 -05:00
Added configurable Connection Throttle. Addresses BUKKIT-1274
This commit is contained in:
1 parent
dda37aa18c
commit
c2cdeac09b
3 files changed
+9
-1
No files matched your search
@@ -10,6 +10,8 @@ class NetworkAcceptThread extends Thread {
|
||||
|
||||
final NetworkListenThread listenThread;
|
||||
|
||||
long connectionThrottle; // CraftBukkit
|
||||
|
||||
NetworkAcceptThread(NetworkListenThread networklistenthread, String s, MinecraftServer minecraftserver) {
|
||||
super(s);
|
||||
this.listenThread = networklistenthread;
|
||||
@@ -24,9 +26,10 @@ class NetworkAcceptThread extends Thread {
|
||||
if (socket != null) {
|
||||
synchronized (NetworkListenThread.getRecentConnectionAttempts(this.listenThread)) {
|
||||
InetAddress inetaddress = socket.getInetAddress();
|
||||
connectionThrottle = this.a.server.getConnectionThrottle(); // 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()));
|
||||
socket.close();
|
||||
continue;
|
||||
|
||||
@@ -424,6 +424,10 @@ public final class CraftServer implements Server {
|
||||
return this.configuration.getInt("settings.ping-packet-limit", 100);
|
||||
}
|
||||
|
||||
public long getConnectionThrottle() {
|
||||
return this.configuration.getInt("settings.connection-throttle");
|
||||
}
|
||||
|
||||
public int getTicksPerAnimalSpawns() {
|
||||
return this.configuration.getInt("ticks-per.animal-spawns");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user