TrinityCore
Loading...
Searching...
No Matches
WorldSocket Class Referencefinal

#include <WorldSocket.h>

+ Inheritance diagram for WorldSocket:

Public Member Functions

 WorldSocket (Trinity::Net::IoContextTcpSocket &&socket)
 
 ~WorldSocket ()
 
 WorldSocket (WorldSocket const &right)=delete
 
 WorldSocket (WorldSocket &&right)=delete
 
WorldSocketoperator= (WorldSocket const &right)=delete
 
WorldSocketoperator= (WorldSocket &&right)=delete
 
void Start () override
 
bool Update () override
 
void SendPacket (WorldPacket const &packet)
 
ConnectionType GetConnectionType () const
 
void SendAuthResponseError (uint32 code)
 
void SetWorldSession (WorldSession *session)
 
void SetSendBufferSize (std::size_t sendBufferSize)
 
void OnClose () override
 
Trinity::Net::SocketReadCallbackResult ReadHandler () override
 
void QueueQuery (QueryCallback &&queryCallback)
 
void SendAuthSession ()
 
bool InitializeCompression ()
 
- Public Member Functions inherited from Trinity::Net::Socket< Stream >
template<typename... Args>
 Socket (IoContextTcpSocket &&socket, Args &&... args)
 
template<typename... Args>
 Socket (boost::asio::io_context &context, Args &&... args)
 
 Socket (Socket const &other)=delete
 
 Socket (Socket &&other)=delete
 
Socketoperator= (Socket const &other)=delete
 
Socketoperator= (Socket &&other)=delete
 
virtual ~Socket ()
 
template<BOOST_ASIO_COMPLETION_TOKEN_FOR(void(boost::system::error_code, boost::asio::ip::tcp::endpoint)) Callback>
decltype(auto) Connect (boost::asio::ip::tcp::endpoint const &endpoint, Callback &&callback)
 
template<BOOST_ASIO_COMPLETION_TOKEN_FOR(void(boost::system::error_code, boost::asio::ip::tcp::endpoint)) Callback>
decltype(auto) Connect (std::vector< boost::asio::ip::tcp::endpoint > const &endpoints, Callback &&callback)
 
boost::asio::ip::address const & GetRemoteIpAddress () const
 
uint16 GetRemotePort () const
 
void SetRemoteEndpoint (boost::asio::ip::tcp::endpoint const &endpoint)
 
template<invocable_r< SocketReadCallbackResult > Callback>
void AsyncRead (Callback &&callback)
 
void QueuePacket (MessageBuffer &&buffer)
 
bool IsOpen () const
 
void CloseSocket ()
 
void DelayedCloseSocket ()
 Marks the socket for closing after write buffer becomes empty.
 
MessageBufferGetReadBuffer ()
 
Stream & underlying_stream ()
 

Protected Types

enum class  ReadDataHandlerResult { Ok = 0 , Error = 1 , WaitingForQuery = 2 }
 

Protected Member Functions

bool ReadHeaderHandler ()
 
ReadDataHandlerResult ReadDataHandler ()
 
- Protected Member Functions inherited from Trinity::Net::Socket< Stream >
bool AsyncProcessQueue ()
 
void SetNoDelay (bool enable)
 

Private Types

using BaseSocket = Socket
 

Private Member Functions

void LogOpcodeText (OpcodeClient opcode) const
 writes network.opcode log
 
void LogOpcodeText (OpcodeClient opcode, std::scoped_lock< std::mutex > const &guard) const
 
void SendPacketAndLogOpcode (WorldPacket const &packet)
 sends and logs network.opcode without accessing WorldSession
 
void WritePacketToBuffer (EncryptablePacket const &packet, MessageBuffer &buffer)
 
uint32 CompressPacket (uint8 *buffer, WorldPacket const &packet)
 
ReadDataHandlerResult HandleAuthSession (WorldPacket &&packet)
 
void HandleAuthSessionCallback (WorldPackets::Auth::AuthSession const *authSession, JSON::RealmList::RealmJoinTicket *joinTicket, PreparedResultSet const *result)
 
ReadDataHandlerResult HandleAuthContinuedSession (WorldPacket &&packet)
 
void HandleAuthContinuedSessionCallback (WorldPackets::Auth::AuthContinuedSession const *authSession, PreparedResultSet const *result)
 
void LoadSessionPermissionsCallback (PreparedQueryResult result)
 
ReadDataHandlerResult HandleKeepAlive ()
 
ReadDataHandlerResult HandleLogDisconnect (WorldPacket &&packet) const
 
ReadDataHandlerResult HandleConnectToFailed (WorldPacket &&packet)
 
ReadDataHandlerResult HandlePing (WorldPacket &&packet)
 
ReadDataHandlerResult HandleEnterEncryptedModeAck ()
 

Private Attributes

ConnectionType _type
 
uint64 _key
 
std::array< uint8, 32 > _serverChallenge
 
WorldPacketCrypt _authCrypt
 
SessionKey _sessionKey
 
std::array< uint8, 32 > _encryptKey
 
TimePoint _lastPingTime
 
uint32 _overSpeedPings
 
std::mutex _worldSessionLock
 
WorldSession_worldSession
 
bool _authed
 
bool _canRequestHotfixes
 
MessageBuffer _headerBuffer
 
MessageBuffer _packetBuffer
 
MPSCQueue< EncryptablePacket, &EncryptablePacket::SocketQueueLink_bufferQueue
 
std::size_t _sendBufferSize
 
z_stream_compressionStream
 
QueryCallbackProcessor _queryProcessor
 
std::string _ipCountry
 

Static Private Attributes

static uint32 const MinSizeForCompression = 0x400
 
static std::array< uint8, 32 > const AuthCheckSeed
 
static std::array< uint8, 32 > const SessionKeySeed
 
static std::array< uint8, 32 > const ContinuedSessionSeed
 
static std::array< uint8, 32 > const EncryptionKeySeed
 

Detailed Description

Definition at line 83 of file WorldSocket.h.

Member Typedef Documentation

◆ BaseSocket

Definition at line 92 of file WorldSocket.h.

Member Enumeration Documentation

◆ ReadDataHandlerResult

enum class WorldSocket::ReadDataHandlerResult
strongprotected
Enumerator
Ok 
Error 
WaitingForQuery 

Definition at line 125 of file WorldSocket.h.

Constructor & Destructor Documentation

◆ WorldSocket() [1/3]

WorldSocket::WorldSocket ( Trinity::Net::IoContextTcpSocket &&  socket)
explicit

Definition at line 65 of file WorldSocket.cpp.

◆ ~WorldSocket()

WorldSocket::~WorldSocket ( )

Definition at line 71 of file WorldSocket.cpp.

◆ WorldSocket() [2/3]

WorldSocket::WorldSocket ( WorldSocket const &  right)
delete

◆ WorldSocket() [3/3]

WorldSocket::WorldSocket ( WorldSocket &&  right)
delete

Member Function Documentation

◆ CompressPacket()

uint32 WorldSocket::CompressPacket ( uint8 buffer,
WorldPacket const &  packet 
)
private

Definition at line 514 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetConnectionType()

ConnectionType WorldSocket::GetConnectionType ( ) const
inline

Definition at line 108 of file WorldSocket.h.

+ Here is the caller graph for this function:

◆ HandleAuthContinuedSession()

WorldSocket::ReadDataHandlerResult WorldSocket::HandleAuthContinuedSession ( WorldPacket &&  packet)
private

Definition at line 859 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleAuthContinuedSessionCallback()

void WorldSocket::HandleAuthContinuedSessionCallback ( WorldPackets::Auth::AuthContinuedSession const *  authSession,
PreparedResultSet const *  result 
)
private

Definition at line 899 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ HandleAuthSession()

WorldSocket::ReadDataHandlerResult WorldSocket::HandleAuthSession ( WorldPacket &&  packet)
private

Definition at line 609 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleAuthSessionCallback()

void WorldSocket::HandleAuthSessionCallback ( WorldPackets::Auth::AuthSession const *  authSession,
JSON::RealmList::RealmJoinTicket joinTicket,
PreparedResultSet const *  result 
)
private
  • Re-check ip locking (same check as in auth).

Negative mutetime indicates amount of seconds to be muted effective on next login - which is now.

Definition at line 647 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ HandleConnectToFailed()

WorldSocket::ReadDataHandlerResult WorldSocket::HandleConnectToFailed ( WorldPacket &&  packet)
private

Definition at line 974 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleEnterEncryptedModeAck()

WorldSocket::ReadDataHandlerResult WorldSocket::HandleEnterEncryptedModeAck ( )
private

Definition at line 1025 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleKeepAlive()

WorldSocket::ReadDataHandlerResult WorldSocket::HandleKeepAlive ( )
private

Definition at line 943 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleLogDisconnect()

WorldSocket::ReadDataHandlerResult WorldSocket::HandleLogDisconnect ( WorldPacket &&  packet) const
private

Definition at line 959 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandlePing()

WorldSocket::ReadDataHandlerResult WorldSocket::HandlePing ( WorldPacket &&  packet)
private

Definition at line 1045 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InitializeCompression()

bool WorldSocket::InitializeCompression ( )

Definition at line 183 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadSessionPermissionsCallback()

void WorldSocket::LoadSessionPermissionsCallback ( PreparedQueryResult  result)
private

Definition at line 851 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ LogOpcodeText() [1/2]

void WorldSocket::LogOpcodeText ( OpcodeClient  opcode) const
private

writes network.opcode log

Definition at line 436 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LogOpcodeText() [2/2]

void WorldSocket::LogOpcodeText ( OpcodeClient  opcode,
std::scoped_lock< std::mutex > const &  guard 
) const
private

Definition at line 441 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ OnClose()

void WorldSocket::OnClose ( )
overridevirtual

Reimplemented from Trinity::Net::Socket< Stream >.

Definition at line 254 of file WorldSocket.cpp.

◆ operator=() [1/2]

WorldSocket & WorldSocket::operator= ( WorldSocket &&  right)
delete

◆ operator=() [2/2]

WorldSocket & WorldSocket::operator= ( WorldSocket const &  right)
delete

◆ QueueQuery()

void WorldSocket::QueueQuery ( QueryCallback &&  queryCallback)

Definition at line 320 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadDataHandler()

WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler ( )
protected

Definition at line 357 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadHandler()

Trinity::Net::SocketReadCallbackResult WorldSocket::ReadHandler ( )
overridevirtual

Reimplemented from Trinity::Net::Socket< Stream >.

Definition at line 262 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ ReadHeaderHandler()

bool WorldSocket::ReadHeaderHandler ( )
protected

Definition at line 332 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendAuthResponseError()

void WorldSocket::SendAuthResponseError ( uint32  code)

Definition at line 1038 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendAuthSession()

void WorldSocket::SendAuthSession ( )

Definition at line 242 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendPacket()

void WorldSocket::SendPacket ( WorldPacket const &  packet)

Definition at line 459 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendPacketAndLogOpcode()

void WorldSocket::SendPacketAndLogOpcode ( WorldPacket const &  packet)
private

sends and logs network.opcode without accessing WorldSession

Definition at line 453 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetSendBufferSize()

void WorldSocket::SetSendBufferSize ( std::size_t  sendBufferSize)
inline

Definition at line 112 of file WorldSocket.h.

◆ SetWorldSession()

void WorldSocket::SetWorldSession ( WorldSession session)

Definition at line 325 of file WorldSocket.cpp.

◆ Start()

void WorldSocket::Start ( )
overridevirtual

Reimplemented from Trinity::Net::Socket< Stream >.

Definition at line 121 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ Update()

bool WorldSocket::Update ( )
overridevirtual

Reimplemented from Trinity::Net::Socket< Stream >.

Definition at line 202 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ WritePacketToBuffer()

void WorldSocket::WritePacketToBuffer ( EncryptablePacket const &  packet,
MessageBuffer buffer 
)
private

Definition at line 470 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _authCrypt

WorldPacketCrypt WorldSocket::_authCrypt
private

Definition at line 157 of file WorldSocket.h.

◆ _authed

bool WorldSocket::_authed
private

Definition at line 166 of file WorldSocket.h.

◆ _bufferQueue

MPSCQueue<EncryptablePacket, &EncryptablePacket::SocketQueueLink> WorldSocket::_bufferQueue
private

Definition at line 171 of file WorldSocket.h.

◆ _canRequestHotfixes

bool WorldSocket::_canRequestHotfixes
private

Definition at line 167 of file WorldSocket.h.

◆ _compressionStream

z_stream* WorldSocket::_compressionStream
private

Definition at line 174 of file WorldSocket.h.

◆ _encryptKey

std::array<uint8, 32> WorldSocket::_encryptKey
private

Definition at line 159 of file WorldSocket.h.

◆ _headerBuffer

MessageBuffer WorldSocket::_headerBuffer
private

Definition at line 169 of file WorldSocket.h.

◆ _ipCountry

std::string WorldSocket::_ipCountry
private

Definition at line 177 of file WorldSocket.h.

◆ _key

uint64 WorldSocket::_key
private

Definition at line 154 of file WorldSocket.h.

◆ _lastPingTime

TimePoint WorldSocket::_lastPingTime
private

Definition at line 161 of file WorldSocket.h.

◆ _overSpeedPings

uint32 WorldSocket::_overSpeedPings
private

Definition at line 162 of file WorldSocket.h.

◆ _packetBuffer

MessageBuffer WorldSocket::_packetBuffer
private

Definition at line 170 of file WorldSocket.h.

◆ _queryProcessor

QueryCallbackProcessor WorldSocket::_queryProcessor
private

Definition at line 176 of file WorldSocket.h.

◆ _sendBufferSize

std::size_t WorldSocket::_sendBufferSize
private

Definition at line 172 of file WorldSocket.h.

◆ _serverChallenge

std::array<uint8, 32> WorldSocket::_serverChallenge
private

Definition at line 156 of file WorldSocket.h.

◆ _sessionKey

SessionKey WorldSocket::_sessionKey
private

Definition at line 158 of file WorldSocket.h.

◆ _type

ConnectionType WorldSocket::_type
private

Definition at line 153 of file WorldSocket.h.

◆ _worldSession

WorldSession* WorldSocket::_worldSession
private

Definition at line 165 of file WorldSocket.h.

◆ _worldSessionLock

std::mutex WorldSocket::_worldSessionLock
private

Definition at line 164 of file WorldSocket.h.

◆ AuthCheckSeed

std::array< uint8, 32 > const WorldSocket::AuthCheckSeed
staticprivate
Initial value:
= { 0xDE, 0x3A, 0x2A, 0x8E, 0x6B, 0x89, 0x52, 0x66, 0x88, 0x9D, 0x7E, 0x7A, 0x77, 0x1D, 0x5D, 0x1F,
0x4E, 0xD9, 0x0C, 0x23, 0x9B, 0xCD, 0x0E, 0xDC, 0xD2, 0xE8, 0x04, 0x3A, 0x68, 0x64, 0xC7, 0xB0 }

Definition at line 56 of file WorldSocket.h.

◆ ContinuedSessionSeed

std::array< uint8, 32 > const WorldSocket::ContinuedSessionSeed
staticprivate
Initial value:
= { 0x56, 0x5C, 0x61, 0x9C, 0x48, 0x3A, 0x52, 0x1F, 0x61, 0x5D, 0x05, 0x49, 0xB2, 0x9A, 0x39, 0xBF,
0x4B, 0x97, 0xB0, 0x1B, 0xF9, 0x6C, 0xDE, 0xD6, 0x80, 0x1D, 0xAB, 0x26, 0x02, 0xA9, 0x9B, 0x9D }

Definition at line 60 of file WorldSocket.h.

◆ EncryptionKeySeed

std::array< uint8, 32 > const WorldSocket::EncryptionKeySeed
staticprivate
Initial value:
= { 0x71, 0xC9, 0xED, 0x5A, 0xA7, 0x0E, 0x4D, 0xFF, 0x4C, 0x36, 0xA6, 0x5A, 0x3E, 0x46, 0x8A, 0x4A,
0x5D, 0xA1, 0x48, 0xC8, 0x30, 0x47, 0x4A, 0xDE, 0xF6, 0x0D, 0x6C, 0xBE, 0x6F, 0xE4, 0x55, 0x73 }

Definition at line 62 of file WorldSocket.h.

◆ MinSizeForCompression

uint32 const WorldSocket::MinSizeForCompression = 0x400
staticprivate

Definition at line 85 of file WorldSocket.h.

◆ SessionKeySeed

std::array< uint8, 32 > const WorldSocket::SessionKeySeed
staticprivate
Initial value:
= { 0xE8, 0x1E, 0x8B, 0x59, 0x27, 0x62, 0x1E, 0xAA, 0x86, 0x15, 0x18, 0xEA, 0xC0, 0xBF, 0x66, 0x8C,
0x6D, 0xBF, 0x83, 0x93, 0xBC, 0xAA, 0x80, 0x52, 0x5B, 0x1E, 0xDC, 0x23, 0xA0, 0x12, 0xB7, 0x50 }

Definition at line 58 of file WorldSocket.h.


The documentation for this class was generated from the following files: