mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-03 07:37:11 +01:00
Merge branch 'authserver_fix_dos' of github.com:jackpoz/TrinityCore
This commit is contained in:
@@ -222,12 +222,25 @@ void AuthSocket::OnClose(void)
|
||||
// Read the packet from the client
|
||||
void AuthSocket::OnRead()
|
||||
{
|
||||
#define MAX_AUTH_LOGON_CHALLENGES_IN_A_ROW 3
|
||||
uint32 challengesInARow = 0;
|
||||
uint8 _cmd;
|
||||
while (1)
|
||||
{
|
||||
if (!socket().recv_soft((char *)&_cmd, 1))
|
||||
return;
|
||||
|
||||
if (_cmd == AUTH_LOGON_CHALLENGE)
|
||||
{
|
||||
++challengesInARow;
|
||||
if (challengesInARow == MAX_AUTH_LOGON_CHALLENGES_IN_A_ROW)
|
||||
{
|
||||
TC_LOG_WARN(LOG_FILTER_AUTHSERVER, "Got %u AUTH_LOGON_CHALLENGE in a row from '%s', possible ongoing DoS", challengesInARow, socket().getRemoteAddress().c_str());
|
||||
socket().shutdown();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
size_t i;
|
||||
|
||||
// Circle through known commands and call the correct command handler
|
||||
|
||||
Reference in New Issue
Block a user