Browse Source

network message validation

lakebane-ai
FatBoy-DOTC 2 weeks ago
parent
commit
47981872be
  1. 2
      src/engine/net/AbstractConnection.java
  2. 9
      src/engine/util/KeyCloneAudit.java

2
src/engine/net/AbstractConnection.java

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

9
src/engine/util/KeyCloneAudit.java

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

Loading…
Cancel
Save