aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Server
diff options
context:
space:
mode:
authorleak <leak@bitmx.net>2012-02-19 13:51:16 +0100
committerleak <leak@bitmx.net>2012-02-19 13:51:16 +0100
commit8e3a4b956e8fcc3ec31240d847a7a630eaf2bba2 (patch)
treec7a797f883906019d9fa820b4d782eb7dfd4c1c5 /src/server/game/Server
parentf0f68f15a86c5ac0c83c47c6db67786506f8460d (diff)
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
Diffstat (limited to 'src/server/game/Server')
-rwxr-xr-xsrc/server/game/Server/Protocol/Opcodes.cpp2
-rwxr-xr-xsrc/server/game/Server/WorldSession.cpp34
-rwxr-xr-xsrc/server/game/Server/WorldSession.h9
-rwxr-xr-xsrc/server/game/Server/WorldSocket.cpp40
4 files changed, 61 insertions, 24 deletions
diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp
index 3ea2d6b690d..4335452635b 100755
--- a/src/server/game/Server/Protocol/Opcodes.cpp
+++ b/src/server/game/Server/Protocol/Opcodes.cpp
@@ -769,7 +769,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x2E4*/ { "SMSG_AREA_SPIRIT_HEALER_TIME", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x2E5*/ { "CMSG_GM_UNTEACH", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL },
/*0x2E6*/ { "SMSG_WARDEN_DATA", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
- /*0x2E7*/ { "CMSG_WARDEN_DATA", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleWardenDataOpcode },
+ /*0x2E7*/ { "CMSG_WARDEN_DATA", STATUS_AUTHED, PROCESS_THREADUNSAFE, &WorldSession::HandleWardenDataOpcode },
/*0x2E8*/ { "SMSG_GROUP_JOINED_BATTLEGROUND", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x2E9*/ { "MSG_BATTLEGROUND_PLAYER_POSITIONS", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBattlegroundPlayerPositionsOpcode},
/*0x2EA*/ { "CMSG_PET_STOP_ATTACK", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandlePetStopAttack },
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index ab107fd0599..951e423a285 100755
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -42,6 +42,8 @@
#include "zlib.h"
#include "ScriptMgr.h"
#include "Transport.h"
+#include "WardenWin.h"
+#include "WardenMac.h"
bool MapSessionFilter::Process(WorldPacket* packet)
{
@@ -94,7 +96,7 @@ m_playerRecentlyLogout(false), m_playerSave(false),
m_sessionDbcLocale(sWorld->GetAvailableDbcLocale(locale)),
m_sessionDbLocaleIndex(locale),
m_latency(0), m_TutorialsChanged(false), recruiterId(recruiter),
-isRecruiter(isARecruiter), timeLastWhoCommand(0)
+isRecruiter(isARecruiter), timeLastWhoCommand(0),_warden(NULL)
{
if (sock)
{
@@ -122,6 +124,9 @@ WorldSession::~WorldSession()
m_Socket = NULL;
}
+ if (_warden)
+ delete _warden;
+
///- empty incoming packet queue
WorldPacket* packet = NULL;
while (_recvQueue.next(packet))
@@ -142,6 +147,12 @@ char const* WorldSession::GetPlayerName() const
return GetPlayer() ? GetPlayer()->GetName() : "<none>";
}
+/// Get player guid if available. Use for logging purposes only
+uint32 WorldSession::GetGuidLow() const
+{
+ return GetPlayer() ? GetPlayer()->GetGUIDLow() : 0;
+}
+
/// Send a packet to the client
void WorldSession::SendPacket(WorldPacket const* packet)
{
@@ -348,6 +359,9 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
delete packet;
}
+ if (m_Socket && !m_Socket->IsClosed() && _warden)
+ _warden->Update();
+
ProcessQueryCallbacks();
//check if we are safe to proceed with logout
@@ -359,6 +373,9 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
if (ShouldLogOut(currTime) && !m_playerLoading)
LogoutPlayer(true);
+ if (m_Socket && GetPlayer() && _warden)
+ _warden->Update();
+
///- Cleanup socket pointer if need
if (m_Socket && m_Socket->IsClosed())
{
@@ -1101,3 +1118,18 @@ void WorldSession::ProcessQueryCallbacks()
_stableSwapCallback.FreeResult();
}
}
+
+void WorldSession::InitWarden(BigNumber* k, std::string os)
+{
+ if (os == "Win")
+ {
+ _warden = (Warden*)new WardenWin();
+ _warden->Init(this, k);
+ }
+ else if (os == "OSX")
+ {
+ // Disabled as it is causing the client to crash
+ // _warden = (Warden*)new WardenMac();
+ // _warden->Init(this, k);
+ }
+}
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 47c54c2c469..90772bfeab9 100755
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -29,6 +29,7 @@
#include "DatabaseEnv.h"
#include "World.h"
#include "WorldPacket.h"
+#include "Cryptography/BigNumber.h"
struct ItemTemplate;
struct AuctionEntry;
@@ -46,6 +47,7 @@ class WorldPacket;
class WorldSocket;
class LoginQueryHolder;
class SpellCastTargets;
+class Warden;
struct AreaTableEntry;
struct LfgJoinResultData;
struct LfgLockStatus;
@@ -242,11 +244,14 @@ class WorldSession
uint32 GetAccountId() const { return _accountId; }
Player* GetPlayer() const { return _player; }
char const* GetPlayerName() const;
+ uint32 GetGuidLow() const;
void SetSecurity(AccountTypes security) { _security = security; }
std::string const& GetRemoteAddress() { return m_Address; }
void SetPlayer(Player* player);
uint8 Expansion() const { return m_expansion; }
+ void InitWarden(BigNumber* k, std::string os);
+
/// Session in auth.queue currently
void SetInQueue(bool state) { m_inQueue = state; }
@@ -488,6 +493,7 @@ class WorldSession
void HandleSetActionButtonOpcode(WorldPacket& recvPacket);
void HandleGameObjectUseOpcode(WorldPacket& recPacket);
+ void HandleMeetingStoneInfo(WorldPacket& recPacket);
void HandleGameobjectReportUse(WorldPacket& recvPacket);
void HandleNameQueryOpcode(WorldPacket& recvPacket);
@@ -934,6 +940,9 @@ class WorldSession
typedef std::list<AddonInfo> AddonsList;
+ // Warden
+ Warden* _warden; // Remains NULL if Warden system is not enabled by config
+
time_t _logoutTime;
bool m_inQueue; // session wait in auth.queue
bool m_playerLoading; // code processed in LoginPlayer
diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp
index ac6f11660e4..2c6098fb23f 100755
--- a/src/server/game/Server/WorldSocket.cpp
+++ b/src/server/game/Server/WorldSocket.cpp
@@ -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));