network message validation
This commit is contained in:
@@ -38,7 +38,7 @@ public abstract class AbstractConnection implements
|
|||||||
protected final AtomicBoolean execTask = new AtomicBoolean(false);
|
protected final AtomicBoolean execTask = new AtomicBoolean(false);
|
||||||
protected final ReentrantLock writeLock = new ReentrantLock();
|
protected final ReentrantLock writeLock = new ReentrantLock();
|
||||||
protected final ReentrantLock readLock = 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 lastKeepAliveTime = System.currentTimeMillis();
|
||||||
protected long lastOpcode = -1;
|
protected long lastOpcode = -1;
|
||||||
protected ConcurrentLinkedQueue<ByteBuffer> outbox = new ConcurrentLinkedQueue<>();
|
protected ConcurrentLinkedQueue<ByteBuffer> outbox = new ConcurrentLinkedQueue<>();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package engine.util;
|
|||||||
|
|
||||||
import engine.gameManager.ConfigManager;
|
import engine.gameManager.ConfigManager;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
|
import engine.net.client.Protocol;
|
||||||
import engine.net.client.msg.ClientNetMsg;
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
import engine.objects.Group;
|
import engine.objects.Group;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
@@ -32,6 +33,14 @@ public enum KeyCloneAudit {
|
|||||||
public static boolean auditNetMsg(ClientNetMsg msg){
|
public static boolean auditNetMsg(ClientNetMsg msg){
|
||||||
boolean valid = true;
|
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;
|
return valid;
|
||||||
|
|||||||
Reference in New Issue
Block a user