#include <RASession.h>
RASession::RASession |
( |
tcp::socket && |
socket | ) |
|
|
inline |
tcp::socket _socket
Definition: RASession.h:55
std::promise< void > * _commandExecuting
Definition: RASession.h:58
bool RASession::CheckAccessLevel |
( |
const std::string & |
user | ) |
|
|
private |
124 std::string safeUser = user;
134 TC_LOG_INFO(
"commands.ra",
"User %s does not exist in database", user.c_str());
138 Field* fields = result->Fetch();
140 if (fields[1].GetUInt8() <
sConfigMgr->GetIntDefault(
"RA.MinLevel", 3))
142 TC_LOG_INFO(
"commands.ra",
"User %s has no privilege to login", user.c_str());
145 else if (fields[2].GetInt32() != -1)
147 TC_LOG_INFO(
"commands.ra",
"User %s has to be assigned on all realms (with RealmID = '-1')", user.c_str());
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
Class used to access individual fields of database query result.
Definition: Field.h:56
#define sConfigMgr
Definition: Config.h:61
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: PreparedStatement.h:74
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
Definition: LoginDatabase.h:91
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:498
bool RASession::CheckPassword |
( |
const std::string & |
user, |
|
|
const std::string & |
pass |
|
) |
| |
|
private |
156 std::string safe_user = user;
159 std::string safe_pass = pass;
173 TC_LOG_INFO(
"commands.ra",
"Wrong password for user: %s", user.c_str());
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
#define hash
Definition: private_namespace.h:186
Definition: LoginDatabase.h:85
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
static std::string CalculateShaPassHash(std::string const &name, std::string const &password)
Definition: AccountMgr.cpp:378
Definition: PreparedStatement.h:74
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:498
void RASession::CommandFinished |
( |
void * |
callbackArg, |
|
|
bool |
|
|
) |
| |
|
staticprivate |
Definition: RASession.h:33
std::promise< void > * _commandExecuting
Definition: RASession.h:58
void RASession::CommandPrint |
( |
void * |
callbackArg, |
|
|
const char * |
text |
|
) |
| |
|
staticprivate |
int Send(const char *data)
Definition: RASession.cpp:93
Definition: RASession.h:33
const std::string RASession::GetRemoteIpAddress |
( |
| ) |
const |
|
inline |
42 {
return _socket.remote_endpoint().address().to_string(); }
tcp::socket _socket
Definition: RASession.h:55
unsigned short RASession::GetRemotePort |
( |
| ) |
const |
|
inline |
43 {
return _socket.remote_endpoint().port(); }
tcp::socket _socket
Definition: RASession.h:55
bool RASession::ProcessCommand |
( |
std::string & |
command | ) |
|
|
private |
182 if (command.length() == 0)
185 TC_LOG_INFO(
"commands.ra",
"Received command: %s", command.c_str());
188 if (command ==
"quit" || command ==
"exit" || command ==
"logout")
199 sWorld->QueueCliCommand(cmd);
int Send(const char *data)
Definition: RASession.cpp:93
static void CommandPrint(void *callbackArg, const char *text)
Definition: RASession.cpp:207
#define sWorld
Definition: World.h:887
Storage class for commands issued for delayed execution.
Definition: World.h:507
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
std::promise< void > * _commandExecuting
Definition: RASession.h:58
static void CommandFinished(void *callbackArg, bool)
Definition: RASession.cpp:216
std::string RASession::ReadString |
( |
| ) |
|
|
private |
104 boost::system::error_code error;
114 std::getline(is, line);
116 if (*line.rbegin() ==
'\r')
117 line.erase(line.length() - 1);
boost::asio::streambuf _readBuffer
Definition: RASession.h:56
tcp::socket _socket
Definition: RASession.h:55
int RASession::Send |
( |
const char * |
data | ) |
|
|
private |
tcp::socket _socket
Definition: RASession.h:55
boost::asio::streambuf _writeBuffer
Definition: RASession.h:57
void RASession::Start |
( |
| ) |
|
35 for (
int counter = 0; counter < 10 &&
_socket.available() == 0; counter++)
42 boost::array<char, 1024> buf;
43 _socket.read_some(boost::asio::buffer(buf));
46 uint8 const reply[2] = { 0xFF, 0xF0 };
47 _socket.write_some(boost::asio::buffer(reply));
50 Send(
"Authentication Required\r\n");
68 Send(
"Authentication failed\r\n");
76 for (std::string
const& line :
sWorld->GetMotd())
int Send(const char *data)
Definition: RASession.cpp:93
const std::string GetRemoteIpAddress() const
Definition: RASession.h:42
#define sWorld
Definition: World.h:887
bool CheckPassword(const std::string &user, const std::string &pass)
Definition: RASession.cpp:154
bool ProcessCommand(std::string &command)
Definition: RASession.cpp:180
float milliseconds()
Definition: units.h:92
bool CheckAccessLevel(const std::string &user)
Definition: RASession.cpp:122
uint8_t uint8
Definition: Define.h:152
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
std::string ReadString()
Definition: RASession.cpp:102
tcp::socket _socket
Definition: RASession.h:55
std::promise<void>* RASession::_commandExecuting |
|
private |
boost::asio::streambuf RASession::_readBuffer |
|
private |
tcp::socket RASession::_socket |
|
private |
boost::asio::streambuf RASession::_writeBuffer |
|
private |
The documentation for this class was generated from the following files: