mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Add cvar for determining whether or not to send rcon console logs to netconsole
This commit is contained in:
parent
48cc2979ec
commit
39b95a9716
@ -192,6 +192,45 @@ void CRConServer::Send(SocketHandle_t hSocket, const std::string& svMessage) con
|
||||
::send(hSocket, ssSendBuf.str().data(), static_cast<int>(ssSendBuf.str().size()), MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: send serialized message to all connected sockets
|
||||
// Input : *svRspBuf -
|
||||
// *svRspVal -
|
||||
// responseType -
|
||||
// nResponseId -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CRConServer::Send(const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t responseType, int nResponseId)
|
||||
{
|
||||
if (responseType == sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG)
|
||||
{
|
||||
if (!sv_rcon_sendlogs->GetBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
this->Send(this->Serialize(svRspBuf, svRspVal, responseType, nResponseId));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: send serialized message to specific connected socket
|
||||
// Input : hSocket -
|
||||
// *svRspBuf -
|
||||
// *svRspVal -
|
||||
// responseType -
|
||||
// nResponseId -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CRConServer::Send(SocketHandle_t hSocket, const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t responseType, int nResponseId)
|
||||
{
|
||||
if (responseType == sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG)
|
||||
{
|
||||
if (!sv_rcon_sendlogs->GetBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
this->Send(hSocket, this->Serialize(svRspBuf, svRspVal, responseType, nResponseId));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: receive message
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -250,17 +289,17 @@ void CRConServer::Recv(void)
|
||||
// Purpose: serializes input
|
||||
// Input : *svRspBuf -
|
||||
// *svRspVal -
|
||||
// response_t -
|
||||
// responseType -
|
||||
// Output : serialized results as string
|
||||
//-----------------------------------------------------------------------------
|
||||
std::string CRConServer::Serialize(const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t response_t, int nResponseId) const
|
||||
std::string CRConServer::Serialize(const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t responseType, int nResponseId) const
|
||||
{
|
||||
sv_rcon::response sv_response;
|
||||
|
||||
sv_response.set_responseid(nResponseId);
|
||||
sv_response.set_responsetype(response_t);
|
||||
sv_response.set_responsetype(responseType);
|
||||
|
||||
switch (response_t)
|
||||
switch (responseType)
|
||||
{
|
||||
case sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH:
|
||||
{
|
||||
@ -334,7 +373,7 @@ void CRConServer::Authenticate(const cl_rcon::request& cl_request, CConnectedNet
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: sha256 hashed password comparison
|
||||
// Input : *svCompare -
|
||||
// Input : svCompare -
|
||||
// Output : true if matches, false otherwise
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CRConServer::Comparator(std::string svPassword) const
|
||||
@ -347,7 +386,7 @@ bool CRConServer::Comparator(std::string svPassword) const
|
||||
DevMsg(eDLL_T::SERVER, "] Client: '%s'[\n", svPassword.c_str());
|
||||
DevMsg(eDLL_T::SERVER, "+---------------------------------------------------------------------------+\n");
|
||||
}
|
||||
if (memcmp(svPassword.c_str(), m_svPasswordHash.c_str(), SHA256::DIGEST_SIZE) == 0)
|
||||
if (std::memcmp(svPassword.data(), m_svPasswordHash.data(), SHA256::DIGEST_SIZE) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -468,7 +507,7 @@ void CRConServer::ProcessMessage(const cl_rcon::request& cl_request)
|
||||
{
|
||||
if (pData->m_bAuthorized)
|
||||
{
|
||||
// TODO: Send conlog to true.
|
||||
sv_rcon_sendlogs->SetValue(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
constexpr char s_pszNoAuthMessage[] = "This server is password protected for console access. Authenticate with 'PASS <password>' command.\n";
|
||||
constexpr char s_pszWrongPwMessage[] = "Admin password incorrect.\n";
|
||||
constexpr char s_pszBannedMessage[] = "Go away.\n";
|
||||
constexpr char s_pszAuthMessage[] = "RCON authentication successfull.\n";
|
||||
constexpr char s_pszAuthMessage[] = "Authentication successfull.\n";
|
||||
|
||||
class CRConServer
|
||||
{
|
||||
@ -24,9 +24,11 @@ public:
|
||||
|
||||
void Send(const std::string& svMessage) const;
|
||||
void Send(SocketHandle_t hSocket, const std::string& svMessage) const;
|
||||
void Send(const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t responseType, int nResponseId = -4);
|
||||
void Send(SocketHandle_t hSocket, const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t responseType, int nResponseId = -4);
|
||||
void Recv(void);
|
||||
|
||||
std::string Serialize(const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t response_t, int nResponseId = -4) const;
|
||||
std::string Serialize(const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t responseType, int nResponseId = -4) const;
|
||||
cl_rcon::request Deserialize(const std::string& svBuf) const;
|
||||
|
||||
void Authenticate(const cl_rcon::request& cl_request, CConnectedNetConsoleData* pData);
|
||||
|
@ -114,7 +114,7 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
||||
{
|
||||
wconsole->debug(vmStr);
|
||||
#ifdef DEDICATED
|
||||
RCONServer()->Send(RCONServer()->Serialize(vmStr, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, nResponseId));
|
||||
RCONServer()->Send(vmStr, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, nResponseId);
|
||||
#endif // DEDICATED
|
||||
}
|
||||
else
|
||||
@ -160,7 +160,7 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
||||
vmStrAnsi.append(buf);
|
||||
wconsole->debug(vmStrAnsi);
|
||||
#ifdef DEDICATED
|
||||
RCONServer()->Send(RCONServer()->Serialize(vmStrAnsi, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, nResponseId));
|
||||
RCONServer()->Send(vmStrAnsi, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, nResponseId);
|
||||
#endif // DEDICATED
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ SQRESULT SQVM_WarningFunc(HSQUIRRELVM v, SQInteger a2, SQInteger a3, SQInteger*
|
||||
{
|
||||
wconsole->debug(vmStr);
|
||||
#ifdef DEDICATED
|
||||
RCONServer()->Send(RCONServer()->Serialize(vmStr, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, nResponseId));
|
||||
RCONServer()->Send(vmStr, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, nResponseId);
|
||||
#endif // DEDICATED
|
||||
}
|
||||
else
|
||||
@ -284,7 +284,7 @@ SQRESULT SQVM_WarningFunc(HSQUIRRELVM v, SQInteger a2, SQInteger a3, SQInteger*
|
||||
vmStrAnsi.append(svConstructor);
|
||||
wconsole->debug(vmStrAnsi);
|
||||
#ifdef DEDICATED
|
||||
RCONServer()->Send(RCONServer()->Serialize(vmStrAnsi, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, nResponseId));
|
||||
RCONServer()->Send(vmStrAnsi, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, nResponseId);
|
||||
#endif // DEDICATED
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ void DevMsg(eDLL_T context, const char* fmt, ...)
|
||||
{
|
||||
wconsole->debug(svOut);
|
||||
#ifdef DEDICATED
|
||||
RCONServer()->Send(RCONServer()->Serialize(svOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context)));
|
||||
RCONServer()->Send(svOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context));
|
||||
#endif // DEDICATED
|
||||
}
|
||||
else
|
||||
@ -337,7 +337,7 @@ void DevMsg(eDLL_T context, const char* fmt, ...)
|
||||
}
|
||||
wconsole->debug(svAnsiOut);
|
||||
#ifdef DEDICATED
|
||||
RCONServer()->Send(RCONServer()->Serialize(svAnsiOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context)));
|
||||
RCONServer()->Send(svAnsiOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context));
|
||||
#endif // DEDICATED
|
||||
}
|
||||
|
||||
@ -435,7 +435,7 @@ void Warning(eDLL_T context, const char* fmt, ...)
|
||||
{
|
||||
wconsole->debug(svOut);
|
||||
#ifdef DEDICATED
|
||||
RCONServer()->Send(RCONServer()->Serialize(svOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context)));
|
||||
RCONServer()->Send(svOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context));
|
||||
#endif // DEDICATED
|
||||
}
|
||||
else
|
||||
@ -451,7 +451,7 @@ void Warning(eDLL_T context, const char* fmt, ...)
|
||||
}
|
||||
wconsole->debug(svAnsiOut);
|
||||
#ifdef DEDICATED
|
||||
RCONServer()->Send(RCONServer()->Serialize(svAnsiOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context)));
|
||||
RCONServer()->Send(svAnsiOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context));
|
||||
#endif // DEDICATED
|
||||
}
|
||||
|
||||
@ -512,7 +512,7 @@ void Error(eDLL_T context, const char* fmt, ...)
|
||||
{
|
||||
wconsole->debug(svOut);
|
||||
#ifdef DEDICATED
|
||||
RCONServer()->Send(RCONServer()->Serialize(svOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context)));
|
||||
RCONServer()->Send(svOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context));
|
||||
#endif // DEDICATED
|
||||
}
|
||||
else
|
||||
@ -528,7 +528,7 @@ void Error(eDLL_T context, const char* fmt, ...)
|
||||
}
|
||||
wconsole->debug(svAnsiOut);
|
||||
#ifdef DEDICATED
|
||||
RCONServer()->Send(RCONServer()->Serialize(svAnsiOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context)));
|
||||
RCONServer()->Send(svAnsiOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context));
|
||||
#endif // DEDICATED
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,7 @@ void ConVar::Init(void) const
|
||||
sv_statusRefreshInterval = ConVar::Create("sv_statusRefreshInterval" , "0.5", FCVAR_RELEASE, "Server status bar update interval (seconds).", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
#ifdef DEDICATED
|
||||
sv_rcon_debug = ConVar::Create("sv_rcon_debug" , "0" , FCVAR_RELEASE, "Show rcon debug information ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
sv_rcon_sendlogs = ConVar::Create("sv_rcon_sendlogs" , "0" , FCVAR_RELEASE, "Network console logs to connected and authenticated sockets.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
sv_rcon_banpenalty = ConVar::Create("sv_rcon_banpenalty" , "10", FCVAR_RELEASE, "Number of minutes to ban users who fail rcon authentication.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
sv_rcon_maxfailures = ConVar::Create("sv_rcon_maxfailures", "10", FCVAR_RELEASE, "Max number of times a user can fail rcon authentication before being banned.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
sv_rcon_maxignores = ConVar::Create("sv_rcon_maxignores" , "15", FCVAR_RELEASE, "Max number of times a user can ignore the no-auth message before being banned.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
|
@ -68,6 +68,7 @@ ConVar* sv_statusRefreshInterval = nullptr;
|
||||
|
||||
#ifdef DEDICATED
|
||||
ConVar* sv_rcon_debug = nullptr;
|
||||
ConVar* sv_rcon_sendlogs = nullptr;
|
||||
ConVar* sv_rcon_banpenalty = nullptr; // TODO
|
||||
ConVar* sv_rcon_maxfailures = nullptr;
|
||||
ConVar* sv_rcon_maxignores = nullptr;
|
||||
|
@ -64,6 +64,7 @@ extern ConVar* sv_statusRefreshInterval;
|
||||
|
||||
#ifdef DEDICATED
|
||||
extern ConVar* sv_rcon_debug;
|
||||
extern ConVar* sv_rcon_sendlogs;
|
||||
extern ConVar* sv_rcon_banpenalty;
|
||||
extern ConVar* sv_rcon_maxfailures;
|
||||
extern ConVar* sv_rcon_maxignores;
|
||||
|
Loading…
x
Reference in New Issue
Block a user