3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-17 05:20:05 +01:00

Loosen throttle strictness.

Dieser Commit ist enthalten in:
EvilSeph 2012-01-24 17:38:47 -05:00
Ursprung 39935eb3f2
Commit b416dd337f
2 geänderte Dateien mit 153 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,46 @@
package net.minecraft.server;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
class NetworkAcceptThread extends Thread {
final MinecraftServer a;
final NetworkListenThread b;
NetworkAcceptThread(NetworkListenThread networklistenthread, String s, MinecraftServer minecraftserver) {
super(s);
this.b = networklistenthread;
this.a = minecraftserver;
}
public void run() {
while (this.b.b) {
try {
Socket socket = NetworkListenThread.a(this.b).accept();
if (socket != null) {
synchronized (NetworkListenThread.b(this.b)) {
InetAddress inetaddress = socket.getInetAddress();
if (NetworkListenThread.b(this.b).containsKey(inetaddress) && System.currentTimeMillis() - ((Long) NetworkListenThread.b(this.b).get(inetaddress)).longValue() < 6000L) { // CraftBukkit
NetworkListenThread.b(this.b).put(inetaddress, Long.valueOf(System.currentTimeMillis()));
socket.close();
continue;
}
NetworkListenThread.b(this.b).put(inetaddress, Long.valueOf(System.currentTimeMillis()));
}
NetLoginHandler netloginhandler = new NetLoginHandler(this.a, socket, "Connection #" + NetworkListenThread.c(this.b));
NetworkListenThread.a(this.b, netloginhandler);
}
} catch (IOException ioexception) {
ioexception.printStackTrace();
}
}
}
}

Datei anzeigen

@ -0,0 +1,107 @@
package net.minecraft.server;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.IOException; // CraftBukkit
public class NetworkListenThread {
public static Logger a = Logger.getLogger("Minecraft");
private ServerSocket d;
private Thread e;
public volatile boolean b = false;
private int f = 0;
private ArrayList g = new ArrayList();
private ArrayList h = new ArrayList();
public MinecraftServer c;
private HashMap i = new HashMap();
public NetworkListenThread(MinecraftServer minecraftserver, InetAddress inetaddress, int i) throws IOException { // CraftBukkit
this.c = minecraftserver;
this.d = new ServerSocket(i, 0, inetaddress);
this.d.setPerformancePreferences(0, 2, 1);
this.b = true;
this.e = new NetworkAcceptThread(this, "Listen thread", minecraftserver);
this.e.start();
}
public void a(Socket socket) {
InetAddress inetaddress = socket.getInetAddress();
HashMap hashmap = this.i;
synchronized (this.i) {
this.i.remove(inetaddress);
}
}
public void a(NetServerHandler netserverhandler) {
this.h.add(netserverhandler);
}
private void a(NetLoginHandler netloginhandler) {
if (netloginhandler == null) {
throw new IllegalArgumentException("Got null pendingconnection!");
} else {
this.g.add(netloginhandler);
}
}
public void a() {
int i;
for (i = 0; i < this.g.size(); ++i) {
NetLoginHandler netloginhandler = (NetLoginHandler) this.g.get(i);
try {
netloginhandler.a();
} catch (Exception exception) {
netloginhandler.disconnect("Internal server error");
a.log(Level.WARNING, "Failed to handle packet: " + exception, exception);
}
if (netloginhandler.c) {
this.g.remove(i--);
}
netloginhandler.networkManager.a();
}
for (i = 0; i < this.h.size(); ++i) {
NetServerHandler netserverhandler = (NetServerHandler) this.h.get(i);
try {
netserverhandler.a();
} catch (Exception exception1) {
a.log(Level.WARNING, "Failed to handle packet: " + exception1, exception1);
netserverhandler.disconnect("Internal server error");
}
if (netserverhandler.disconnected) {
this.h.remove(i--);
}
netserverhandler.networkManager.a();
}
}
static ServerSocket a(NetworkListenThread networklistenthread) {
return networklistenthread.d;
}
static HashMap b(NetworkListenThread networklistenthread) {
return networklistenthread.i;
}
static int c(NetworkListenThread networklistenthread) {
return networklistenthread.f++;
}
static void a(NetworkListenThread networklistenthread, NetLoginHandler netloginhandler) {
networklistenthread.a(netloginhandler);
}
}