Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/server/StarServerRconClient.hpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
commit6352e8e3196f78388b6c771073f9e03eaa612673 (patch)
treee23772f79a7fbc41bc9108951e9e136857484bf4 /source/server/StarServerRconClient.hpp
parent6741a057e5639280d85d0f88ba26f000baa58f61 (diff)
everything everywhere
all at once
Diffstat (limited to 'source/server/StarServerRconClient.hpp')
-rw-r--r--source/server/StarServerRconClient.hpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/source/server/StarServerRconClient.hpp b/source/server/StarServerRconClient.hpp
new file mode 100644
index 0000000..8c9bb25
--- /dev/null
+++ b/source/server/StarServerRconClient.hpp
@@ -0,0 +1,51 @@
+#ifndef STAR_SERVER_RCON_CLIENT_HPP
+#define STAR_SERVER_RCON_CLIENT_HPP
+
+#include "StarThread.hpp"
+#include "StarTcp.hpp"
+#include "StarMap.hpp"
+#include "StarDataStreamDevices.hpp"
+
+namespace Star {
+
+class UniverseServer;
+
+class ServerRconClient : public Thread {
+public:
+ static const uint32_t SERVERDATA_AUTH = 0x03;
+ static const uint32_t SERVERDATA_EXECCOMMAND = 0x02;
+ static const uint32_t SERVERDATA_RESPONSE_VALUE = 0x00;
+ static const uint32_t SERVERDATA_AUTH_RESPONSE = 0x02;
+ static const uint32_t SERVERDATA_AUTH_FAILURE = 0xffffffff;
+ ServerRconClient(UniverseServer* universe, TcpSocketPtr socket);
+ ~ServerRconClient();
+
+ void start();
+ void stop();
+
+protected:
+ virtual void run();
+
+private:
+ static size_t const MaxPacketSize = 4096;
+ STAR_EXCEPTION(NoMoreRequests, StarException);
+
+ void receive(size_t size);
+ void send(uint32_t requestId, uint32_t cmd, String str = "");
+ void sendAuthFailure();
+ void sendCmdResponse(uint32_t requestId, String response);
+ void closeSocket();
+ void processRequest();
+ String handleCommand(String commandLine);
+
+ UniverseServer* m_universe;
+ TcpSocketPtr m_socket;
+ DataStreamBuffer m_packetBuffer;
+ bool m_stop;
+ bool m_authed;
+ String m_rconPassword;
+};
+typedef shared_ptr<ServerRconClient> ServerRconClientPtr;
+}
+
+#endif