mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[8823] removed ban-cleanup queries from realmd at login
now they just getting executed when realmd is started i think this will improve speed a bit.. cause we don't need to cleanup those bans so often we just can check the conditions inside the select
This commit is contained in:
parent
31a2996374
commit
fbe9241a96
3 changed files with 14 additions and 10 deletions
|
|
@ -379,11 +379,11 @@ 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
|
||||||
// No SQL injection possible (paste the IP address as passed by the socket)
|
// No SQL injection possible (paste the IP address as passed by the socket)
|
||||||
loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
|
||||||
|
|
||||||
std::string address = GetRemoteAddress();
|
std::string address = GetRemoteAddress();
|
||||||
loginDatabase.escape_string(address);
|
loginDatabase.escape_string(address);
|
||||||
QueryResult *result = loginDatabase.PQuery( "SELECT * FROM ip_banned WHERE ip = '%s'",address.c_str());
|
QueryResult *result = loginDatabase.PQuery("SELECT unbandate FROM ip_banned WHERE "
|
||||||
|
// permanent still banned
|
||||||
|
"(unbandate = bandate OR unbandate > UNIX_TIMESTAMP()) AND ip = '%s'", address.c_str());
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
pkt << (uint8)REALM_AUTH_ACCOUNT_BANNED;
|
pkt << (uint8)REALM_AUTH_ACCOUNT_BANNED;
|
||||||
|
|
@ -422,13 +422,12 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||||
|
|
||||||
if (!locked)
|
if (!locked)
|
||||||
{
|
{
|
||||||
//set expired bans to inactive
|
|
||||||
loginDatabase.Execute("UPDATE account_banned SET active = 0 WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
|
||||||
///- If the account is banned, reject the logon attempt
|
///- If the account is banned, reject the logon attempt
|
||||||
QueryResult *banresult = loginDatabase.PQuery("SELECT bandate,unbandate FROM account_banned WHERE id = %u AND active = 1", (*result)[1].GetUInt32());
|
QueryResult *banresult = loginDatabase.PQuery("SELECT bandate,unbandate FROM account_banned WHERE "
|
||||||
|
"id = %u AND active = 1 AND (unbandate > UNIX_TIMESTAMP() OR unbandate = bandate)", (*result)[1].GetUInt32());
|
||||||
if(banresult)
|
if(banresult)
|
||||||
{
|
{
|
||||||
if((*banresult)[0].GetUInt64() == (*banresult)[1].GetUInt64())
|
if((*banresult)[0].GetUInt64() != (*banresult)[1].GetUInt64())
|
||||||
{
|
{
|
||||||
pkt << (uint8) REALM_AUTH_ACCOUNT_BANNED;
|
pkt << (uint8) REALM_AUTH_ACCOUNT_BANNED;
|
||||||
sLog.outBasic("[AuthChallenge] Banned account %s tries to login!",_login.c_str ());
|
sLog.outBasic("[AuthChallenge] Banned account %s tries to login!",_login.c_str ());
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,11 @@ extern int main(int argc, char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cleanup query
|
||||||
|
//set expired bans to inactive
|
||||||
|
loginDatabase.Execute("UPDATE account_banned SET active = 0 WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||||
|
loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||||
|
|
||||||
h.Add(&authListenSocket);
|
h.Add(&authListenSocket);
|
||||||
|
|
||||||
///- Catch termination signals
|
///- Catch termination signals
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "8822"
|
#define REVISION_NR "8823"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue