Cuberite
A lightweight, fast and extensible game server for Minecraft
|
Meta-protocol that recognizes multiple protocol versions, creates the specific protocol version instance and redirects everything to it. More...
#include <ProtocolRecognizer.h>
Public Member Functions | |
cMultiVersionProtocol () | |
void | HandleIncomingData (cClientHandle &a_Client, ContiguousByteBuffer &a_Data) |
Directs incoming protocol data along the correct pathway, depending on the state of the version recognition process. More... | |
void | HandleOutgoingData (ContiguousByteBuffer &a_Data) |
Allows the protocol (if any) to do a final pass on outgiong data, possibly modifying the provided buffer in-place. More... | |
auto & | operator-> () |
Convenience overload to enable redirecting sends to the underlying implementation. More... | |
void | SendDisconnect (cClientHandle &a_Client, const AString &a_Reason) |
Sends a disconnect to the client as a result of a recognition error. More... | |
bool | VersionRecognitionSuccessful () |
Returns if we contain a concrete protocol corresponding to the client's protocol version. More... | |
Static Public Member Functions | |
static AString | GetVersionTextFromInt (cProtocol::Version a_ProtocolVersion) |
Translates protocol version number into protocol version text: 49 -> "1.4.4". More... | |
Private Member Functions | |
void | HandleIncomingDataInOldPingResponseStage (cClientHandle &a_Client, ContiguousByteBufferView a_Data) |
Handles and responds to unsupported clients sending pings. More... | |
void | HandleIncomingDataInRecognitionStage (cClientHandle &a_Client, ContiguousByteBuffer &a_Data) |
Handles data reception in a newly-created client handle that doesn't yet have a known protocol. More... | |
void | HandlePacketStatusPing (cClientHandle &a_Client) |
void | HandlePacketStatusRequest (cClientHandle &a_Client) |
bool | TryHandleHTTPRequest (cClientHandle &a_Client, ContiguousByteBuffer &a_Data) |
std::unique_ptr< cProtocol > | TryRecognizeLengthedProtocol (cClientHandle &a_Client) |
Tries to recognize a protocol in the lengthed family (1.7+), based on m_Buffer. More... | |
Static Private Member Functions | |
static UInt32 | GetPacketID (cProtocol::ePacketType a_PacketType) |
Returns the protocol-specific packet ID given the protocol-agnostic packet enum. More... | |
static void | SendPacket (cClientHandle &a_Client, cByteBuffer &a_OutPacketBuffer) |
Sends one packet inside a cByteBuffer. More... | |
Private Attributes | |
cByteBuffer | m_Buffer |
Buffer for received protocol data. More... | |
std::unique_ptr< cProtocol > | m_Protocol |
The actual protocol implementation. More... | |
bool | m_WaitingForData |
If we're still waiting for data required for version recognition to arrive. More... | |
Meta-protocol that recognizes multiple protocol versions, creates the specific protocol version instance and redirects everything to it.
Definition at line 20 of file ProtocolRecognizer.h.
cMultiVersionProtocol::cMultiVersionProtocol | ( | ) |
Definition at line 40 of file ProtocolRecognizer.cpp.
|
staticprivate |
Returns the protocol-specific packet ID given the protocol-agnostic packet enum.
Definition at line 395 of file ProtocolRecognizer.cpp.
|
static |
Translates protocol version number into protocol version text: 49 -> "1.4.4".
Definition at line 50 of file ProtocolRecognizer.cpp.
void cMultiVersionProtocol::HandleIncomingData | ( | cClientHandle & | a_Client, |
ContiguousByteBuffer & | a_Data | ||
) |
Directs incoming protocol data along the correct pathway, depending on the state of the version recognition process.
The protocol modifies the provided buffer in-place.
Definition at line 187 of file ProtocolRecognizer.cpp.
|
private |
Handles and responds to unsupported clients sending pings.
Definition at line 141 of file ProtocolRecognizer.cpp.
|
private |
Handles data reception in a newly-created client handle that doesn't yet have a known protocol.
a_Data contains a view of data that were just received. Tries to recognize a protocol, populate m_Protocol, and transitions to another mode depending on success.
Definition at line 83 of file ProtocolRecognizer.cpp.
void cMultiVersionProtocol::HandleOutgoingData | ( | ContiguousByteBuffer & | a_Data | ) |
Allows the protocol (if any) to do a final pass on outgiong data, possibly modifying the provided buffer in-place.
Definition at line 209 of file ProtocolRecognizer.cpp.
|
private |
Definition at line 460 of file ProtocolRecognizer.cpp.
|
private |
Definition at line 414 of file ProtocolRecognizer.cpp.
|
inline |
Convenience overload to enable redirecting sends to the underlying implementation.
Definition at line 36 of file ProtocolRecognizer.h.
void cMultiVersionProtocol::SendDisconnect | ( | cClientHandle & | a_Client, |
const AString & | a_Reason | ||
) |
Sends a disconnect to the client as a result of a recognition error.
This function can be used to disconnect before any protocol has been recognised.
Definition at line 224 of file ProtocolRecognizer.cpp.
|
staticprivate |
Sends one packet inside a cByteBuffer.
This is used only when handling an outdated server ping.
Definition at line 372 of file ProtocolRecognizer.cpp.
|
private |
Definition at line 248 of file ProtocolRecognizer.cpp.
|
private |
Tries to recognize a protocol in the lengthed family (1.7+), based on m_Buffer.
Returns a cProtocol_XXX instance if recognized.
Definition at line 279 of file ProtocolRecognizer.cpp.
|
inline |
Returns if we contain a concrete protocol corresponding to the client's protocol version.
Definition at line 30 of file ProtocolRecognizer.h.
|
private |
Buffer for received protocol data.
Definition at line 83 of file ProtocolRecognizer.h.
|
private |
The actual protocol implementation.
Created when recognition of the client version succeeds with a version we support.
Definition at line 87 of file ProtocolRecognizer.h.
|
private |
If we're still waiting for data required for version recognition to arrive.
Definition at line 90 of file ProtocolRecognizer.h.