Skip to content

Commit

Permalink
Merge pull request #4620 from LandSandBoat/allow_packet_guard_allow_l…
Browse files Browse the repository at this point in the history
…ist_modification

[core] Allow external modification of packet guard allow list
  • Loading branch information
TeoTwawki authored Oct 19, 2023
2 parents 796bf9d + 40a7681 commit 5e4f933
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion modules/renamer/cpp/renamer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "../src/map/utils/moduleutils.h"
#include "../src/map/packet_guard.h"
#include "../src/map/utils/moduleutils.h"
#include "../src/map/zone.h"

extern uint8 PacketSize[512];
Expand Down Expand Up @@ -87,6 +88,11 @@ class RenamerModule : public CPPModule

SendListPacket(PChar, dataString);
};

// Add new possible packet to PacketGuard allow list
auto& allowList = PacketGuard::GetPacketAllowList();

allowList[SUBSTATE_IN_CS][0x01] = true;
}
};

Expand Down
5 changes: 5 additions & 0 deletions src/map/packet_guard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,9 @@ namespace PacketGuard
output += "=======================================\n";
ShowInfo(output);
}

auto GetPacketAllowList() -> std::unordered_map<CHAR_SUBSTATE, std::unordered_map<uint16, bool>>&
{
return allowList;
}
} // namespace PacketGuard
2 changes: 2 additions & 0 deletions src/map/packet_guard.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace PacketGuard
bool PacketIsValidForPlayerState(CCharEntity* PChar, uint16 SmallPD_Type);
bool IsRateLimitedPacket(CCharEntity* PChar, uint16 SmallPD_Type);
void PrintPacketList(CCharEntity* PChar);

auto GetPacketAllowList() -> std::unordered_map<CHAR_SUBSTATE, std::unordered_map<uint16, bool>>&;
} // namespace PacketGuard

#endif // _PACKETGUARD_H

0 comments on commit 5e4f933

Please sign in to comment.