26#include <boost/asio/buffer.hpp>
27#include <boost/asio/read_until.hpp>
31using boost::asio::ip::tcp;
38 for (
int counter = 0; counter < 10 &&
_socket.available() == 0; counter++)
39 std::this_thread::sleep_for(100ms);
46 _socket.read_some(boost::asio::buffer(buf));
49 uint8 const reply[2] = { 0xFF, 0xF0 };
50 _socket.write_some(boost::asio::buffer(reply));
53 Send(
"Authentication Required\r\n");
71 Send(
"Authentication failed\r\n");
79 for (std::string
const& line :
sWorld->GetMotd())
107 boost::system::error_code error;
117 std::getline(is, line);
119 if (*line.rbegin() ==
'\r')
120 line.erase(line.length() - 1);
127 std::string safeUser = user;
137 TC_LOG_INFO(
"commands.ra",
"User {} does not exist in database", user);
141 Field* fields = result->Fetch();
143 if (fields[1].GetUInt8() <
sConfigMgr->GetIntDefault(
"Ra.MinLevel", 3))
145 TC_LOG_INFO(
"commands.ra",
"User {} has no privilege to login", user);
148 else if (fields[2].GetInt32() != -1)
150 TC_LOG_INFO(
"commands.ra",
"User {} has to be assigned on all realms (with RealmID = '-1')", user);
159 std::string safe_user = user;
160 std::transform(safe_user.begin(), safe_user.end(), safe_user.begin(), ::toupper);
163 std::string safe_pass = pass;
165 std::transform(safe_pass.begin(), safe_pass.end(), safe_pass.begin(), ::toupper);
180 TC_LOG_INFO(
"commands.ra",
"Wrong password for user: {}", user);
186 if (command.length() == 0)
189 TC_LOG_INFO(
"commands.ra",
"Received command: {}", command);
192 if (command ==
"quit" || command ==
"exit" || command ==
"logout")
203 sWorld->QueueCliCommand(cmd);
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
#define TC_LOG_INFO(filterType__,...)
@ LOGIN_SEL_CHECK_PASSWORD_BY_NAME
@ LOGIN_SEL_ACCOUNT_ACCESS
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Class used to access individual fields of database query result.
void setString(uint8 index, std::string const &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 CheckPassword(const std::string &user, const std::string &pass)
bool ProcessCommand(std::string &command)
static void CommandPrint(void *callbackArg, std::string_view text)
const std::string GetRemoteIpAddress() const
static constexpr size_t SALT_LENGTH
static constexpr size_t VERIFIER_LENGTH
std::array< uint8, SALT_LENGTH > Salt
std::array< uint8, VERIFIER_LENGTH > Verifier
static bool CheckLogin(std::string const &username, std::string const &password, Salt const &salt, Verifier const &verifier)
Storage class for commands issued for delayed execution.