Cuberite
A lightweight, fast and extensible game server for Minecraft
RCONServer.h
Go to the documentation of this file.
1 
2 // RCONServer.h
3 
4 // Declares the cRCONServer class representing the RCON server
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "OSSupport/Network.h"
13 
14 
15 
16 
17 
18 // fwd:
19 class cServer;
21 
22 
23 
24 
25 
27 {
28 public:
29  cRCONServer(cServer & a_Server);
30  virtual ~cRCONServer();
31 
32  void Initialize(cSettingsRepositoryInterface & a_Settings);
33 
34 protected:
35  friend class cRCONCommandOutput;
36  friend class cRCONListenCallbacks;
37 
38  class cConnection :
40  {
41  public:
42  cConnection(cRCONServer & a_RCONServer, const AString & a_IPAddress);
43 
44  protected:
45  friend class cRCONCommandOutput;
46 
49 
52 
55 
58 
61 
62 
63  // cTCPLink::cCallbacks overrides:
64  virtual void OnLinkCreated(cTCPLinkPtr a_Link) override;
65  virtual void OnReceivedData(const char * a_Data, size_t a_Length) override;
66  virtual void OnRemoteClosed(void) override;
67  virtual void OnError(int a_ErrorCode, const AString & a_ErrorMsg) override;
68 
70  bool ProcessPacket(UInt32 a_RequestID, UInt32 a_PacketType, UInt32 a_PayloadLength, const char * a_Payload);
71 
73  UInt32 UIntFromBuffer(const char * a_Buffer);
74 
76  void UIntToBuffer(UInt32 a_Value, char * a_Buffer);
77 
79  void SendResponse(UInt32 a_RequestID, UInt32 a_PacketType, UInt32 a_PayloadLength, const char * a_Payload);
80  } ;
81 
82 
85 
88 
91 } ;
92 
93 
94 
95 
96 
unsigned int UInt32
Definition: Globals.h:157
std::shared_ptr< cTCPLink > cTCPLinkPtr
Definition: Network.h:25
std::vector< cServerHandlePtr > cServerHandlePtrs
Definition: Network.h:30
std::string AString
Definition: StringUtils.h:11
cServerHandlePtrs m_ListenServers
The sockets for accepting RCON connections (one socket per port).
Definition: RCONServer.h:87
AString m_Password
Password for authentication.
Definition: RCONServer.h:90
void Initialize(cSettingsRepositoryInterface &a_Settings)
Definition: RCONServer.cpp:137
cRCONServer(cServer &a_Server)
Definition: RCONServer.cpp:116
virtual ~cRCONServer()
Definition: RCONServer.cpp:125
cServer & m_Server
The server object that will process the commands received.
Definition: RCONServer.h:84
virtual void OnLinkCreated(cTCPLinkPtr a_Link) override
Called when the cTCPLink for the connection is created.
Definition: RCONServer.cpp:195
AString m_IPAddress
Address of the client.
Definition: RCONServer.h:60
virtual void OnReceivedData(const char *a_Data, size_t a_Length) override
Called when there's data incoming from the remote peer.
Definition: RCONServer.cpp:204
bool ProcessPacket(UInt32 a_RequestID, UInt32 a_PacketType, UInt32 a_PayloadLength, const char *a_Payload)
Processes the given packet and sends the response; returns true if successful, false if the connectio...
Definition: RCONServer.cpp:266
cRCONServer & m_RCONServer
Server that owns this connection and processes requests.
Definition: RCONServer.h:54
void SendResponse(UInt32 a_RequestID, UInt32 a_PacketType, UInt32 a_PayloadLength, const char *a_Payload)
Sends a RCON packet back to the client.
Definition: RCONServer.cpp:339
void UIntToBuffer(UInt32 a_Value, char *a_Buffer)
Puts 4 bytes representing the int into the buffer.
Definition: RCONServer.cpp:327
bool m_IsAuthenticated
Set to true if the client has successfully authenticated.
Definition: RCONServer.h:48
cConnection(cRCONServer &a_RCONServer, const AString &a_IPAddress)
Definition: RCONServer.cpp:184
cTCPLinkPtr m_Link
The TCP link to the client.
Definition: RCONServer.h:57
virtual void OnError(int a_ErrorCode, const AString &a_ErrorMsg) override
Called when an error is detected on the connection.
Definition: RCONServer.cpp:256
virtual void OnRemoteClosed(void) override
Called when the remote end closes the connection.
Definition: RCONServer.cpp:247
AString m_Buffer
Buffer for the incoming data.
Definition: RCONServer.h:51
UInt32 UIntFromBuffer(const char *a_Buffer)
Reads 4 bytes from a_Buffer and returns the LE UInt32 they represent.
Definition: RCONServer.cpp:317
Definition: Server.h:56