2012-01-24 23:38:47 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.net.InetAddress;
|
|
|
|
import java.net.Socket;
|
|
|
|
|
|
|
|
class NetworkAcceptThread extends Thread {
|
|
|
|
|
|
|
|
final MinecraftServer a;
|
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
final NetworkListenThread listenThread;
|
2012-01-24 23:38:47 +01:00
|
|
|
|
|
|
|
NetworkAcceptThread(NetworkListenThread networklistenthread, String s, MinecraftServer minecraftserver) {
|
|
|
|
super(s);
|
2012-02-29 22:31:04 +01:00
|
|
|
this.listenThread = networklistenthread;
|
2012-01-24 23:38:47 +01:00
|
|
|
this.a = minecraftserver;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void run() {
|
2012-02-29 22:31:04 +01:00
|
|
|
while (this.listenThread.b) {
|
2012-01-24 23:38:47 +01:00
|
|
|
try {
|
2012-02-29 22:31:04 +01:00
|
|
|
Socket socket = NetworkListenThread.a(this.listenThread).accept();
|
2012-01-24 23:38:47 +01:00
|
|
|
|
|
|
|
if (socket != null) {
|
2012-02-29 22:31:04 +01:00
|
|
|
synchronized (NetworkListenThread.getRecentConnectionAttempts(this.listenThread)) {
|
2012-01-24 23:38:47 +01:00
|
|
|
InetAddress inetaddress = socket.getInetAddress();
|
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
// CraftBukkit
|
|
|
|
if (NetworkListenThread.getRecentConnectionAttempts(this.listenThread).containsKey(inetaddress) && System.currentTimeMillis() - ((Long) NetworkListenThread.getRecentConnectionAttempts(this.listenThread).get(inetaddress)).longValue() < 4000L) {
|
|
|
|
NetworkListenThread.getRecentConnectionAttempts(this.listenThread).put(inetaddress, Long.valueOf(System.currentTimeMillis()));
|
2012-01-24 23:38:47 +01:00
|
|
|
socket.close();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
NetworkListenThread.getRecentConnectionAttempts(this.listenThread).put(inetaddress, Long.valueOf(System.currentTimeMillis()));
|
2012-01-24 23:38:47 +01:00
|
|
|
}
|
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
NetLoginHandler netloginhandler = new NetLoginHandler(this.a, socket, "Connection #" + NetworkListenThread.c(this.listenThread));
|
2012-01-24 23:38:47 +01:00
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
NetworkListenThread.a(this.listenThread, netloginhandler);
|
2012-01-24 23:38:47 +01:00
|
|
|
}
|
|
|
|
} catch (IOException ioexception) {
|
|
|
|
ioexception.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|