aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/sv_rcon.h
diff options
context:
space:
mode:
authorAmos <48657826+Mauler125@users.noreply.github.com>2022-03-04 00:54:01 +0100
committerAmos <48657826+Mauler125@users.noreply.github.com>2022-03-04 00:54:01 +0100
commitbc7375807af20ad9bb07efa14ed538fce2f9ea00 (patch)
treef78cfa2738ff40ed4473454c34e8b71632c4253c /NorthstarDedicatedTest/sv_rcon.h
parentf108edc345d9709dbdc977578bf851b4b3aa0939 (diff)
downloadNorthstarLauncher-bc7375807af20ad9bb07efa14ed538fce2f9ea00.tar.gz
NorthstarLauncher-bc7375807af20ad9bb07efa14ed538fce2f9ea00.zip
RCON implementation
* Full CNetAdr rewrite (protocol agnostic) * Full CSocketCreator class rebuild (based on Valve's implementation) * RCON implementation on server and client * Misc cleanup
Diffstat (limited to 'NorthstarDedicatedTest/sv_rcon.h')
-rw-r--r--NorthstarDedicatedTest/sv_rcon.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/sv_rcon.h b/NorthstarDedicatedTest/sv_rcon.h
new file mode 100644
index 00000000..399d5f2e
--- /dev/null
+++ b/NorthstarDedicatedTest/sv_rcon.h
@@ -0,0 +1,50 @@
+#pragma once
+#include "NetAdr2.h"
+#include "socketcreator.h"
+#include "sv_rcon.pb.h"
+#include "cl_rcon.pb.h"
+#include "igameserverdata.h"
+
+constexpr char s_pszNoAuthMessage[] = "This server is password protected for console access. Must send 'PASS <password>' command.\n\r";
+constexpr char s_pszWrongPwMessage[] = "Password incorrect.\n\r";
+constexpr char s_pszBannedMessage[] = "Go away.\n\r";
+constexpr char s_pszAuthMessage[] = "RCON authentication succesfull.\n\r";
+
+class CRConServer
+{
+public:
+ void Init(void);
+ void Shutdown(void);
+
+ void Think(void);
+ void RunFrame(void);
+
+ void Send(const std::string& svMessage) const;
+ void Recv(void);
+
+ std::string Serialize(const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t response_t) const;
+ cl_rcon::request Deserialize(const std::string& svBuf) const;
+
+ void Authenticate(const cl_rcon::request& cl_request, CConnectedNetConsoleData* pData);
+ bool Comparator(std::string svPassword) const;
+
+ void ProcessBuffer(const char* pszIn, int nRecvLen, CConnectedNetConsoleData* pData);
+ void ProcessMessage(const cl_rcon::request& cl_request);
+
+ void Execute(const cl_rcon::request& cl_request) const;
+ bool CheckForBan(CConnectedNetConsoleData* pData);
+
+ void CloseConnection(void);
+ void CloseNonAuthConnection(void);
+
+private:
+
+ bool m_bInitialized = false;
+ int m_nConnIndex = 0;
+ CNetAdr2* m_pAdr2 = new CNetAdr2();
+ CSocketCreator* m_pSocket = new CSocketCreator();
+ std::vector<std::string> m_vBannedAddress;
+ std::string m_svPasswordHash;
+};
+void InitializeServerRcon(HMODULE baseAddress);
+extern CRConServer* g_pRConServer; \ No newline at end of file