![]() |
TrinityCore
|
#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 | |
| WorldSocket & | operator= (WorldSocket const &right)=delete |
| WorldSocket & | operator= (WorldSocket &&right)=delete |
| void | Start () override |
| bool | Update () override |
| void | SendPacket (WorldPacket const &packet) |
| void | SetSendBufferSize (std::size_t sendBufferSize) |
| void | OnClose () override |
| Trinity::Net::SocketReadCallbackResult | ReadHandler () override |
| void | QueueQuery (QueryCallback &&queryCallback) |
| void | SendAuthSession () |
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 | |
| Socket & | operator= (Socket const &other)=delete |
| Socket & | operator= (Socket &&other)=delete |
| virtual | ~Socket () |
| boost::asio::ip::address const & | GetRemoteIpAddress () const |
| uint16 | GetRemotePort () const |
| template<SocketReadCallback 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. | |
| MessageBuffer & | GetReadBuffer () |
| 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, std::unique_lock< std::mutex > const &guard) const |
| void | SendPacketAndLogOpcode (WorldPacket const &packet) |
| sends and logs network.opcode without accessing WorldSession | |
| void | HandleAuthSession (WorldPacket &recvPacket) |
| void | HandleAuthSessionCallback (std::shared_ptr< AuthSession > authSession, PreparedQueryResult result) |
| void | LoadSessionPermissionsCallback (PreparedQueryResult result) |
| void | SendAuthResponseError (uint8 code) |
| bool | HandlePing (WorldPacket &recvPacket) |
Private Attributes | |
| std::array< uint8, 4 > | _serverChallenge |
| std::array< uint8, 32 > | _dosChallenge |
| WorldPacketCrypt | _authCrypt |
| TimePoint | _LastPingTime |
| uint32 | _OverSpeedPings |
| std::mutex | _worldSessionLock |
| WorldSession * | _worldSession |
| bool | _authed |
| MessageBuffer | _headerBuffer |
| MessageBuffer | _packetBuffer |
| MPSCQueue< EncryptablePacket, &EncryptablePacket::SocketQueueLink > | _bufferQueue |
| std::size_t | _sendBufferSize |
| QueryCallbackProcessor | _queryProcessor |
| std::string | _ipCountry |
Definition at line 67 of file WorldSocket.h.
|
private |
Definition at line 69 of file WorldSocket.h.
|
strongprotected |
| Enumerator | |
|---|---|
| Ok | |
| Error | |
| WaitingForQuery | |
Definition at line 97 of file WorldSocket.h.
| WorldSocket::WorldSocket | ( | Trinity::Net::IoContextTcpSocket && | socket | ) |
Definition at line 37 of file WorldSocket.cpp.
References _headerBuffer, and MessageBuffer::Resize().
|
default |
|
delete |
|
delete |
|
private |
Definition at line 423 of file WorldSocket.cpp.
References Realm::Id, LOGIN_SEL_ACCOUNT_INFO_BY_NAME, LoginDatabase, QueueQuery(), ByteBuffer::read(), realm, RealmHandle::Realm, ByteBuffer::rpos(), PreparedStatementBase::setInt32(), PreparedStatementBase::setString(), and ByteBuffer::size().
Referenced by ReadDataHandler().
|
private |
Negative mutetime indicates amount of seconds to be muted effective on next login - which is now.
Definition at line 452 of file WorldSocket.cpp.
References _authCrypt, _authed, _ipCountry, _serverChallenge, _worldSession, Trinity::Net::Socket< Stream >::AsyncRead(), AUTH_BANNED, AUTH_FAILED, AUTH_REJECT, AUTH_UNAVAILABLE, AUTH_UNKNOWN_ACCOUNT, CONFIG_ALLOW_LOGGING_IP_ADDRESSES_IN_DATABASE, CONFIG_WARDEN_ENABLED, Trinity::Net::Socket< Stream >::DelayedCloseSocket(), AccountInfo::Expansion, Trinity::Impl::GenericHash< HashCreator, DigestLength >::Finalize(), Trinity::Impl::GenericHash< HashCreator, DigestLength >::GetDigest(), GameTime::GetGameTime(), Trinity::Net::Socket< Stream >::GetRemoteIpAddress(), AccountInfo::Id, Realm::Id, WorldPacketCrypt::Init(), WorldSession::InitWarden(), AccountInfo::IsBanned, AccountInfo::IsLockedToIP, AccountInfo::IsRectuiter, ClientBuild::Platform::IsValid(), AccountInfo::LastIP, WorldSession::LoadPermissionsAsync(), LoadSessionPermissionsCallback(), AccountInfo::Locale, AccountInfo::LockCountry, LOGIN_UPD_LAST_ATTEMPT_IP, LOGIN_UPD_LAST_IP, LOGIN_UPD_MUTE_TIME_LOGIN, LoginDatabase, AccountInfo::MuteTime, AccountInfo::OS, QueueQuery(), WorldSession::ReadAddonsInfo(), realm, RealmHandle::Realm, REALM_LIST_REALM_NOT_FOUND, AccountInfo::Recruiter, SEC_PLAYER, AccountInfo::Security, SendAuthResponseError(), AccountInfo::SessionKey, PreparedStatementBase::setInt64(), PreparedStatementBase::setString(), PreparedStatementBase::setUInt32(), sIPLocation, Trinity::Net::InvokeReadHandlerCallback< SocketType >::Socket, sScriptMgr, sWorld, TC_LOG_DEBUG, TC_LOG_ERROR, AccountInfo::TimezoneOffset, Trinity::Impl::GenericHash< HashCreator, DigestLength >::UpdateData(), and QueryCallback::WithPreparedCallback().
|
private |
Definition at line 640 of file WorldSocket.cpp.
References _LastPingTime, _OverSpeedPings, _worldSession, _worldSessionLock, CONFIG_MAX_OVERSPEED_PINGS, WorldSession::GetPlayerInfo(), Trinity::Net::Socket< Stream >::GetRemoteIpAddress(), WorldSession::HasPermission(), rbac::RBAC_PERM_SKIP_CHECK_OVERSPEED_PING, SendPacketAndLogOpcode(), WorldSession::SetLatency(), SMSG_PONG, sWorld, and TC_LOG_ERROR.
Referenced by ReadDataHandler().
|
private |
Definition at line 624 of file WorldSocket.cpp.
References _worldSession, WorldSession::GetRBACData(), rbac::RBACData::LoadFromDBCallback(), and sWorld.
Referenced by HandleAuthSessionCallback().
|
private |
writes network.opcode log accessing WorldSession is not threadsafe, only do it when holding _worldSessionLock
Definition at line 394 of file WorldSocket.cpp.
References _worldSession, GetOpcodeNameForLogging(), WorldSession::GetPlayerInfo(), Trinity::Net::Socket< Stream >::GetRemoteIpAddress(), and TC_LOG_TRACE.
Referenced by ReadDataHandler().
|
overridevirtual |
Reimplemented from Trinity::Net::Socket< Stream >.
Definition at line 136 of file WorldSocket.cpp.
References _worldSession, and _worldSessionLock.
|
delete |
|
delete |
| void WorldSocket::QueueQuery | ( | QueryCallback && | queryCallback | ) |
Definition at line 202 of file WorldSocket.cpp.
References _queryProcessor, and AsyncCallbackProcessor< T >::AddCallback().
Referenced by HandleAuthSession(), and HandleAuthSessionCallback().
|
protected |
Definition at line 297 of file WorldSocket.cpp.
References _authed, _headerBuffer, _packetBuffer, _worldSession, _worldSessionLock, CLIENT_TO_SERVER, ClientPktHeader::cmd, CMSG_AUTH_SESSION, CMSG_KEEP_ALIVE, CMSG_PING, CMSG_TIME_SYNC_RESP, Error, WorldPacket::GetOpcode(), GetOpcodeNameForLogging(), WorldSession::GetPlayerInfo(), MessageBuffer::GetReadPointer(), Trinity::Net::Socket< Stream >::GetRemoteIpAddress(), Trinity::Net::Socket< Stream >::GetRemotePort(), HandleAuthSession(), HandlePing(), LogOpcodeText(), Ok, opcodeTable, WorldSession::QueuePacket(), WorldSession::ResetTimeOutTime(), sPacketLog, TC_LOG_ERROR, and WaitingForQuery.
Referenced by ReadHandler().
|
overridevirtual |
Reimplemented from Trinity::Net::Socket< Stream >.
Definition at line 144 of file WorldSocket.cpp.
References _headerBuffer, _packetBuffer, ASSERT, Trinity::Net::Socket< Stream >::CloseSocket(), MessageBuffer::GetActiveSize(), Trinity::Net::Socket< Stream >::GetReadBuffer(), MessageBuffer::GetReadPointer(), MessageBuffer::GetRemainingSpace(), Trinity::Net::KeepReading, Ok, MessageBuffer::ReadCompleted(), ReadDataHandler(), ReadHeaderHandler(), MessageBuffer::Reset(), Trinity::Net::Stop, WaitingForQuery, and MessageBuffer::Write().
|
protected |
Definition at line 207 of file WorldSocket.cpp.
References _authCrypt, _headerBuffer, _packetBuffer, ASSERT, ClientPktHeader::cmd, WorldPacketCrypt::DecryptRecv(), EndianConvert(), EndianConvertReverse(), MessageBuffer::GetActiveSize(), MessageBuffer::GetReadPointer(), Trinity::Net::Socket< Stream >::GetRemoteIpAddress(), WorldPacketCrypt::IsInitialized(), ClientPktHeader::IsValidOpcode(), ClientPktHeader::IsValidSize(), MessageBuffer::Resize(), ClientPktHeader::size, and TC_LOG_ERROR.
Referenced by ReadHandler().
|
private |
Definition at line 632 of file WorldSocket.cpp.
References SendPacketAndLogOpcode(), and SMSG_AUTH_RESPONSE.
Referenced by HandleAuthSessionCallback().
| void WorldSocket::SendAuthSession | ( | ) |
Definition at line 123 of file WorldSocket.cpp.
References _dosChallenge, _serverChallenge, WorldPackets::Auth::AuthChallenge::Challenge, WorldPackets::Auth::AuthChallenge::DosChallenge, WorldPackets::Auth::AuthChallenge::DosZeroBits, Trinity::Crypto::GetRandomBytes(), SendPacketAndLogOpcode(), and WorldPackets::Auth::AuthChallenge::Write().
Referenced by WorldSocketProtocolInitializer::Start().
| void WorldSocket::SendPacket | ( | WorldPacket const & | packet | ) |
Definition at line 412 of file WorldSocket.cpp.
References _authCrypt, _bufferQueue, Trinity::Net::Socket< Stream >::GetRemoteIpAddress(), Trinity::Net::Socket< Stream >::GetRemotePort(), WorldPacketCrypt::IsInitialized(), Trinity::Net::Socket< Stream >::IsOpen(), SERVER_TO_CLIENT, and sPacketLog.
Referenced by SendPacketAndLogOpcode().
|
private |
sends and logs network.opcode without accessing WorldSession
Definition at line 406 of file WorldSocket.cpp.
References WorldPacket::GetOpcode(), GetOpcodeNameForLogging(), Trinity::Net::Socket< Stream >::GetRemoteIpAddress(), SendPacket(), and TC_LOG_TRACE.
Referenced by HandlePing(), SendAuthResponseError(), and SendAuthSession().
|
inline |
Definition at line 85 of file WorldSocket.h.
|
overridevirtual |
Reimplemented from Trinity::Net::Socket< Stream >.
Definition at line 60 of file WorldSocket.cpp.
References Trinity::Net::SocketConnectionInitializer::SetupChain(), and Start().
Referenced by Start().
|
overridevirtual |
Reimplemented from Trinity::Net::Socket< Stream >.
Definition at line 73 of file WorldSocket.cpp.
References _authCrypt, _bufferQueue, _queryProcessor, _sendBufferSize, ByteBuffer::contents(), ByteBuffer::empty(), WorldPacketCrypt::EncryptSend(), MessageBuffer::GetActiveSize(), ServerPktHeader::getHeaderLength(), WorldPacket::GetOpcode(), MessageBuffer::GetRemainingSpace(), ServerPktHeader::header, EncryptablePacket::NeedsEncryption(), AsyncCallbackProcessor< T >::ProcessReadyCallbacks(), Trinity::Net::Socket< Stream >::QueuePacket(), MessageBuffer::Resize(), ByteBuffer::size(), and MessageBuffer::Write().
|
private |
Definition at line 121 of file WorldSocket.h.
Referenced by HandleAuthSessionCallback(), ReadHeaderHandler(), SendPacket(), and Update().
|
private |
Definition at line 128 of file WorldSocket.h.
Referenced by HandleAuthSessionCallback(), and ReadDataHandler().
|
private |
Definition at line 132 of file WorldSocket.h.
Referenced by SendPacket(), and Update().
|
private |
Definition at line 120 of file WorldSocket.h.
Referenced by SendAuthSession().
|
private |
Definition at line 130 of file WorldSocket.h.
Referenced by ReadDataHandler(), ReadHandler(), ReadHeaderHandler(), and WorldSocket().
|
private |
Definition at line 136 of file WorldSocket.h.
Referenced by HandleAuthSessionCallback().
|
private |
Definition at line 123 of file WorldSocket.h.
Referenced by HandlePing().
|
private |
Definition at line 124 of file WorldSocket.h.
Referenced by HandlePing().
|
private |
Definition at line 131 of file WorldSocket.h.
Referenced by ReadDataHandler(), ReadHandler(), and ReadHeaderHandler().
|
private |
Definition at line 135 of file WorldSocket.h.
Referenced by QueueQuery(), and Update().
|
private |
Definition at line 133 of file WorldSocket.h.
Referenced by Update().
|
private |
Definition at line 119 of file WorldSocket.h.
Referenced by HandleAuthSessionCallback(), and SendAuthSession().
|
private |
Definition at line 127 of file WorldSocket.h.
Referenced by HandleAuthSessionCallback(), HandlePing(), LoadSessionPermissionsCallback(), LogOpcodeText(), OnClose(), and ReadDataHandler().
|
private |
Definition at line 126 of file WorldSocket.h.
Referenced by HandlePing(), OnClose(), and ReadDataHandler().