Core/Warden: Base implementation for Warden functionality

Note: The default config file action for clients failing the checks can be changed for each check via the characters.warden_action table

Credits to TOM_RUS
This commit is contained in:
leak committed 2012-02-19 13:51:16 +01:00
1 parent f0f68f15a8
commit 8e3a4b956e
34 files changed
+4568 -41

No files matched your search

+18 -22
View File
@@ -778,11 +778,11 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
//uint8 expansion = 0;
LocaleConstant locale;
std::string account;
SHA1Hash sha1;
SHA1Hash sha;
BigNumber v, s, g, N;
WorldPacket packet, SendAddonPacked;
BigNumber K;
BigNumber k;
if (sWorld->IsClosed())
{
@@ -816,21 +816,9 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
LoginDatabase.EscapeString (safe_account);
// No SQL injection, username escaped.
QueryResult result =
LoginDatabase.PQuery ("SELECT "
"id, " //0
"sessionkey, " //1
"last_ip, " //2
"locked, " //3
"v, " //4
"s, " //5
"expansion, " //6
"mutetime, " //7
"locale, " //8
"recruiter " //9
"FROM account "
"WHERE username = '%s'",
safe_account.c_str());
// 0 1 2 3 4 5 6 7 8 9 10
QueryResult result = LoginDatabase.PQuery ("SELECT id, sessionkey, last_ip, locked, v, s, expansion, mutetime, locale, recruiter, os FROM account "
"WHERE username = '%s'", safe_account.c_str());
// Stop if the account is not found
if (!result)
@@ -882,7 +870,12 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
}
id = fields[0].GetUInt32();
K.SetHexStr (fields[1].GetCString());
/*
if (security > SEC_ADMINISTRATOR) // prevent invalid security settings in DB
security = SEC_ADMINISTRATOR;
*/
k.SetHexStr (fields[1].GetCString());
int64 mutetime = fields[7].GetInt64();
//! Negative mutetime indicates amount of seconds to be muted effective on next login - which is now.
@@ -903,6 +896,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
locale = LOCALE_enUS;
uint32 recruiter = fields[9].GetUInt32();
std::string os = fields[10].GetString();
// Checks gmlevel per Realm
result =
@@ -954,8 +948,6 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
}
// Check that Key and account name are the same on client and server
SHA1Hash sha;
uint32 t = 0;
uint32 seed = m_Seed;
@@ -963,7 +955,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
sha.UpdateData ((uint8 *) & t, 4);
sha.UpdateData ((uint8 *) & clientSeed, 4);
sha.UpdateData ((uint8 *) & seed, 4);
sha.UpdateBigNumbers (&K, NULL);
sha.UpdateBigNumbers (&k, NULL);
sha.Finalize();
if (memcmp (sha.GetDigest(), digest, 20))
@@ -1002,12 +994,16 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
// NOTE ATM the socket is single-threaded, have this in mind ...
ACE_NEW_RETURN (m_Session, WorldSession (id, this, AccountTypes(security), expansion, mutetime, locale, recruiter, isRecruiter), -1);
m_Crypt.Init(&K);
m_Crypt.Init(&k);
m_Session->LoadGlobalAccountData();
m_Session->LoadTutorialsData();
m_Session->ReadAddonsInfo(recvPacket);
// Initialize Warden system only if it is enabled by config
if (sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED))
m_Session->InitWarden(&k, os);
// Sleep this Network thread for
uint32 sleepTime = sWorld->getIntConfig(CONFIG_SESSION_ADD_DELAY);
ACE_OS::sleep (ACE_Time_Value (0, sleepTime));