network message validation

This commit is contained in:
2025-02-09 14:13:28 -06:00
parent daea835613
commit 47981872be
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ public abstract class AbstractConnection implements
protected final AtomicBoolean execTask = new AtomicBoolean(false);
protected final ReentrantLock writeLock = new ReentrantLock();
protected final ReentrantLock readLock = new ReentrantLock();
protected long lastMsgTime = System.currentTimeMillis();
public long lastMsgTime = System.currentTimeMillis();
protected long lastKeepAliveTime = System.currentTimeMillis();
protected long lastOpcode = -1;
protected ConcurrentLinkedQueue<ByteBuffer> outbox = new ConcurrentLinkedQueue<>();
+9
View File
@@ -2,6 +2,7 @@ package engine.util;
import engine.gameManager.ConfigManager;
import engine.gameManager.DbManager;
import engine.net.client.Protocol;
import engine.net.client.msg.ClientNetMsg;
import engine.objects.Group;
import engine.objects.PlayerCharacter;
@@ -32,6 +33,14 @@ public enum KeyCloneAudit {
public static boolean auditNetMsg(ClientNetMsg msg){
boolean valid = true;
if(msg.getProtocolMsg().equals(Protocol.KEEPALIVESERVERCLIENT))
return true;
Long msgDelay = System.currentTimeMillis() - msg.getOrigin().lastMsgTime;
if(msgDelay < 100)
return false;
return valid;