// Get the first word of the command.
size_t split = command.find_first_of(' ');
if (split != StringView::npos)
{
StringView commandName = trim(command.substr(0, split));
StringView password = trim(command.substr(split + 1));
if (commandName == "login")
{
StringView rconPassword = self.core->getConfig().getString("rcon.password");
bool success = false;
if (rconPassword == "")
{
peer.sendClientMessage(Colour::White(), "SERVER: Server's rcon password is empty.");
success = false;
}
else
{
if (password == rconPassword)
{
pdata->setConsoleAccessibility(true);
self.core->logLn(LogLevel::Warning, "RCON (In-Game): Player #%d (%.*s) has logged in.", peer.getID(), PRINT_VIEW(peer.getName()));
peer.sendClientMessage(Colour::White(), "SERVER: You are logged in as admin.");
success = true;
}
else
{
self.core->logLn(LogLevel::Warning, "RCON (In-Game): Player #%d (%.*s) failed login.", peer.getID(), PRINT_VIEW(peer.getName()));
peer.sendClientMessage(Colour::White(), "SERVER: Bad admin password. Repeated attempts will get you banned.");
success = false;
}
}
self.eventDispatcher.all(
[&peer, password, success](ConsoleEventHandler* handler)
{
handler->onRconLoginAttempt(peer, password, success);
});
}
}