AzerothCore 3.3.5a
OpenSource WoW Emulator
|
#include "WorldSocket.h"
Public Member Functions | |
WorldSocket (tcp::socket &&socket) | |
~WorldSocket () | |
WorldSocket (WorldSocket const &right)=delete | |
WorldSocket & | operator= (WorldSocket const &right)=delete |
void | Start () override |
bool | Update () override |
void | SendPacket (WorldPacket const &packet) |
void | SetSendBufferSize (std::size_t sendBufferSize) |
Public Member Functions inherited from Socket< WorldSocket > | |
Socket (tcp::socket &&socket) | |
virtual | ~Socket () |
virtual void | Start ()=0 |
virtual bool | Update () |
boost::asio::ip::address | GetRemoteIpAddress () const |
uint16 | GetRemotePort () const |
void | AsyncRead () |
void | AsyncReadProxyHeader () |
void | AsyncReadWithCallback (void(T::*callback)(boost::system::error_code, std::size_t)) |
void | QueuePacket (MessageBuffer &&buffer) |
ProxyHeaderReadingState | GetProxyHeaderReadingState () const |
bool | IsOpen () const |
void | CloseSocket () |
void | DelayedCloseSocket () |
Marks the socket for closing after write buffer becomes empty. More... | |
MessageBuffer & | GetReadBuffer () |
Protected Types | |
enum class | ReadDataHandlerResult { Ok = 0 , Error = 1 , WaitingForQuery = 2 } |
Protected Member Functions | |
void | OnClose () override |
void | ReadHandler () override |
bool | ReadHeaderHandler () |
ReadDataHandlerResult | ReadDataHandler () |
Protected Member Functions inherited from Socket< WorldSocket > | |
virtual void | OnClose () |
virtual void | ReadHandler ()=0 |
bool | AsyncProcessQueue () |
void | SetNoDelay (bool enable) |
Private Types | |
typedef Socket< WorldSocket > | BaseSocket |
Private Member Functions | |
void | CheckIpCallback (PreparedQueryResult result) |
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 More... | |
void | HandleSendAuthSession () |
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 > | _authSeed |
AuthCrypt | _authCrypt |
TimePoint | _LastPingTime |
uint32 | _OverSpeedPings |
std::mutex | _worldSessionLock |
WorldSession * | _worldSession |
bool | _authed |
MessageBuffer | _headerBuffer |
MessageBuffer | _packetBuffer |
MPSCQueue< EncryptableAndCompressiblePacket, &EncryptableAndCompressiblePacket::SocketQueueLink > | _bufferQueue |
std::size_t | _sendBufferSize |
QueryCallbackProcessor | _queryProcessor |
std::string | _ipCountry |
|
private |
|
strongprotected |
Enumerator | |
---|---|
Ok | |
Error | |
WaitingForQuery |
WorldSocket::WorldSocket | ( | tcp::socket && | socket | ) |
References _authSeed, _headerBuffer, Acore::Crypto::GetRandomBytes(), and MessageBuffer::Resize().
|
default |
|
delete |
|
private |
References Socket< WorldSocket >::AsyncRead(), AUTH_REJECT, Socket< WorldSocket >::DelayedCloseSocket(), Socket< WorldSocket >::GetRemoteIpAddress(), HandleSendAuthSession(), LOG_ERROR, and SendAuthResponseError().
Referenced by Start().
|
private |
References _queryProcessor, AsyncCallbackProcessor< T >::AddCallback(), HandleAuthSessionCallback(), Realm::Id, LOGIN_SEL_ACCOUNT_INFO_BY_NAME, LoginDatabase, ByteBuffer::read(), realm, RealmHandle::Realm, ByteBuffer::rpos(), PreparedStatementBase::SetData(), and ByteBuffer::size().
Referenced by ReadDataHandler().
|
private |
Negative mutetime indicates amount of minutes to be muted effective on next login - which is now.
References _authCrypt, _authed, _authSeed, _ipCountry, _worldSession, Socket< WorldSocket >::AsyncRead(), AUTH_BANNED, AUTH_FAILED, AUTH_REJECT, AUTH_UNAVAILABLE, AUTH_UNKNOWN_ACCOUNT, CONFIG_WARDEN_ENABLED, Socket< WorldSocket >::DelayedCloseSocket(), AccountInfo::Expansion, Acore::Impl::GenericHash< HashCreator, DigestLength >::Finalize(), Acore::Impl::GenericHash< HashCreator, DigestLength >::GetDigest(), GameTime::GetGameTime(), Socket< WorldSocket >::GetRemoteIpAddress(), AccountInfo::Id, Realm::Id, AuthCrypt::Init(), WorldSession::InitWarden(), AccountInfo::IsBanned, AccountInfo::IsLockedToIP, AccountInfo::IsRectuiter, AccountInfo::LastIP, AccountInfo::Locale, AccountInfo::LockCountry, LOG_DEBUG, LOG_ERROR, LOGIN_UPD_LAST_ATTEMPT_IP, LOGIN_UPD_LAST_IP, LOGIN_UPD_MUTE_TIME_LOGIN, LoginDatabase, AccountInfo::MuteTime, AccountInfo::OS, WorldSession::ReadAddonsInfo(), realm, RealmHandle::Realm, REALM_LIST_REALM_NOT_FOUND, AccountInfo::Recruiter, sConfigMgr, SEC_PLAYER, AccountInfo::Security, SendAuthResponseError(), AccountInfo::SessionKey, PreparedStatementBase::SetData(), sIPLocation, sScriptMgr, sWorld, AccountInfo::TotalTime, and Acore::Impl::GenericHash< HashCreator, DigestLength >::UpdateData().
Referenced by HandleAuthSession().
|
private |
References _LastPingTime, _OverSpeedPings, _worldSession, _worldSessionLock, CONFIG_MAX_OVERSPEED_PINGS, WorldSession::GetPlayerInfo(), Socket< WorldSocket >::GetRemoteIpAddress(), WorldSession::GetSecurity(), AccountMgr::IsPlayerAccount(), LOG_ERROR, SendPacketAndLogOpcode(), WorldSession::SetLatency(), SMSG_PONG, and sWorld.
Referenced by ReadDataHandler().
|
private |
References _authSeed, ByteBuffer::append(), SendPacketAndLogOpcode(), and SMSG_AUTH_CHALLENGE.
Referenced by CheckIpCallback().
|
private |
|
private |
writes network.opcode log accessing WorldSession is not threadsafe, only do it when holding _worldSessionLock
References _worldSession, GetOpcodeNameForLogging(), WorldSession::GetPlayerInfo(), Socket< WorldSocket >::GetRemoteIpAddress(), and LOG_TRACE.
Referenced by ReadDataHandler().
|
overrideprotectedvirtual |
Reimplemented from Socket< WorldSocket >.
References _worldSession, and _worldSessionLock.
|
delete |
|
protected |
References _authed, _headerBuffer, _packetBuffer, _worldSession, _worldSessionLock, CLIENT_TO_SERVER, ClientPktHeader::cmd, CMSG_AUTH_SESSION, CMSG_KEEP_ALIVE, CMSG_PING, CMSG_TIME_SYNC_RESP, CMSG_WARDEN_DATA, Error, WorldPacket::GetOpcode(), GetOpcodeNameForLogging(), WorldSession::GetPlayerInfo(), MessageBuffer::GetReadPointer(), Socket< WorldSocket >::GetRemoteIpAddress(), Socket< WorldSocket >::GetRemotePort(), HandleAuthSession(), HandlePing(), LOG_ERROR, LogOpcodeText(), GameTime::Now(), Ok, opcodeTable, WorldSession::QueuePacket(), WorldSession::ResetTimeOutTime(), sPacketLog, and WaitingForQuery.
Referenced by ReadHandler().
|
overrideprotectedvirtual |
Implements Socket< WorldSocket >.
References _headerBuffer, _packetBuffer, ASSERT, Socket< WorldSocket >::AsyncRead(), Socket< WorldSocket >::CloseSocket(), MessageBuffer::GetActiveSize(), Socket< WorldSocket >::GetReadBuffer(), MessageBuffer::GetReadPointer(), MessageBuffer::GetRemainingSpace(), Socket< WorldSocket >::IsOpen(), Ok, MessageBuffer::ReadCompleted(), ReadDataHandler(), ReadHeaderHandler(), MessageBuffer::Reset(), WaitingForQuery, and MessageBuffer::Write().
|
protected |
References _authCrypt, _headerBuffer, _packetBuffer, ASSERT, ClientPktHeader::cmd, AuthCrypt::DecryptRecv(), EndianConvert(), EndianConvertReverse(), MessageBuffer::GetActiveSize(), MessageBuffer::GetReadPointer(), Socket< WorldSocket >::GetRemoteIpAddress(), AuthCrypt::IsInitialized(), ClientPktHeader::IsValidOpcode(), ClientPktHeader::IsValidSize(), LOG_ERROR, MessageBuffer::Resize(), and ClientPktHeader::size.
Referenced by ReadHandler().
|
private |
References SendPacketAndLogOpcode(), and SMSG_AUTH_RESPONSE.
Referenced by CheckIpCallback(), and HandleAuthSessionCallback().
void WorldSocket::SendPacket | ( | WorldPacket const & | packet | ) |
References _authCrypt, _bufferQueue, Socket< WorldSocket >::GetRemoteIpAddress(), Socket< WorldSocket >::GetRemotePort(), AuthCrypt::IsInitialized(), Socket< WorldSocket >::IsOpen(), SERVER_TO_CLIENT, and sPacketLog.
Referenced by SendPacketAndLogOpcode().
|
private |
sends and logs network.opcode without accessing WorldSession
References WorldPacket::GetOpcode(), GetOpcodeNameForLogging(), Socket< WorldSocket >::GetRemoteIpAddress(), LOG_TRACE, and SendPacket().
Referenced by HandlePing(), HandleSendAuthSession(), and SendAuthResponseError().
|
inline |
|
overridevirtual |
Implements Socket< WorldSocket >.
References _queryProcessor, AsyncCallbackProcessor< T >::AddCallback(), CheckIpCallback(), Socket< WorldSocket >::GetRemoteIpAddress(), LOGIN_SEL_IP_INFO, LoginDatabase, and PreparedStatementBase::SetData().
|
overridevirtual |
Reimplemented from Socket< WorldSocket >.
References _authCrypt, _bufferQueue, _queryProcessor, _sendBufferSize, EncryptableAndCompressiblePacket::CompressIfNeeded(), ByteBuffer::contents(), ByteBuffer::empty(), AuthCrypt::EncryptSend(), MessageBuffer::GetActiveSize(), ServerPktHeader::getHeaderLength(), WorldPacket::GetOpcode(), MessageBuffer::GetRemainingSpace(), ServerPktHeader::header, EncryptableAndCompressiblePacket::NeedsEncryption(), AsyncCallbackProcessor< T >::ProcessReadyCallbacks(), Socket< WorldSocket >::QueuePacket(), MessageBuffer::Resize(), ByteBuffer::size(), Socket< WorldSocket >::Update(), and MessageBuffer::Write().
|
private |
Referenced by HandleAuthSessionCallback(), ReadHeaderHandler(), SendPacket(), and Update().
|
private |
Referenced by HandleAuthSessionCallback(), and ReadDataHandler().
|
private |
Referenced by HandleAuthSessionCallback(), HandleSendAuthSession(), and WorldSocket().
|
private |
Referenced by SendPacket(), and Update().
|
private |
Referenced by ReadDataHandler(), ReadHandler(), ReadHeaderHandler(), and WorldSocket().
|
private |
Referenced by HandleAuthSessionCallback().
|
private |
Referenced by HandlePing().
|
private |
Referenced by HandlePing().
|
private |
Referenced by ReadDataHandler(), ReadHandler(), and ReadHeaderHandler().
|
private |
Referenced by HandleAuthSession(), Start(), and Update().
|
private |
Referenced by Update().
|
private |
Referenced by HandleAuthSessionCallback(), HandlePing(), LogOpcodeText(), OnClose(), and ReadDataHandler().
|
private |
Referenced by HandlePing(), OnClose(), and ReadDataHandler().