Core/Log: Log all character kicks to "network.kick" category

This commit is contained in:
jackpoz
2020-04-08 21:05:01 +02:00
parent 68fcd592f8
commit 31018c3652
11 changed files with 33 additions and 29 deletions

View File

@@ -98,8 +98,8 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accountId)
if (Player* p = ObjectAccessor::FindConnectedPlayer(guid))
{
WorldSession* s = p->GetSession();
s->KickPlayer(); // mark session to remove at next session list update
s->LogoutPlayer(false); // logout player without waiting next session list update
s->KickPlayer("AccountMgr::DeleteAccount Deleting the account"); // mark session to remove at next session list update
s->LogoutPlayer(false); // logout player without waiting next session list update
}
Player::DeleteFromDB(guid, accountId, false); // no need to update realm characters

View File

@@ -689,7 +689,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData)
if (PlayerLoading() || GetPlayer() != nullptr)
{
TC_LOG_ERROR("network", "Player tries to login again, AccountId = %d", GetAccountId());
KickPlayer();
KickPlayer("WorldSession::HandlePlayerLoginOpcode Another client logging in");
return;
}
@@ -701,7 +701,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData)
if (!IsLegitCharacterForAccount(playerGuid))
{
TC_LOG_ERROR("network", "Account (%u) can't login with that character (%s).", GetAccountId(), playerGuid.ToString().c_str());
KickPlayer();
KickPlayer("WorldSession::HandlePlayerLoginOpcode Trying to login with a character of another account");
return;
}
@@ -728,7 +728,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
if (!pCurrChar->LoadFromDB(playerGuid, holder))
{
SetPlayer(nullptr);
KickPlayer(); // disconnect client, player no set to session and it will not deleted or saved at kick
KickPlayer("WorldSession::HandlePlayerLogin Player::LoadFromDB failed"); // disconnect client, player no set to session and it will not deleted or saved at kick
delete pCurrChar; // delete it manually
delete holder; // delete all unprocessed queries
m_playerLoading = false;
@@ -1348,7 +1348,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData)
TC_LOG_ERROR("entities.player.cheat", "Account %u, IP: %s tried to customise %s, but it does not belong to their account!",
GetAccountId(), GetRemoteAddress().c_str(), customizeInfo->Guid.ToString().c_str());
recvData.rfinish();
KickPlayer();
KickPlayer("WorldSession::HandleCharCustomize Trying to customise character of another account");
return;
}
@@ -1601,7 +1601,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
TC_LOG_ERROR("entities.player.cheat", "Account %u, IP: %s tried to factionchange character %s, but it does not belong to their account!",
GetAccountId(), GetRemoteAddress().c_str(), factionChangeInfo->Guid.ToString().c_str());
recvData.rfinish();
KickPlayer();
KickPlayer("WorldSession::HandleCharFactionOrRaceChange Trying to change faction of character of another account");
return;
}

View File

@@ -509,7 +509,7 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recvData)
{
TC_LOG_DEBUG("misc", "Player %s from account id %u kicked for incorrect speed (must be %f instead %f)",
_player->GetName().c_str(), _player->GetSession()->GetAccountId(), _player->GetSpeed(move_type), newspeed);
_player->GetSession()->KickPlayer();
_player->GetSession()->KickPlayer("WorldSession::HandleForceSpeedChangeAck Incorrect speed");
}
}
}

View File

@@ -377,7 +377,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str(), ihe.GetInvalidValue().c_str());
if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK))
KickPlayer();
KickPlayer("WorldSession::Update Invalid chat link");
}
catch (WorldPackets::IllegalHyperlinkException const& ihe)
{
@@ -385,7 +385,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str(), ihe.GetInvalidValue().c_str());
if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK))
KickPlayer();
KickPlayer("WorldSession::Update Illegal chat link");
}
catch (WorldPackets::PacketArrayMaxCapacityException const& pamce)
{
@@ -612,10 +612,13 @@ void WorldSession::LogoutPlayer(bool save)
}
/// Kick a player out of the World
void WorldSession::KickPlayer()
void WorldSession::KickPlayer(std::string const& reason)
{
if (m_Socket)
{
TC_LOG_INFO("network.kick", "Account: %u Character: '%s' %s kicked with reason: %s", GetAccountId(), _player ? _player->GetName().c_str() : "<none>",
_player ? _player->GetGUID().ToString().c_str() : "", reason.c_str());
m_Socket->CloseSocket();
forceExit = true;
}
@@ -630,7 +633,7 @@ bool WorldSession::ValidateHyperlinksAndMaybeKick(std::string const& str)
GetPlayer()->GetGUID().ToString().c_str(), str.c_str());
if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK))
KickPlayer();
KickPlayer("WorldSession::ValidateHyperlinksAndMaybeKick Invalid chat link");
return false;
}
@@ -644,7 +647,7 @@ bool WorldSession::DisallowHyperlinksAndMaybeKick(std::string const& str)
GetPlayer()->GetGUID().ToString().c_str(), str.c_str());
if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK))
KickPlayer();
KickPlayer("WorldSession::DisallowHyperlinksAndMaybeKick Illegal chat link");
return false;
}
@@ -1353,7 +1356,7 @@ bool WorldSession::DosProtection::EvaluateOpcode(WorldPacket& p, time_t time) co
case POLICY_KICK:
{
TC_LOG_WARN("network", "AntiDOS: Player kicked!");
Session->KickPlayer();
Session->KickPlayer("WorldSession::DosProtection::EvaluateOpcode AntiDOS");
return false;
}
case POLICY_BAN:
@@ -1369,7 +1372,7 @@ bool WorldSession::DosProtection::EvaluateOpcode(WorldPacket& p, time_t time) co
}
sWorld->BanAccount(bm, nameOrIp, duration, "DOS (Packet Flooding/Spoofing", "Server: AutoDOS");
TC_LOG_WARN("network", "AntiDOS: Player automatically banned for %u seconds.", duration);
Session->KickPlayer();
Session->KickPlayer("WorldSession::DosProtection::EvaluateOpcode AntiDOS");
return false;
}
default: // invalid policy

View File

@@ -416,7 +416,7 @@ class TC_GAME_API WorldSession
}
void LogoutPlayer(bool save);
void KickPlayer();
void KickPlayer(std::string const& reason);
// Returns true if all contained hyperlinks are valid
// May kick player on false depending on world config (handler should abort)
bool ValidateHyperlinksAndMaybeKick(std::string const& str);

View File

@@ -110,7 +110,7 @@ void Warden::Update()
{
TC_LOG_WARN("warden", "%s (latency: %u, IP: %s) exceeded Warden module response delay for more than %s - disconnecting client",
_session->GetPlayerInfo().c_str(), _session->GetLatency(), _session->GetRemoteAddress().c_str(), secsToTimeString(maxClientResponseDelay, TimeFormat::ShortText).c_str());
_session->KickPlayer();
_session->KickPlayer("Warden::Update Warden module response delay exceeded");
}
else
_clientResponseTimer += diff;
@@ -195,7 +195,7 @@ std::string Warden::Penalty(WardenCheck* check /*= nullptr*/)
return "None";
break;
case WARDEN_ACTION_KICK:
_session->KickPlayer();
_session->KickPlayer("Warden::Penalty");
return "Kick";
break;
case WARDEN_ACTION_BAN:

View File

@@ -265,5 +265,5 @@ void WardenMac::HandleData(ByteBuffer &buff)
//found = true;
}
_session->KickPlayer();
_session->KickPlayer("WardenMac::HandleData");
}

View File

@@ -297,7 +297,7 @@ bool World::RemoveSession(uint32 id)
if (itr->second->PlayerLoading())
return false;
itr->second->KickPlayer();
itr->second->KickPlayer("World::RemoveSession");
}
return true;
@@ -316,9 +316,9 @@ void World::AddSession_(WorldSession* s)
///- kick already loaded player with same account (if any) and remove session
///- if player is in loading and want to load again, return
if (!RemoveSession (s->GetAccountId()))
if (!RemoveSession(s->GetAccountId()))
{
s->KickPlayer();
s->KickPlayer("World::AddSession_ Couldn't remove the other session while on loading screen");
delete s; // session not added yet in session list, so not listed in queue
return;
}
@@ -2694,7 +2694,7 @@ void World::KickAll()
// session not removed at kick and will removed in next update tick
for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
itr->second->KickPlayer();
itr->second->KickPlayer("World::KickAll");
}
/// Kick (and save) all players with security level less `sec`
@@ -2703,7 +2703,7 @@ void World::KickAllLess(AccountTypes sec)
// session not removed at kick and will removed in next update tick
for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
if (itr->second->GetSecurity() < sec)
itr->second->KickPlayer();
itr->second->KickPlayer("World::KickAllLess");
}
/// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban
@@ -2791,7 +2791,7 @@ BanReturn World::BanAccount(BanMode mode, std::string const& nameOrIP, uint32 du
if (WorldSession* sess = FindSession(account))
if (std::string(sess->GetPlayerName()) != author)
sess->KickPlayer();
sess->KickPlayer("World::BanAccount Banning account");
} while (resultAccounts->NextRow());
LoginDatabase.CommitTransaction(trans);
@@ -2863,7 +2863,7 @@ BanReturn World::BanCharacter(std::string const& name, std::string const& durati
CharacterDatabase.CommitTransaction(trans);
if (banned)
banned->GetSession()->KickPlayer();
banned->GetSession()->KickPlayer("World::BanCharacter Banning character");
return BAN_SUCCESS;
}

View File

@@ -380,7 +380,7 @@ public:
target->SetName(newName);
if (WorldSession* session = target->GetSession())
session->KickPlayer();
session->KickPlayer("HandleCharacterRenameCommand GM Command renaming character");
}
else
{
@@ -865,7 +865,7 @@ public:
{
characterGuid = player->GetGUID();
accountId = player->GetSession()->GetAccountId();
player->GetSession()->KickPlayer();
player->GetSession()->KickPlayer("HandleCharacterEraseCommand GM Command deleting character");
}
else
{

View File

@@ -941,7 +941,7 @@ public:
else
handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, playerName.c_str());
target->GetSession()->KickPlayer();
target->GetSession()->KickPlayer("HandleKickPlayerCommand GM Command");
return true;
}

View File

@@ -3960,6 +3960,7 @@ Logger.mmaps=3,Server
#Logger.movement.motionmaster=3,Console Server
#Logger.movement.splinechain=3,Console Server
#Logger.network=3,Console Server
#Logger.network.kick=3,Console Server
#Logger.network.opcode=3,Console Server
#Logger.network.soap=3,Console Server
#Logger.outdoorpvp=3,Console Server