feat(Core/Commands): add ".server set security" to set realm security level (#26649)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Andrew
2026-07-18 14:39:44 -03:00
committed by GitHub
parent c6dc7f8f23
commit 02afbec99d
7 changed files with 48 additions and 0 deletions

View File

@@ -116,6 +116,7 @@ void LoginDatabaseConnection::DoPrepareStatements()
PrepareStatement(LOGIN_SEL_LAST_ATTEMPT_IP, "SELECT last_attempt_ip FROM account WHERE id = ?", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_LAST_IP, "SELECT last_ip FROM account WHERE id = ?", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_REALMLIST_SECURITY_LEVEL, "SELECT allowedSecurityLevel from realmlist WHERE id = ?", CONNECTION_SYNCH);
PrepareStatement(LOGIN_UPD_REALMLIST_SECURITY_LEVEL, "UPDATE realmlist SET allowedSecurityLevel = ? WHERE id = ?", CONNECTION_ASYNC);
PrepareStatement(LOGIN_DEL_ACCOUNT, "DELETE FROM account WHERE id = ?", CONNECTION_ASYNC);
PrepareStatement(LOGIN_SEL_AUTOBROADCAST, "SELECT id, weight, text FROM autobroadcast WHERE realmid = ? OR realmid = -1", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_AUTOBROADCAST_LOCALIZED, "SELECT id, locale, text FROM autobroadcast_locale WHERE realmid = ? OR realmid = -1", CONNECTION_SYNCH);

View File

@@ -98,6 +98,7 @@ enum LoginDatabaseStatements : uint32
LOGIN_SEL_BANS,
LOGIN_SEL_ACCOUNT_WHOIS,
LOGIN_SEL_REALMLIST_SECURITY_LEVEL,
LOGIN_UPD_REALMLIST_SECURITY_LEVEL,
LOGIN_DEL_ACCOUNT,
LOGIN_SEL_AUTOBROADCAST,
LOGIN_SEL_AUTOBROADCAST_LOCALIZED,

View File

@@ -700,6 +700,7 @@ enum RBACPermissions
RBAC_PERM_COMMAND_SPELLINFO_EFFECTS = 936,
RBAC_PERM_COMMAND_SPELLINFO_TARGETS = 937,
RBAC_PERM_COMMAND_SPELLINFO_ALL = 938,
RBAC_PERM_COMMAND_SERVER_SET_SECURITY = 939,
// custom permissions 1000+
RBAC_PERM_MAX
};

View File

@@ -1400,6 +1400,10 @@ enum AcoreStrings
LANG_LFG_COOLDOWN_CLEARED = 11019,
LANG_COMMAND_SERVER_SET_SECURITY = 11020,
LANG_COMMAND_SERVER_SET_SECURITY_ERROR = 11021,
LANG_COMMAND_SERVER_INFO_SECURITY = 11022,
LANG_MUTED_PLAYER = 30000, // Mute for player 2 hour
// Instant Flight

View File

@@ -76,6 +76,7 @@ public:
{ "loglevel", HandleServerSetLogLevelCommand, rbac::RBAC_PERM_COMMAND_SERVER_SET_LOGLEVEL, Console::Yes },
{ "motd", HandleServerSetMotdCommand, rbac::RBAC_PERM_COMMAND_SERVER_SET_MOTD, Console::Yes },
{ "closed", HandleServerSetClosedCommand, rbac::RBAC_PERM_COMMAND_SERVER_SET_CLOSED, Console::Yes },
{ "security", HandleServerSetSecurityCommand, rbac::RBAC_PERM_COMMAND_SERVER_SET_SECURITY, Console::Yes },
};
static ChatCommandTable serverCommandTable =
@@ -270,6 +271,7 @@ public:
handler->PSendSysMessage("Connected players: {}. Characters in world: {}. Queue: {}.", activeSessionCount, playerCount, queuedSessionCount);
handler->PSendSysMessage("Connection peak: {}.", connPeak);
handler->PSendSysMessage(LANG_COMMAND_SERVER_INFO_SECURITY, uint32(sWorld->GetPlayerSecurityLimit()));
handler->PSendSysMessage(LANG_UPTIME, secsToTimeString(GameTime::GetUptime().count()));
handler->PSendSysMessage("Update time diff: {}ms. Last {} diffs summary:", sWorldUpdateTime.GetLastUpdateTime(), sWorldUpdateTime.GetDatasetSize());
handler->PSendSysMessage("|- Mean: {}ms", sWorldUpdateTime.GetAverageUpdateTime());
@@ -600,6 +602,27 @@ public:
return false;
}
// Set the minimum security level allowed to log into this realm (realmlist.allowedSecurityLevel)
static bool HandleServerSetSecurityCommand(ChatHandler* handler, uint8 level)
{
if (level > SEC_ADMINISTRATOR)
{
handler->SendErrorMessage(LANG_COMMAND_SERVER_SET_SECURITY_ERROR, SEC_PLAYER, SEC_ADMINISTRATOR);
return false;
}
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_REALMLIST_SECURITY_LEVEL);
stmt->SetData(0, level);
stmt->SetData(1, realm.Id.Realm);
LoginDatabase.Execute(stmt);
// Apply live; raising the limit kicks any now-disallowed sessions.
sWorld->SetPlayerSecurityLimit(AccountTypes(level));
handler->PSendSysMessage(LANG_COMMAND_SERVER_SET_SECURITY, level);
return true;
}
// Set the level of logging
static bool HandleServerSetLogLevelCommand(ChatHandler* /*handler*/, bool isLogger, std::string const& name, int32 level)
{