summaryrefslogtreecommitdiff
path: root/src/authserver/Server/AuthSocket.cpp
diff options
context:
space:
mode:
authorYehonal <yehonal.azeroth@gmail.com>2017-08-19 19:42:48 +0200
committerYehonal <yehonal.azeroth@gmail.com>2017-08-19 19:42:48 +0200
commitc1586e0d995de5dd278b0acfe410acf66f6c2c6d (patch)
tree5c66718c37379eda84669c1990c8d2f8fc0835d3 /src/authserver/Server/AuthSocket.cpp
parentf888e8c86b09d55587294921fbfeb58afb3d2282 (diff)
changed DISABLED_ cmake variable to ENABLED_ and implemented for all disabled logs
Diffstat (limited to 'src/authserver/Server/AuthSocket.cpp')
-rw-r--r--src/authserver/Server/AuthSocket.cpp136
1 files changed, 102 insertions, 34 deletions
diff --git a/src/authserver/Server/AuthSocket.cpp b/src/authserver/Server/AuthSocket.cpp
index b9671c0d12..d53f7fcc48 100644
--- a/src/authserver/Server/AuthSocket.cpp
+++ b/src/authserver/Server/AuthSocket.cpp
@@ -197,7 +197,9 @@ void AuthSocket::OnAccept(void)
void AuthSocket::OnClose(void)
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "AuthSocket::OnClose");
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "AuthSocket::OnClose");
+#endif
}
// Read the packet from the client
@@ -229,11 +231,15 @@ void AuthSocket::OnRead()
{
if ((uint8)table[i].cmd == _cmd && (table[i].status == _status))
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Got data for cmd %u recv length %u", (uint32)_cmd, (uint32)socket().recv_len());
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "Got data for cmd %u recv length %u", (uint32)_cmd, (uint32)socket().recv_len());
+#endif
if (!(*this.*table[i].handler)())
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Command handler failed for cmd %u recv length %u", (uint32)_cmd, (uint32)socket().recv_len());
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "Command handler failed for cmd %u recv length %u", (uint32)_cmd, (uint32)socket().recv_len());
+#endif
return;
}
break;
@@ -243,7 +249,9 @@ void AuthSocket::OnRead()
// Report unknown packets in the error log
if (i == AUTH_TOTAL_COMMANDS)
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Got unknown packet from '%s'", socket().getRemoteAddress().c_str());
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "Got unknown packet from '%s'", socket().getRemoteAddress().c_str());
+#endif
socket().shutdown();
return;
}
@@ -296,7 +304,9 @@ ACE_Thread_Mutex LastLoginAttemptMutex;
// Logon Challenge command handler
bool AuthSocket::_HandleLogonChallenge()
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleLogonChallenge");
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleLogonChallenge");
+#endif
if (socket().recv_len() < sizeof(sAuthLogonChallenge_C))
return false;
@@ -336,7 +346,9 @@ bool AuthSocket::_HandleLogonChallenge()
EndianConvertPtr<uint16>(&buf[0]);
uint16 remaining = ((sAuthLogonChallenge_C *)&buf[0])->size;
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] got header, body is %#04x bytes", remaining);
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] got header, body is %#04x bytes", remaining);
+#endif
if ((remaining < sizeof(sAuthLogonChallenge_C) - buf.size()) || (socket().recv_len() < remaining))
return false;
@@ -348,8 +360,12 @@ bool AuthSocket::_HandleLogonChallenge()
// Read the remaining of the packet
socket().recv((char *)&buf[4], remaining);
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] got full packet, %#04x bytes", ch->size);
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] name(%d): '%s'", ch->I_len, ch->I);
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] got full packet, %#04x bytes", ch->size);
+#endif
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] name(%d): '%s'", ch->I_len, ch->I);
+#endif
// BigEndian code, nop in little endian case
// size already converted
@@ -387,7 +403,9 @@ bool AuthSocket::_HandleLogonChallenge()
if (result)
{
pkt << uint8(WOW_FAIL_BANNED);
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] Banned ip tries to login!",socket().getRemoteAddress().c_str(), socket().getRemotePort());
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] Banned ip tries to login!",socket().getRemoteAddress().c_str(), socket().getRemotePort());
+#endif
}
else
{
@@ -405,20 +423,30 @@ bool AuthSocket::_HandleLogonChallenge()
bool locked = false;
if (fields[2].GetUInt8() == 1) // if ip is locked
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Account '%s' is locked to IP - '%s'", _login.c_str(), fields[3].GetCString());
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Player address is '%s'", ip_address.c_str());
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Account '%s' is locked to IP - '%s'", _login.c_str(), fields[3].GetCString());
+#endif
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Player address is '%s'", ip_address.c_str());
+#endif
if (strcmp(fields[3].GetCString(), ip_address.c_str()) != 0)
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Account IP differs");
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Account IP differs");
+#endif
pkt << uint8(WOW_FAIL_LOCKED_ENFORCED);
locked = true;
}
else
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Account IP matches");
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Account IP matches");
+#endif
}
else
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Account '%s' is not locked to ip", _login.c_str());
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] Account '%s' is not locked to ip", _login.c_str());
+#endif
if (!locked)
{
@@ -434,12 +462,16 @@ bool AuthSocket::_HandleLogonChallenge()
if ((*banresult)[0].GetUInt32() == (*banresult)[1].GetUInt32())
{
pkt << uint8(WOW_FAIL_BANNED);
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] Banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] Banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
+#endif
}
else
{
pkt << uint8(WOW_FAIL_SUSPENDED);
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] Temporarily banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] Temporarily banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
+#endif
}
}
else
@@ -451,7 +483,9 @@ bool AuthSocket::_HandleLogonChallenge()
std::string databaseV = fields[5].GetString();
std::string databaseS = fields[6].GetString();
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "database authentication values: v='%s' s='%s'", databaseV.c_str(), databaseS.c_str());
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "database authentication values: v='%s' s='%s'", databaseV.c_str(), databaseS.c_str());
+#endif
// multiply with 2 since bytes are stored as hexstring
if (databaseV.size() != s_BYTE_SIZE * 2 || databaseS.size() != s_BYTE_SIZE * 2)
@@ -513,7 +547,9 @@ bool AuthSocket::_HandleLogonChallenge()
for (int i = 0; i < 4; ++i)
_localizationName[i] = ch->country[4-i-1];
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] account %s is using '%c%c%c%c' locale (%u)", socket().getRemoteAddress().c_str(), socket().getRemotePort(),
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] account %s is using '%c%c%c%c' locale (%u)", socket().getRemoteAddress().c_str(), socket().getRemotePort(),
+#endif
// _login.c_str (), ch->country[3], ch->country[2], ch->country[1], ch->country[0], GetLocaleByName(_localizationName)
// );
@@ -533,7 +569,9 @@ bool AuthSocket::_HandleLogonChallenge()
// Logon Proof command handler
bool AuthSocket::_HandleLogonProof()
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleLogonProof");
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleLogonProof");
+#endif
// Read the packet
sAuthLogonProof_C lp;
@@ -546,7 +584,9 @@ bool AuthSocket::_HandleLogonProof()
if (_expversion == NO_VALID_EXP_FLAG)
{
// Check if we have the appropriate patch on the disk
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Client with invalid version, patching is not implemented");
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "Client with invalid version, patching is not implemented");
+#endif
socket().shutdown();
return true;
}
@@ -630,7 +670,9 @@ bool AuthSocket::_HandleLogonProof()
// Check if SRP6 results match (password is correct), else send an error
if (!memcmp(M.AsByteArray().get(), lp.M1, 20))
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' User '%s' successfully authenticated", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' User '%s' successfully authenticated", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
+#endif
// Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account
// No SQL injection (escaped user name) and IP address as received by socket
@@ -680,7 +722,9 @@ bool AuthSocket::_HandleLogonProof()
char data[4] = { AUTH_LOGON_PROOF, WOW_FAIL_UNKNOWN_ACCOUNT, 3, 0 };
socket().send(data, sizeof(data));
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] account %s tried to login with invalid password!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] account %s tried to login with invalid password!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
+#endif
uint32 MaxWrongPassCount = sConfigMgr->GetIntDefault("WrongPass.MaxCount", 0);
if (MaxWrongPassCount > 0)
@@ -710,7 +754,9 @@ bool AuthSocket::_HandleLogonProof()
stmt->setUInt32(1, WrongPassBanTime);
LoginDatabase.Execute(stmt);
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times",
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times",
+#endif
// socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str(), WrongPassBanTime, failed_logins);
}
else
@@ -720,7 +766,9 @@ bool AuthSocket::_HandleLogonProof()
stmt->setUInt32(1, WrongPassBanTime);
LoginDatabase.Execute(stmt);
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times",
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "'%s:%d' [AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times",
+#endif
// socket().getRemoteAddress().c_str(), socket().getRemotePort(), socket().getRemoteAddress().c_str(), WrongPassBanTime, _login.c_str(), failed_logins);
}
}
@@ -734,7 +782,9 @@ bool AuthSocket::_HandleLogonProof()
// Reconnect Challenge command handler
bool AuthSocket::_HandleReconnectChallenge()
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleReconnectChallenge");
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleReconnectChallenge");
+#endif
if (socket().recv_len() < sizeof(sAuthLogonChallenge_C))
return false;
@@ -747,7 +797,9 @@ bool AuthSocket::_HandleReconnectChallenge()
EndianConvertPtr<uint16>(&buf[0]);
uint16 remaining = ((sAuthLogonChallenge_C *)&buf[0])->size;
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "[ReconnectChallenge] got header, body is %#04x bytes", remaining);
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[ReconnectChallenge] got header, body is %#04x bytes", remaining);
+#endif
if ((remaining < sizeof(sAuthLogonChallenge_C) - buf.size()) || (socket().recv_len() < remaining))
return false;
@@ -762,8 +814,12 @@ bool AuthSocket::_HandleReconnectChallenge()
// Read the remaining of the packet
socket().recv((char *)&buf[4], remaining);
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "[ReconnectChallenge] got full packet, %#04x bytes", ch->size);
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "[ReconnectChallenge] name(%d): '%s'", ch->I_len, ch->I);
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[ReconnectChallenge] got full packet, %#04x bytes", ch->size);
+#endif
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "[ReconnectChallenge] name(%d): '%s'", ch->I_len, ch->I);
+#endif
_login = (const char*)ch->I;
@@ -813,7 +869,9 @@ bool AuthSocket::_HandleReconnectChallenge()
// Reconnect Proof command handler
bool AuthSocket::_HandleReconnectProof()
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleReconnectProof");
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleReconnectProof");
+#endif
// Read the packet
sAuthReconnectProof_C lp;
if (!socket().recv((char *)&lp, sizeof(sAuthReconnectProof_C)))
@@ -880,7 +938,9 @@ ACE_INET_Addr const& AuthSocket::GetAddressForClient(Realm const& realm, ACE_INE
// Realm List command handler
bool AuthSocket::_HandleRealmList()
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleRealmList");
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleRealmList");
+#endif
if (socket().recv_len() < 5)
return false;
@@ -1010,7 +1070,9 @@ bool AuthSocket::_HandleRealmList()
// Resume patch transfer
bool AuthSocket::_HandleXferResume()
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleXferResume");
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleXferResume");
+#endif
// Check packet length and patch existence
if (socket().recv_len() < 9 || !pPatch) // FIXME: pPatch is never used
{
@@ -1031,7 +1093,9 @@ bool AuthSocket::_HandleXferResume()
// Cancel patch transfer
bool AuthSocket::_HandleXferCancel()
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleXferCancel");
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleXferCancel");
+#endif
// Close and delete the socket
socket().recv_skip(1); //clear input buffer
@@ -1043,7 +1107,9 @@ bool AuthSocket::_HandleXferCancel()
// Accept patch transfer
bool AuthSocket::_HandleXferAccept()
{
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleXferAccept");
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleXferAccept");
+#endif
// Check packet length and patch existence
if (!pPatch)
@@ -1129,7 +1195,9 @@ void Patcher::LoadPatchMD5(char *szFileName)
std::string path = "./patches/";
path += szFileName;
FILE* pPatch = fopen(path.c_str(), "rb");
- ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Loading patch info from %s\n", path.c_str());
+#ifdef ENABLE_EXTRAS && ENABLE_EXTRA_LOGS
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "Loading patch info from %s\n", path.c_str());
+#endif
if (!pPatch)
{