mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-08 12:10:59 -06:00
Fixed a critical bug with the Management Server (no more lockouts weeee)
This commit is contained in:
parent
cc3b7546d4
commit
127ebc242e
6 changed files with 68 additions and 6 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package ms.net;
|
||||
|
||||
import ms.world.WorldDatabase;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
|
|
@ -8,6 +10,7 @@ import java.nio.channels.SelectionKey;
|
|||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/**
|
||||
|
|
@ -63,7 +66,9 @@ public final class IoEventHandler {
|
|||
ByteBuffer buffer = ByteBuffer.allocate(100_000);
|
||||
IoSession session = (IoSession) key.attachment();
|
||||
if (channel.read(buffer) == -1) {
|
||||
System.out.println("Existing session disconnected - likely portscanner or server status checker.");
|
||||
if(session.getGameServer() != null){
|
||||
WorldDatabase.unRegister(session.getGameServer());
|
||||
}
|
||||
key.cancel();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ public final class RegistryReadEvent extends IoReadEvent {
|
|||
boolean quickChat = buffer.get() == 1;
|
||||
boolean lootshare = buffer.get() == 1;
|
||||
String activity = ByteBufferUtils.getString(buffer);
|
||||
System.out.println("["+ revision + "], country = " + country + ", members = " + members + ", pvp = " + pvp + ", quickChat = " + quickChat + ", lootShare = " + lootshare + ", activity = " + activity);
|
||||
for (int i = 0; i < CHECK.length(); i++) {
|
||||
if ((char) buffer.get() != CHECK.charAt(i)) {
|
||||
session.write(3);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import ms.net.IoSession;
|
|||
import ms.net.packet.IoBuffer;
|
||||
import ms.world.info.CountryFlag;
|
||||
import ms.world.info.WorldInfo;
|
||||
import ms09.MSLogger;
|
||||
|
||||
/**
|
||||
* Holds all the world servers.
|
||||
|
|
@ -148,9 +149,25 @@ public class WorldDatabase {
|
|||
throw new IllegalStateException("World " + info.getWorldId() + " is already registered!");
|
||||
}
|
||||
flagUpdate();
|
||||
System.out.println("Registered world - [id=" + info.getWorldId() + ", ip=" + info.getAddress() + ", country=" + info.getCountry().name().toLowerCase() + ", revision=" + info.getRevision() + "]!");
|
||||
MSLogger.logInfo("Registered world - [id=" + info.getWorldId() + ", ip=" + info.getAddress() + ", country=" + info.getCountry().name().toLowerCase() + ", revision=" + info.getRevision() + "]!");
|
||||
return DATABASE[info.getWorldId()] = new GameServer(info);
|
||||
}
|
||||
|
||||
public static void unRegister(GameServer server){
|
||||
int index = -1;
|
||||
for(int i = 0; i < DATABASE.length; i++){
|
||||
GameServer s = DATABASE[i];
|
||||
if(s == server){
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(index != -1){
|
||||
DATABASE[index] = null;
|
||||
WorldInfo info = server.getInfo();
|
||||
MSLogger.logInfo("Unregistered world - [id=" + info.getWorldId() + ", ip=" + info.getAddress() + ", country=" + info.getCountry().name().toLowerCase() + ", revision=" + info.getRevision() + "]!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the world id of the player.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue