Proper client timeout detection (#19906)

- Properly detect client timeout when logged into a character after a configurable time (default 60s) has passed without the client sending any packets.
- Fixes issues with crashed clients leaving characters in the world for a very long time (default 15 minutes), as well as edge case exploits involving intentionally pausing client execution for some amount of time.

(cherry picked from commit 7dfd472f8dff6ce067572e2887c2beb56d9ba9de)
This commit is contained in:
Treeston
2020-07-16 22:00:30 +02:00
committed by Carbenium
parent 37c3259de8
commit 2c3fc47a96
6 changed files with 27 additions and 10 deletions
+9 -5
View File
@@ -142,7 +142,7 @@ WorldSession::WorldSession(uint32 id, std::string&& name, uint32 battlenetAccoun
if (sock)
{
m_Address = sock->GetRemoteIpAddress().to_string();
ResetTimeOutTime();
ResetTimeOutTime(false);
LoginDatabase.PExecute("UPDATE account SET online = 1 WHERE id = %u;", GetAccountId()); // One-time query
}
@@ -327,7 +327,8 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
UpdateTimeOutTime(diff);
///- Before we process anything:
/// If necessary, kick the player from the character select screen
/// If necessary, kick the player because the client didn't send anything for too long
/// (or they've been idling in character select)
if (IsConnectionIdle())
m_Socket[CONNECTION_TYPE_REALM]->CloseSocket();
@@ -697,9 +698,12 @@ char const* WorldSession::GetTrinityString(uint32 entry) const
return sObjectMgr->GetTrinityString(entry, GetSessionDbLocaleIndex());
}
void WorldSession::ResetTimeOutTime()
void WorldSession::ResetTimeOutTime(bool onlyActive)
{
m_timeOutTime = int32(sWorld->getIntConfig(CONFIG_SOCKET_TIMEOUTTIME));
if (GetPlayer())
m_timeOutTime = int32(sWorld->getIntConfig(CONFIG_SOCKET_TIMEOUTTIME_ACTIVE));
else if (!onlyActive)
m_timeOutTime = int32(sWorld->getIntConfig(CONFIG_SOCKET_TIMEOUTTIME));
}
void WorldSession::Handle_NULL(WorldPackets::Null& null)
@@ -1069,7 +1073,7 @@ void WorldSession::InitializeSessionCallback(LoginDatabaseQueryHolder* realmHold
SendAuthWaitQue(0);
SetInQueue(false);
ResetTimeOutTime();
ResetTimeOutTime(false);
SendSetTimeZoneInformation();
SendFeatureSystemStatusGlueScreen();