aboutsummaryrefslogtreecommitdiff
path: root/NetConsole/netconsole.cpp
diff options
context:
space:
mode:
authorKawe Mazidjatari <48657826+Mauler125@users.noreply.github.com>2022-05-07 11:47:16 +0200
committerKawe Mazidjatari <48657826+Mauler125@users.noreply.github.com>2022-05-07 11:47:16 +0200
commitaf9e2fe286e97140c40b2461bbd5d131125ac768 (patch)
treef3de60d2b14be5eb5bbbe19e437e022b10b7915f /NetConsole/netconsole.cpp
parent54739a3f365b7662c80c2e104af7a3ecc8b80c15 (diff)
downloadNorthstarLauncher-af9e2fe286e97140c40b2461bbd5d131125ac768.tar.gz
NorthstarLauncher-af9e2fe286e97140c40b2461bbd5d131125ac768.zip
RCON system improvements
* Buffers are now send properly from the game client and netconsole client (running scripts and executing command's/convar's now work properly). * Removed 'PASS' string check on server and only rely on 'SERVERDATA_REQUEST_AUTH' enum for auth queries (should make heavy abuse even harder).
Diffstat (limited to 'NetConsole/netconsole.cpp')
-rw-r--r--NetConsole/netconsole.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/NetConsole/netconsole.cpp b/NetConsole/netconsole.cpp
index cfdd31e1..3a59c5be 100644
--- a/NetConsole/netconsole.cpp
+++ b/NetConsole/netconsole.cpp
@@ -95,23 +95,29 @@ void CNetCon::UserInput(void)
size_t nPos = svInput.find(" ");
if (!svInput.empty() && nPos > 0 && nPos < svInput.size() && nPos != svInput.size())
{
- std::string svReqVal = svInput.substr(nPos + 1);
- std::string svReqBuf = svInput.erase(svInput.find(" "));
+ std::string svSecondArg = svInput.substr(nPos + 1);
+ std::string svFirstArg = svInput;
+ svFirstArg = svFirstArg.erase(svFirstArg.find(" "));
- if (strcmp(svReqBuf.c_str(), "PASS") == 0) // Auth with RCON server.
+ if (strcmp(svFirstArg.c_str(), "PASS") == 0) // Auth with RCON server.
{
- std::string svSerialized = this->Serialize(svReqBuf, svReqVal, cl_rcon::request_t::SERVERDATA_REQUEST_AUTH);
+ std::string svSerialized = this->Serialize(svSecondArg, "", cl_rcon::request_t::SERVERDATA_REQUEST_AUTH);
this->Send(svSerialized);
}
- else // This is a ConVar.
+ else if (strcmp(svFirstArg.c_str(), "SET") == 0) // Set value query.
{
- std::string svSerialized = this->Serialize(svReqBuf, svReqVal, cl_rcon::request_t::SERVERDATA_REQUEST_SETVALUE);
+ std::string svSerialized = this->Serialize(svFirstArg, svSecondArg, cl_rcon::request_t::SERVERDATA_REQUEST_SETVALUE);
+ this->Send(svSerialized);
+ }
+ else // Execute command query.
+ {
+ std::string svSerialized = this->Serialize(svInput.c_str(), "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND);
this->Send(svSerialized);
}
}
- else // This is a ConCommand.
+ else // Single arg command query.
{
- std::string svSerialized = this->Serialize(svInput, "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND);
+ std::string svSerialized = this->Serialize(svInput.c_str(), "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND);
this->Send(svSerialized);
}
}