mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Additional RCON system cleanup
This commit is contained in:
parent
9775fc4bba
commit
5bd6432862
@ -290,43 +290,43 @@ void CRConClient::ProcessMessage(const sv_rcon::response& sv_response) const
|
||||
case sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG:
|
||||
{
|
||||
// !TODO: Network the enum for this.
|
||||
if (strstr(svOut.c_str(), SQVM_LOG_T[0].c_str()))
|
||||
if (svOut.find(SQVM_LOG_T[0]))
|
||||
{
|
||||
SQVM_PrintFunc(nullptr, const_cast<char*>("%s"), svOut.c_str());
|
||||
}
|
||||
else // This has to be done for RUI color logging.
|
||||
{
|
||||
if (strstr(svOut.c_str(), sDLL_T[0].c_str()))
|
||||
if (svOut.find(sDLL_T[0]))
|
||||
{
|
||||
StringReplace(svOut, sDLL_T[0], "");
|
||||
DevMsg(eDLL_T::SERVER, "%s", svOut.c_str());
|
||||
}
|
||||
if (strstr(svOut.c_str(), sDLL_T[1].c_str()))
|
||||
if (svOut.find(sDLL_T[1]))
|
||||
{
|
||||
StringReplace(svOut, sDLL_T[1], "");
|
||||
DevMsg(eDLL_T::CLIENT, "%s", svOut.c_str());
|
||||
}
|
||||
if (strstr(svOut.c_str(), sDLL_T[2].c_str()))
|
||||
if (svOut.find(sDLL_T[2]))
|
||||
{
|
||||
StringReplace(svOut, sDLL_T[2], "");
|
||||
DevMsg(eDLL_T::UI, "%s", svOut.c_str());
|
||||
}
|
||||
if (strstr(svOut.c_str(), sDLL_T[3].c_str()))
|
||||
if (svOut.find(sDLL_T[3]))
|
||||
{
|
||||
StringReplace(svOut, sDLL_T[3], "");
|
||||
DevMsg(eDLL_T::ENGINE, "%s", svOut.c_str());
|
||||
}
|
||||
if (strstr(svOut.c_str(), sDLL_T[4].c_str()))
|
||||
if (svOut.find(sDLL_T[4]))
|
||||
{
|
||||
StringReplace(svOut, sDLL_T[4], "");
|
||||
DevMsg(eDLL_T::FS, "%s", svOut.c_str());
|
||||
}
|
||||
if (strstr(svOut.c_str(), sDLL_T[5].c_str()))
|
||||
if (svOut.find(sDLL_T[5]))
|
||||
{
|
||||
StringReplace(svOut, sDLL_T[5], "");
|
||||
DevMsg(eDLL_T::RTECH, "%s", svOut.c_str());
|
||||
}
|
||||
if (strstr(svOut.c_str(), sDLL_T[6].c_str()))
|
||||
if (svOut.find(sDLL_T[6]))
|
||||
{
|
||||
StringReplace(svOut, sDLL_T[6], "");
|
||||
DevMsg(eDLL_T::MS, "%s", svOut.c_str());
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: NETCON systems init
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CRConServer::CRConServer()
|
||||
CRConServer::CRConServer(void)
|
||||
: m_bInitialized(false)
|
||||
, m_nConnIndex(0)
|
||||
{
|
||||
@ -29,6 +29,15 @@ CRConServer::CRConServer()
|
||||
m_pSocket = new CSocketCreator();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CRConServer::~CRConServer(void)
|
||||
{
|
||||
delete m_pAdr2;
|
||||
delete m_pSocket;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: NETCON systems init
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -74,7 +83,7 @@ void CRConServer::Think(void)
|
||||
for (m_nConnIndex = nCount - 1; m_nConnIndex >= 0; m_nConnIndex--)
|
||||
{
|
||||
CNetAdr2 netAdr2 = m_pSocket->GetAcceptedSocketAddress(m_nConnIndex);
|
||||
if (std::strcmp(netAdr2.GetIP(true).c_str(), sv_rcon_whitelist_address->GetString()) != 0)
|
||||
if (netAdr2.GetIP(true).compare(sv_rcon_whitelist_address->GetString()) != 0)
|
||||
{
|
||||
CConnectedNetConsoleData* pData = m_pSocket->GetAcceptedSocketData(m_nConnIndex);
|
||||
if (!pData->m_bAuthorized)
|
||||
@ -156,19 +165,7 @@ void CRConServer::Send(const std::string& svMessage) const
|
||||
|
||||
if (pData->m_bAuthorized)
|
||||
{
|
||||
size_t nMsgCount = (ssSendBuf.str().size() + MAX_NETCONSOLE_INPUT_LEN - 1) / MAX_NETCONSOLE_INPUT_LEN;
|
||||
size_t nDataSize = ssSendBuf.str().size();
|
||||
size_t nPos = 0;
|
||||
|
||||
for (size_t j = 0; j < nMsgCount; j++)
|
||||
{
|
||||
size_t nSize = std::min<uint64_t>(MAX_NETCONSOLE_INPUT_LEN, nDataSize);
|
||||
nDataSize -= nSize;
|
||||
string svFinal = ssSendBuf.str().substr(nPos, nSize);
|
||||
|
||||
::send(pData->m_hSocket, svFinal.data(), static_cast<int>(svFinal.size()), MSG_NOSIGNAL);
|
||||
nPos += nSize;
|
||||
}
|
||||
::send(pData->m_hSocket, ssSendBuf.str().data(), static_cast<int>(ssSendBuf.str().size()), MSG_NOSIGNAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -523,7 +520,7 @@ bool CRConServer::CheckForBan(CConnectedNetConsoleData* pData)
|
||||
|| pData->m_nIgnoredMessage >= sv_rcon_maxignores->GetInt())
|
||||
{
|
||||
// Don't add whitelisted address to ban vector.
|
||||
if (std::strcmp(netAdr2.GetIP(true).c_str(), sv_rcon_whitelist_address->GetString()) == 0)
|
||||
if (netAdr2.GetIP(true).compare(sv_rcon_whitelist_address->GetString()) == 0)
|
||||
{
|
||||
pData->m_nFailedAttempts = 0;
|
||||
pData->m_nIgnoredMessage = 0;
|
||||
|
@ -12,8 +12,8 @@ constexpr char s_pszAuthMessage[] = "RCON authentication successfull.\n";
|
||||
class CRConServer
|
||||
{
|
||||
public:
|
||||
CRConServer();
|
||||
~CRConServer() { delete m_pAdr2; delete m_pSocket; }
|
||||
CRConServer(void);
|
||||
~CRConServer(void);
|
||||
|
||||
void Init(void);
|
||||
void Shutdown(void);
|
||||
|
@ -125,14 +125,14 @@ void CNetCon::UserInput(void)
|
||||
|
||||
if (std::getline(std::cin, svInput))
|
||||
{
|
||||
if (strcmp(svInput.c_str(), "nquit") == 0)
|
||||
if (svInput.compare("nquit") == 0)
|
||||
{
|
||||
m_bQuitApplication = true;
|
||||
return;
|
||||
}
|
||||
if (m_abConnEstablished)
|
||||
{
|
||||
if (strcmp(svInput.c_str(), "disconnect") == 0)
|
||||
if (svInput.compare("disconnect") == 0)
|
||||
{
|
||||
this->Disconnect();
|
||||
return;
|
||||
@ -141,12 +141,12 @@ void CNetCon::UserInput(void)
|
||||
vector<string> vSubStrings = StringSplit(svInput, ' ', 2);
|
||||
if (vSubStrings.size() > 1)
|
||||
{
|
||||
if (strcmp(vSubStrings[0].c_str(), "PASS") == 0) // Auth with RCON server.
|
||||
if (vSubStrings[0].compare("PASS") == 0) // Auth with RCON server.
|
||||
{
|
||||
std::string svSerialized = this->Serialize(vSubStrings[1], "", cl_rcon::request_t::SERVERDATA_REQUEST_AUTH);
|
||||
this->Send(svSerialized);
|
||||
}
|
||||
else if (strcmp(vSubStrings[0].c_str(), "SET") == 0) // Set value query.
|
||||
else if (vSubStrings[0].compare("SET") == 0) // Set value query.
|
||||
{
|
||||
if (vSubStrings.size() > 2)
|
||||
{
|
||||
@ -156,13 +156,13 @@ void CNetCon::UserInput(void)
|
||||
}
|
||||
else // Execute command query.
|
||||
{
|
||||
std::string svSerialized = this->Serialize(svInput.c_str(), "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND);
|
||||
std::string svSerialized = this->Serialize(svInput, "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND);
|
||||
this->Send(svSerialized);
|
||||
}
|
||||
}
|
||||
else if (!svInput.empty()) // Single arg command query.
|
||||
{
|
||||
std::string svSerialized = this->Serialize(svInput.c_str(), "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND);
|
||||
std::string svSerialized = this->Serialize(svInput, "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND);
|
||||
this->Send(svSerialized);
|
||||
}
|
||||
}
|
||||
|
@ -780,8 +780,7 @@ void RCON_CmdQuery_f(const CCommand& args)
|
||||
return;
|
||||
}
|
||||
|
||||
string svCmdQuery = RCONClient()->Serialize(args.ArgS(), "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND);
|
||||
RCONClient()->Send(svCmdQuery);
|
||||
RCONClient()->Send(RCONClient()->Serialize(args.ArgS(), "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND));
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user