From 11c3c456b7e135cb749e65d47e39cdc8f267a599 Mon Sep 17 00:00:00 2001 From: Roc13x Date: Wed, 18 Apr 2018 18:27:45 +0100 Subject: Core/Bnet: Improve client ban messages (#21837) * Don't hide banned game accounts from list. * Display proper ban messages with suspension time remaining. * More appropriate error codes for bans and locks --- src/server/bnetserver/Server/Session.cpp | 22 +++++++++++++--------- src/server/bnetserver/Server/Session.h | 1 + .../Database/Implementation/LoginDatabase.cpp | 2 +- src/server/game/Server/WorldSocket.cpp | 12 ++++++------ 4 files changed, 21 insertions(+), 16 deletions(-) (limited to 'src/server') diff --git a/src/server/bnetserver/Server/Session.cpp b/src/server/bnetserver/Server/Session.cpp index d1106f7a42b..55a6827854a 100644 --- a/src/server/bnetserver/Server/Session.cpp +++ b/src/server/bnetserver/Server/Session.cpp @@ -52,11 +52,12 @@ void Battlenet::Session::AccountInfo::LoadResult(PreparedQueryResult result) void Battlenet::Session::GameAccountInfo::LoadResult(Field* fields) { - // a.id, a.username, ab.unbandate > UNIX_TIMESTAMP() OR ab.unbandate = ab.bandate, ab.unbandate = ab.bandate, aa.gmlevel + // a.id, a.username, ab.unbandate, ab.unbandate = ab.bandate, aa.gmlevel Id = fields[0].GetUInt32(); Name = fields[1].GetString(); - IsBanned = fields[2].GetUInt64() != 0; - IsPermanenetlyBanned = fields[3].GetUInt64() != 0; + UnbanDate = fields[2].GetUInt32(); + IsPermanenetlyBanned = fields[3].GetUInt32() != 0; + IsBanned = IsPermanenetlyBanned || UnbanDate > time(nullptr); SecurityLevel = AccountTypes(fields[4].GetUInt8()); std::size_t hashPos = Name.find('#'); @@ -371,12 +372,9 @@ uint32 Battlenet::Session::VerifyWebCredentials(std::string const& webCredential logonResult.mutable_account_id()->set_high(UI64LIT(0x100000000000000)); for (auto itr = _accountInfo->GameAccounts.begin(); itr != _accountInfo->GameAccounts.end(); ++itr) { - if (!itr->second.IsBanned) - { - EntityId* gameAccountId = logonResult.add_game_account_id(); - gameAccountId->set_low(itr->second.Id); - gameAccountId->set_high(UI64LIT(0x200000200576F57)); - } + EntityId* gameAccountId = logonResult.add_game_account_id(); + gameAccountId->set_low(itr->second.Id); + gameAccountId->set_high(UI64LIT(0x200000200576F57)); } if (!_ipCountry.empty()) @@ -436,6 +434,7 @@ uint32 Battlenet::Session::HandleGetGameAccountState(account::v1::GetGameAccount { response->mutable_state()->mutable_game_status()->set_is_suspended(itr->second.IsBanned); response->mutable_state()->mutable_game_status()->set_is_banned(itr->second.IsPermanenetlyBanned); + response->mutable_state()->mutable_game_status()->set_suspension_expires(uint64(itr->second.UnbanDate) * 1000000); } response->mutable_state()->mutable_game_status()->set_program(5730135); // WoW @@ -508,6 +507,11 @@ uint32 Battlenet::Session::GetRealmListTicket(std::unordered_mapIsPermanenetlyBanned) + return ERROR_GAME_ACCOUNT_BANNED; + else if (_gameAccountInfo->IsBanned) + return ERROR_GAME_ACCOUNT_SUSPENDED; + bool clientInfoOk = false; if (Variant const* clientInfo = GetParam(params, "Param_ClientInfo")) { diff --git a/src/server/bnetserver/Server/Session.h b/src/server/bnetserver/Server/Session.h index 88fd5c36cca..22b9e0a7b44 100644 --- a/src/server/bnetserver/Server/Session.h +++ b/src/server/bnetserver/Server/Session.h @@ -99,6 +99,7 @@ namespace Battlenet uint32 Id; std::string Name; std::string DisplayName; + uint32 UnbanDate; bool IsBanned; bool IsPermanenetlyBanned; AccountTypes SecurityLevel; diff --git a/src/server/database/Database/Implementation/LoginDatabase.cpp b/src/server/database/Database/Implementation/LoginDatabase.cpp index 782e128258d..04aa0578403 100644 --- a/src/server/database/Database/Implementation/LoginDatabase.cpp +++ b/src/server/database/Database/Implementation/LoginDatabase.cpp @@ -117,7 +117,7 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_DEL_ACCOUNT_MUTED, "DELETE FROM account_muted WHERE guid = ?", CONNECTION_ASYNC); #define BnetAccountInfo "ba.id, UPPER(ba.email), ba.locked, ba.lock_country, ba.last_ip, ba.LoginTicketExpiry, bab.unbandate > UNIX_TIMESTAMP() OR bab.unbandate = bab.bandate, bab.unbandate = bab.bandate" -#define BnetGameAccountInfo "a.id, a.username, ab.unbandate > UNIX_TIMESTAMP() OR ab.unbandate = ab.bandate, ab.unbandate = ab.bandate, aa.gmlevel" +#define BnetGameAccountInfo "a.id, a.username, ab.unbandate, ab.unbandate = ab.bandate, aa.gmlevel" PrepareStatement(LOGIN_SEL_BNET_AUTHENTICATION, "SELECT ba.id, ba.sha_pass_hash, ba.failed_logins, ba.LoginTicket, ba.LoginTicketExpiry, bab.unbandate > UNIX_TIMESTAMP() OR bab.unbandate = bab.bandate FROM battlenet_accounts ba LEFT JOIN battlenet_account_bans bab ON ba.id = bab.id WHERE email = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_BNET_AUTHENTICATION, "UPDATE battlenet_accounts SET LoginTicket = ?, LoginTicketExpiry = ? WHERE id = ?", CONNECTION_ASYNC); diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index 95848c9eb7c..d35d5f78298 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -633,8 +633,8 @@ struct AccountInfo Game.OS = fields[9].GetString(); BattleNet.Id = fields[10].GetUInt32(); Game.Security = AccountTypes(fields[11].GetUInt8()); - BattleNet.IsBanned = fields[12].GetUInt64() != 0; - Game.IsBanned = fields[13].GetUInt64() != 0; + BattleNet.IsBanned = fields[12].GetUInt32() != 0; + Game.IsBanned = fields[13].GetUInt32() != 0; Game.IsRectuiter = fields[14].GetUInt32() != 0; if (BattleNet.Locale >= TOTAL_LOCALES) @@ -754,7 +754,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptrOnFailedAccountLogin(account.Game.Id); @@ -766,7 +766,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptrOnFailedAccountLogin(account.Game.Id); @@ -789,7 +789,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptrOnFailedAccountLogin(account.Game.Id); DelayedCloseSocket(); @@ -801,7 +801,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr SEC_PLAYER && account.Game.Security < allowedAccountType) { - SendAuthResponseError(ERROR_DENIED); + SendAuthResponseError(ERROR_SERVER_IS_PRIVATE); TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: User tries to login but his security level is not enough"); sScriptMgr->OnFailedAccountLogin(account.Game.Id); DelayedCloseSocket(); -- cgit v1.2.3