26#include <boost/asio/buffer.hpp>
27#include <boost/asio/read_until.hpp>
36 for (
int counter = 0; counter < 10 &&
_socket.available() == 0; counter++)
37 std::this_thread::sleep_for(100ms);
44 _socket.read_some(boost::asio::buffer(buf));
47 uint8 const reply[2] = { 0xFF, 0xF0 };
48 _socket.write_some(boost::asio::buffer(reply));
51 Send(
"Authentication Required\r\n");
69 Send(
"Authentication failed\r\n");
77 for (std::string
const& line :
sWorld->GetMotd())
105 boost::system::error_code error;
115 std::getline(is, line);
117 if (*line.rbegin() ==
'\r')
118 line.erase(line.length() - 1);
125 std::string safeUser = user;
135 TC_LOG_INFO(
"commands.ra",
"User {} does not exist in database", user);
139 Field* fields = result->Fetch();
143 TC_LOG_INFO(
"commands.ra",
"User {} has no privilege to login", user);
146 else if (fields[2].GetInt32() != -1)
148 TC_LOG_INFO(
"commands.ra",
"User {} has to be assigned on all realms (with RealmID = '-1')", user);
157 if (command.length() == 0)
160 TC_LOG_INFO(
"commands.ra",
"Received command: {}", command);
163 if (command ==
"quit" || command ==
"exit" || command ==
"logout")
174 sWorld->QueueCliCommand(cmd);
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
#define TC_LOG_INFO(filterType__, message__,...)
@ LOGIN_SEL_ACCOUNT_ACCESS
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
static bool CheckPassword(std::string username, std::string password)
Class used to access individual fields of database query result.
void setString(uint8 index, std::string &&value)
int Send(std::string_view data)
static void CommandFinished(void *callbackArg, bool)
bool CheckAccessLevel(const std::string &user)
std::promise< void > * _commandExecuting
boost::asio::streambuf _writeBuffer
boost::asio::streambuf _readBuffer
Trinity::Net::IoContextTcpSocket _socket
bool ProcessCommand(std::string &command)
static void CommandPrint(void *callbackArg, std::string_view text)
boost::asio::ip::address GetRemoteIpAddress() const
Storage class for commands issued for delayed execution.