Add remote kicking support to the MS

This commit is contained in:
ceikry 2021-11-29 22:41:23 -06:00
parent ce9366a47a
commit bf2feefa11
3 changed files with 36 additions and 0 deletions

View file

@ -63,3 +63,4 @@
- Quest point cape/hood no longer unequip on login if wearing QP hood
- Random Event Genie lamps now scale exp correctly
- Void mace now consumes runes correctly
- Add remote kicking support to the Management Server

View file

@ -152,6 +152,7 @@ public class IoSession {
* Handles the writing of all buffers in the queue.
*/
public void write() {
if (!key.isValid()) {
disconnect();
return;
@ -169,6 +170,7 @@ public class IoSession {
writingQueue.remove(0);
}
} catch (IOException e) {
e.printStackTrace();
disconnect();
} finally {
writingLock.unlock();

View file

@ -1,10 +1,14 @@
package ms.net.event;
import java.nio.ByteBuffer;
import java.util.Locale;
import ms.Management;
import ms.net.IoReadEvent;
import ms.net.IoSession;
import ms.net.packet.IoBuffer;
import ms.system.util.ManagementConstants;
import ms.world.PlayerSession;
import ms.world.WorldDatabase;
import ms.system.util.ByteBufferUtils;
@ -40,6 +44,35 @@ public final class HSReadEvent extends IoReadEvent {
int updateStamp = buffer.getInt();
WorldDatabase.sendUpdate(session, updateStamp);
break;
case 35:
IoBuffer buf = new IoBuffer();
String username = ByteBufferUtils.getString(buffer).toLowerCase();
password = ByteBufferUtils.getString(buffer);
if (!password.equals(ManagementConstants.getSECRET_KEY())){
System.out.println("Password mismatch (attempt=" + password + ")!");
buf.put(1);
ByteBuffer buff = buf.toByteBuffer();
buff.flip();
session.queue(buff);
return;
}
PlayerSession player = WorldDatabase.getPlayer(username);
if (player == null) {
System.out.println("Player " + username + " was not registered!");
buf.put(2);
ByteBuffer buff = buf.toByteBuffer();
buff.flip();
session.queue(buff);
return;
}
buf.put(0);
ByteBuffer buff = buf.toByteBuffer();
buff.flip();
session.queue(buff);
player.getWorld().getPlayers().remove(username);
player.setWorldId(0);
break;
default:
System.err.println("Unhandled handshake opcode: " + opcode + ".");
session.disconnect();