diff --git a/src/main/java/emu/lunarcore/server/game/GameServerPacketHandler.java b/src/main/java/emu/lunarcore/server/game/GameServerPacketHandler.java index 27f8f01..a581df8 100644 --- a/src/main/java/emu/lunarcore/server/game/GameServerPacketHandler.java +++ b/src/main/java/emu/lunarcore/server/game/GameServerPacketHandler.java @@ -50,7 +50,7 @@ public class GameServerPacketHandler { if (handler != null) { // Check cooldown to prevent packet spam long timestamp = System.currentTimeMillis(); - if (session.getPacketCooldown().get(cmdId) >= timestamp) { + if (session.getPacketCooldown().get(cmdId) >= timestamp && !CmdIdUtils.ALLOWED_FILTER_PACKETS.contains(cmdId)) { //LunarCore.getLogger().warn("Dropped a packet " + CmdIdUtils.getCmdIdName(cmdId)); return; } else { diff --git a/src/main/java/emu/lunarcore/server/game/GameSession.java b/src/main/java/emu/lunarcore/server/game/GameSession.java index 445be66..5dd7454 100644 --- a/src/main/java/emu/lunarcore/server/game/GameSession.java +++ b/src/main/java/emu/lunarcore/server/game/GameSession.java @@ -132,7 +132,7 @@ public class GameSession { // Log packet if (LunarCore.getConfig().getLogOptions().packets) { - if (!(LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.LOOP_PACKETS.contains(opcode))) { + if (!(LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.IGNORED_LOG_PACKETS.contains(opcode))) { logPacket("RECV", opcode, data); } } @@ -159,8 +159,8 @@ public class GameSession { // Log if (LunarCore.getConfig().getLogOptions().packets) { - if (!(LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.LOOP_PACKETS.contains(packet.getCmdId()))) { - logPacket("RECV", packet.getCmdId(), packet.getData()); + if (!(LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.IGNORED_LOG_PACKETS.contains(packet.getCmdId()))) { + logPacket("SEND", packet.getCmdId(), packet.getData()); } } } @@ -177,7 +177,7 @@ public class GameSession { // Log if (LunarCore.getConfig().getLogOptions().packets) { - if (!(LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.LOOP_PACKETS.contains(cmdId))) { + if (!(LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.IGNORED_LOG_PACKETS.contains(cmdId))) { logPacket("SEND", cmdId, Utils.EMPTY_BYTE_ARRAY); } } diff --git a/src/main/java/emu/lunarcore/server/packet/CmdIdUtils.java b/src/main/java/emu/lunarcore/server/packet/CmdIdUtils.java index 091a89e..a902037 100644 --- a/src/main/java/emu/lunarcore/server/packet/CmdIdUtils.java +++ b/src/main/java/emu/lunarcore/server/packet/CmdIdUtils.java @@ -16,13 +16,28 @@ import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; public class CmdIdUtils { - public static final IntSet LOOP_PACKETS = IntOpenHashSet.of( + /** + * Packet ids that will NOT be logged if "filterLoopingPackets" is true in the config + */ + public static final IntSet IGNORED_LOG_PACKETS = IntOpenHashSet.of( CmdId.PlayerHeartBeatCsReq, CmdId.PlayerHeartBeatScRsp, CmdId.SceneEntityMoveCsReq, CmdId.SceneEntityMoveScRsp, CmdId.GetQuestDataScRsp ); + + /** + * Packet ids that will NOT be caught by the spam filter + */ + public static final IntSet ALLOWED_FILTER_PACKETS = IntOpenHashSet.of( + CmdId.PlayerGetTokenCsReq, + CmdId.PlayerLoginCsReq, + CmdId.PlayerHeartBeatCsReq, + CmdId.GetMissionStatusCsReq, + CmdId.GetMissionStatusCsReq, + CmdId.GetMissionEventDataCsReq + ); private static Int2ObjectMap cmdIdMap;