25#include <boost/asio/buffer.hpp>
26#include <boost/asio/read_until.hpp>
33 for (
int counter = 0; counter < 10 &&
_socket.available() == 0; counter++)
34 std::this_thread::sleep_for(std::chrono::milliseconds(100));
41 _socket.read_some(boost::asio::buffer(buf));
44 uint8 const reply[2] = { 0xFF, 0xF0 };
45 _socket.write_some(boost::asio::buffer(reply));
48 Send(
"Authentication Required\r\n");
66 Send(
"Authentication failed\r\n");
74 for (std::string
const& line :
sWorld->GetMotd())
102 boost::system::error_code error;
112 std::getline(is, line);
114 if (*line.rbegin() ==
'\r')
115 line.erase(line.length() - 1);
122 std::string safeUser = user;
132 TC_LOG_INFO(
"commands.ra",
"User {} does not exist in database", user);
136 Field* fields = result->Fetch();
140 TC_LOG_INFO(
"commands.ra",
"User {} has no privilege to login", user);
143 else if (fields[2].GetInt32() != -1)
145 TC_LOG_INFO(
"commands.ra",
"User {} has to be assigned on all realms (with RealmID = '-1')", user);
154 if (command.length() == 0)
157 TC_LOG_INFO(
"commands.ra",
"Received command: {}", command);
160 if (command ==
"quit" || command ==
"exit" || command ==
"logout")
171 sWorld->QueueCliCommand(cmd);
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
#define TC_LOG_INFO(filterType__,...)
@ 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(const uint8 index, const std::string &value)
int Send(std::string_view data)
boost::asio::ip::tcp::socket _socket
std::string GetRemoteIpAddress() const
static void CommandFinished(void *callbackArg, bool)
bool CheckAccessLevel(const std::string &user)
std::promise< void > * _commandExecuting
boost::asio::streambuf _writeBuffer
boost::asio::streambuf _readBuffer
bool ProcessCommand(std::string &command)
static void CommandPrint(void *callbackArg, std::string_view text)
Storage class for commands issued for delayed execution.