Fixed a critical bug with the Management Server (no more lockouts weeee)

This commit is contained in:
ceikry 2021-07-13 21:12:07 -05:00
parent eafc281439
commit 31479d811f
6 changed files with 68 additions and 6 deletions

View file

@ -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;
}

View file

@ -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);