Core/AuthServer: Streamlined authserver log messages (added client port for easier identification and matching for multiple connections from same IP)
This commit is contained in:
@@ -209,7 +209,7 @@ AuthSocket::~AuthSocket(void) {}
|
|||||||
// Accept the connection and set the s random value for SRP6
|
// Accept the connection and set the s random value for SRP6
|
||||||
void AuthSocket::OnAccept(void)
|
void AuthSocket::OnAccept(void)
|
||||||
{
|
{
|
||||||
sLog->outBasic("Accepting connection from '%s'", socket().get_remote_address().c_str());
|
sLog->outBasic("'%s:%d' Accepting connection", socket().getRemoteAddress().c_str(), socket().getRemotePort());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuthSocket::OnClose(void)
|
void AuthSocket::OnClose(void)
|
||||||
@@ -247,7 +247,7 @@ void AuthSocket::OnRead()
|
|||||||
// Report unknown packets in the error log
|
// Report unknown packets in the error log
|
||||||
if (i == AUTH_TOTAL_COMMANDS)
|
if (i == AUTH_TOTAL_COMMANDS)
|
||||||
{
|
{
|
||||||
sLog->outError("[Auth] got unknown packet from '%s'", socket().get_remote_address().c_str());
|
sLog->outError("[Auth] got unknown packet from '%s'", socket().getRemoteAddress().c_str());
|
||||||
socket().shutdown();
|
socket().shutdown();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -350,14 +350,14 @@ bool AuthSocket::_HandleLogonChallenge()
|
|||||||
// Verify that this IP is not in the ip_banned table
|
// Verify that this IP is not in the ip_banned table
|
||||||
LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS));
|
LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS));
|
||||||
|
|
||||||
const std::string& ip_address = socket().get_remote_address();
|
const std::string& ip_address = socket().getRemoteAddress();
|
||||||
PreparedStatement *stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED);
|
PreparedStatement *stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED);
|
||||||
stmt->setString(0, ip_address);
|
stmt->setString(0, ip_address);
|
||||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
pkt << (uint8)WOW_FAIL_BANNED;
|
pkt << (uint8)WOW_FAIL_BANNED;
|
||||||
sLog->outBasic("[AuthChallenge] Banned ip %s tried to login!", ip_address.c_str());
|
sLog->outBasic("'%s:%d' [AuthChallenge] Banned ip tries to login!",socket().getRemoteAddress().c_str(), socket().getRemotePort());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -404,12 +404,12 @@ bool AuthSocket::_HandleLogonChallenge()
|
|||||||
if ((*banresult)[0].GetUInt64() == (*banresult)[1].GetUInt64())
|
if ((*banresult)[0].GetUInt64() == (*banresult)[1].GetUInt64())
|
||||||
{
|
{
|
||||||
pkt << (uint8)WOW_FAIL_BANNED;
|
pkt << (uint8)WOW_FAIL_BANNED;
|
||||||
sLog->outBasic("[AuthChallenge] Banned account %s tried to login!", _login.c_str());
|
sLog->outBasic("'%s:%d' [AuthChallenge] Banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pkt << (uint8)WOW_FAIL_SUSPENDED;
|
pkt << (uint8)WOW_FAIL_SUSPENDED;
|
||||||
sLog->outBasic("[AuthChallenge] Temporarily banned account %s tried to login!", _login.c_str());
|
sLog->outBasic("'%s:%d' [AuthChallenge] Temporarily banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -480,7 +480,9 @@ bool AuthSocket::_HandleLogonChallenge()
|
|||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
_localizationName[i] = ch->country[4-i-1];
|
_localizationName[i] = ch->country[4-i-1];
|
||||||
|
|
||||||
sLog->outBasic("[AuthChallenge] account %s is using '%c%c%c%c' locale (%u)", _login.c_str (), ch->country[3], ch->country[2], ch->country[1], ch->country[0], GetLocaleByName(_localizationName));
|
sLog->outBasic("'%s:%d' [AuthChallenge] account %s is using '%c%c%c%c' locale (%u)", socket().getRemoteAddress().c_str(), socket().getRemotePort(),
|
||||||
|
_login.c_str (), ch->country[3], ch->country[2], ch->country[1], ch->country[0], GetLocaleByName(_localizationName)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -590,7 +592,7 @@ bool AuthSocket::_HandleLogonProof()
|
|||||||
// Check if SRP6 results match (password is correct), else send an error
|
// Check if SRP6 results match (password is correct), else send an error
|
||||||
if (!memcmp(M.AsByteArray(), lp.M1, 20))
|
if (!memcmp(M.AsByteArray(), lp.M1, 20))
|
||||||
{
|
{
|
||||||
sLog->outBasic("User '%s' successfully authenticated", _login.c_str());
|
sLog->outBasic("'%s:%d' User '%s' successfully authenticated", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
|
||||||
|
|
||||||
// Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account
|
// 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
|
// No SQL injection (escaped user name) and IP address as received by socket
|
||||||
@@ -598,7 +600,7 @@ bool AuthSocket::_HandleLogonProof()
|
|||||||
|
|
||||||
PreparedStatement *stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LOGONPROOF);
|
PreparedStatement *stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LOGONPROOF);
|
||||||
stmt->setString(0, K_hex);
|
stmt->setString(0, K_hex);
|
||||||
stmt->setString(1, socket().get_remote_address().c_str());
|
stmt->setString(1, socket().getRemoteAddress().c_str());
|
||||||
stmt->setUInt32(2, GetLocaleByName(_localizationName));
|
stmt->setUInt32(2, GetLocaleByName(_localizationName));
|
||||||
stmt->setString(3, _login);
|
stmt->setString(3, _login);
|
||||||
LoginDatabase.Execute(stmt);
|
LoginDatabase.Execute(stmt);
|
||||||
@@ -638,7 +640,7 @@ bool AuthSocket::_HandleLogonProof()
|
|||||||
char data[4] = { AUTH_LOGON_PROOF, WOW_FAIL_UNKNOWN_ACCOUNT, 3, 0 };
|
char data[4] = { AUTH_LOGON_PROOF, WOW_FAIL_UNKNOWN_ACCOUNT, 3, 0 };
|
||||||
socket().send(data, sizeof(data));
|
socket().send(data, sizeof(data));
|
||||||
|
|
||||||
sLog->outBasic("[AuthChallenge] account %s tried to login with wrong password!", _login.c_str());
|
sLog->outBasic("'%s:%d' [AuthChallenge] account %s tried to login with invalid password!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
|
||||||
|
|
||||||
uint32 MaxWrongPassCount = ConfigMgr::GetIntDefault("WrongPass.MaxCount", 0);
|
uint32 MaxWrongPassCount = ConfigMgr::GetIntDefault("WrongPass.MaxCount", 0);
|
||||||
if (MaxWrongPassCount > 0)
|
if (MaxWrongPassCount > 0)
|
||||||
@@ -668,17 +670,18 @@ bool AuthSocket::_HandleLogonProof()
|
|||||||
stmt->setUInt32(1, WrongPassBanTime);
|
stmt->setUInt32(1, WrongPassBanTime);
|
||||||
LoginDatabase.Execute(stmt);
|
LoginDatabase.Execute(stmt);
|
||||||
|
|
||||||
sLog->outBasic("[AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times",
|
sLog->outBasic("'%s:%d' [AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times",
|
||||||
_login.c_str(), WrongPassBanTime, failed_logins);
|
socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str(), WrongPassBanTime, failed_logins);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_IP_AUTO_BANNED);
|
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_IP_AUTO_BANNED);
|
||||||
stmt->setString(0, socket().get_remote_address());
|
stmt->setString(0, socket().getRemoteAddress());
|
||||||
stmt->setUInt32(1, WrongPassBanTime);
|
stmt->setUInt32(1, WrongPassBanTime);
|
||||||
LoginDatabase.Execute(stmt);
|
LoginDatabase.Execute(stmt);
|
||||||
|
|
||||||
sLog->outBasic("[AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times", socket().get_remote_address().c_str(), WrongPassBanTime, _login.c_str(), failed_logins);
|
sLog->outBasic("'%s:%d' [AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times",
|
||||||
|
socket().getRemoteAddress().c_str(), socket().getRemotePort(), socket().getRemoteAddress().c_str(), WrongPassBanTime, _login.c_str(), failed_logins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -730,7 +733,7 @@ bool AuthSocket::_HandleReconnectChallenge()
|
|||||||
// Stop if the account is not found
|
// Stop if the account is not found
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
sLog->outError("[ERROR] user %s tried to login and we cannot find his session key in the database.", _login.c_str());
|
sLog->outError("'%s:%d' [ERROR] user %s tried to login and we cannot find his session key in the database.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
|
||||||
socket().shutdown();
|
socket().shutdown();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -790,7 +793,7 @@ bool AuthSocket::_HandleReconnectProof()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sLog->outError("[ERROR] user %s tried to login, but session invalid.", _login.c_str());
|
sLog->outError("'%s:%d' [ERROR] user %s tried to login, but session is invalid.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
|
||||||
socket().shutdown();
|
socket().shutdown();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -812,7 +815,7 @@ bool AuthSocket::_HandleRealmList()
|
|||||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
sLog->outError("[ERROR] user %s tried to login and we cannot find him in the database.", _login.c_str());
|
sLog->outError("'%s:%d' [ERROR] user %s tried to login but we cannot find him in the database.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
|
||||||
socket().shutdown();
|
socket().shutdown();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ RealmSocket::Session::Session(void) {}
|
|||||||
|
|
||||||
RealmSocket::Session::~Session(void) { }
|
RealmSocket::Session::~Session(void) { }
|
||||||
|
|
||||||
RealmSocket::RealmSocket(void) : input_buffer_(4096), session_(NULL), remote_address_()
|
RealmSocket::RealmSocket(void) : input_buffer_(4096), session_(NULL), _remoteAddress()
|
||||||
{
|
{
|
||||||
reference_counting_policy().value(ACE_Event_Handler::Reference_Counting_Policy::ENABLED);
|
reference_counting_policy().value(ACE_Event_Handler::Reference_Counting_Policy::ENABLED);
|
||||||
|
|
||||||
@@ -63,7 +63,8 @@ int RealmSocket::open(void * arg)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
remote_address_ = addr.get_host_addr();
|
_remoteAddress = addr.get_host_addr();
|
||||||
|
_remotePort = addr.get_port_number();
|
||||||
|
|
||||||
// Register with ACE Reactor
|
// Register with ACE Reactor
|
||||||
if (Base::open(arg) == -1)
|
if (Base::open(arg) == -1)
|
||||||
@@ -89,9 +90,14 @@ int RealmSocket::close(int)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& RealmSocket::get_remote_address(void) const
|
const std::string& RealmSocket::getRemoteAddress(void) const
|
||||||
{
|
{
|
||||||
return remote_address_;
|
return _remoteAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint16 RealmSocket::getRemotePort(void) const
|
||||||
|
{
|
||||||
|
return _remotePort;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t RealmSocket::recv_len(void) const
|
size_t RealmSocket::recv_len(void) const
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ public:
|
|||||||
|
|
||||||
bool send(const char *buf, size_t len);
|
bool send(const char *buf, size_t len);
|
||||||
|
|
||||||
const std::string& get_remote_address(void) const;
|
const std::string& getRemoteAddress(void) const;
|
||||||
|
|
||||||
|
const uint16 getRemotePort(void) const;
|
||||||
|
|
||||||
virtual int open(void *);
|
virtual int open(void *);
|
||||||
|
|
||||||
@@ -70,7 +72,8 @@ private:
|
|||||||
|
|
||||||
ACE_Message_Block input_buffer_;
|
ACE_Message_Block input_buffer_;
|
||||||
Session* session_;
|
Session* session_;
|
||||||
std::string remote_address_;
|
std::string _remoteAddress;
|
||||||
|
uint16 _remotePort;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __REALMSOCKET_H__ */
|
#endif /* __REALMSOCKET_H__ */
|
||||||
|
|||||||
Reference in New Issue
Block a user