mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/NetworkIO: Removed MSG_VERIFY_CONNECTIVITY as an opcode
This commit is contained in:
@@ -612,7 +612,6 @@ void OpcodeTable::Initialize()
|
||||
DEFINE_OPCODE_HANDLER(MSG_SET_RAID_DIFFICULTY, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleSetRaidDifficultyOpcode );
|
||||
DEFINE_OPCODE_HANDLER(MSG_TABARDVENDOR_ACTIVATE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleTabardVendorActivateOpcode);
|
||||
DEFINE_OPCODE_HANDLER(MSG_TALENT_WIPE_CONFIRM, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleTalentWipeConfirmOpcode );
|
||||
DEFINE_OPCODE_HANDLER(MSG_VERIFY_CONNECTIVITY, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_EarlyProccess );
|
||||
DEFINE_OPCODE_HANDLER(SMSG_ACCOUNT_DATA_TIMES, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide );
|
||||
DEFINE_OPCODE_HANDLER(SMSG_ACCOUNT_INFO_RESPONSE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_ServerSide );
|
||||
DEFINE_OPCODE_HANDLER(SMSG_ACCOUNT_RESTRICTED_WARNING, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_ServerSide );
|
||||
|
||||
@@ -653,7 +653,6 @@ enum Opcodes
|
||||
MSG_START_MOVE_FORWARD = 0x0000,
|
||||
MSG_TABARDVENDOR_ACTIVATE = 0x6926,
|
||||
MSG_TALENT_WIPE_CONFIRM = 0x0107,
|
||||
MSG_VERIFY_CONNECTIVITY = 0x4F57,
|
||||
SMSG_ACCOUNT_DATA_TIMES = 0x4B05,
|
||||
SMSG_ACCOUNT_INFO_RESPONSE = 0x10A7,
|
||||
SMSG_ACCOUNT_RESTRICTED_WARNING = 0x51A7,
|
||||
|
||||
@@ -28,21 +28,23 @@
|
||||
|
||||
using boost::asio::ip::tcp;
|
||||
|
||||
WorldSocket::WorldSocket(tcp::socket&& socket)
|
||||
: Socket(std::move(socket), sizeof(ClientPktHeader)), _authSeed(rand32()), _OverSpeedPings(0), _worldSession(nullptr)
|
||||
std::string const WorldSocket::ServerConnectionInitialize("WORLD OF WARCRAFT CONNECTION - SERVER TO CLIENT");
|
||||
|
||||
std::string const WorldSocket::ClientConnectionInitialize("WORLD OF WARCRAFT CONNECTION - CLIENT TO SERVER");
|
||||
|
||||
WorldSocket::WorldSocket(tcp::socket&& socket) : Socket(std::move(socket), sizeof(ClientPktHeader)),
|
||||
_authSeed(rand32()), _OverSpeedPings(0), _worldSession(nullptr), _initialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
void WorldSocket::Start()
|
||||
{
|
||||
sScriptMgr->OnSocketOpen(shared_from_this());
|
||||
AsyncReadHeader();
|
||||
|
||||
// not an opcode. this packet sends raw string WORLD OF WARCRAFT CONNECTION - SERVER TO CLIENT"
|
||||
// because of our implementation of WorldPacket sending, bytes "WO" become the opcode
|
||||
WorldPacket packet(MSG_VERIFY_CONNECTIVITY);
|
||||
packet << "RLD OF WARCRAFT CONNECTION - SERVER TO CLIENT";
|
||||
AsyncWrite(packet);
|
||||
AsyncReadData(ClientConnectionInitialize.length() + 2 /*sizeof(ClientPktHeader::size)*/ + 1 /*null terminator*/);
|
||||
|
||||
_writeQueue.emplace(ServerConnectionInitialize);
|
||||
AsyncWrite(_writeQueue.front());
|
||||
}
|
||||
|
||||
void WorldSocket::HandleSendAuthSession()
|
||||
@@ -90,85 +92,85 @@ void WorldSocket::ReadHeaderHandler()
|
||||
|
||||
void WorldSocket::ReadDataHandler()
|
||||
{
|
||||
ClientPktHeader* header = reinterpret_cast<ClientPktHeader*>(GetHeaderBuffer());
|
||||
if (_initialized)
|
||||
{
|
||||
ClientPktHeader* header = reinterpret_cast<ClientPktHeader*>(GetHeaderBuffer());
|
||||
|
||||
Opcodes opcode = PacketFilter::DropHighBytes(Opcodes(header->cmd));
|
||||
|
||||
std::string opcodeName = GetOpcodeNameForLogging(opcode);
|
||||
std::string opcodeName = GetOpcodeNameForLogging(opcode);
|
||||
|
||||
WorldPacket packet(opcode, MoveData());
|
||||
WorldPacket packet(opcode, MoveData());
|
||||
|
||||
if (sPacketLog->CanLogPacket())
|
||||
sPacketLog->LogPacket(packet, CLIENT_TO_SERVER, GetRemoteIpAddress(), GetRemotePort());
|
||||
if (sPacketLog->CanLogPacket())
|
||||
sPacketLog->LogPacket(packet, CLIENT_TO_SERVER, GetRemoteIpAddress(), GetRemotePort());
|
||||
|
||||
TC_LOG_TRACE("network.opcode", "C->S: %s %s", (_worldSession ? _worldSession->GetPlayerInfo() : GetRemoteIpAddress().to_string()).c_str(), opcodeName.c_str());
|
||||
TC_LOG_TRACE("network.opcode", "C->S: %s %s", (_worldSession ? _worldSession->GetPlayerInfo() : GetRemoteIpAddress().to_string()).c_str(), opcodeName.c_str());
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
case CMSG_PING:
|
||||
HandlePing(packet);
|
||||
break;
|
||||
case CMSG_AUTH_SESSION:
|
||||
if (_worldSession)
|
||||
{
|
||||
TC_LOG_ERROR("network", "WorldSocket::ProcessIncoming: received duplicate CMSG_AUTH_SESSION from %s", _worldSession->GetPlayerInfo().c_str());
|
||||
switch (opcode)
|
||||
{
|
||||
case CMSG_PING:
|
||||
HandlePing(packet);
|
||||
break;
|
||||
}
|
||||
case CMSG_AUTH_SESSION:
|
||||
if (_worldSession)
|
||||
{
|
||||
TC_LOG_ERROR("network", "WorldSocket::ProcessIncoming: received duplicate CMSG_AUTH_SESSION from %s", _worldSession->GetPlayerInfo().c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
HandleAuthSession(packet);
|
||||
break;
|
||||
case CMSG_KEEP_ALIVE:
|
||||
TC_LOG_DEBUG("network", "%s", opcodeName.c_str());
|
||||
sScriptMgr->OnPacketReceive(_worldSession, packet);
|
||||
break;
|
||||
case CMSG_LOG_DISCONNECT:
|
||||
packet.rfinish(); // contains uint32 disconnectReason;
|
||||
TC_LOG_DEBUG("network", "%s", opcodeName.c_str());
|
||||
sScriptMgr->OnPacketReceive(_worldSession, packet);
|
||||
return;
|
||||
// not an opcode, client sends string "WORLD OF WARCRAFT CONNECTION - CLIENT TO SERVER" without opcode
|
||||
// first 4 bytes become the opcode (2 dropped)
|
||||
case MSG_VERIFY_CONNECTIVITY:
|
||||
{
|
||||
TC_LOG_DEBUG("network", "%s", opcodeName.c_str());
|
||||
sScriptMgr->OnPacketReceive(_worldSession, packet);
|
||||
std::string str;
|
||||
packet >> str;
|
||||
if (str != "D OF WARCRAFT CONNECTION - CLIENT TO SERVER")
|
||||
{
|
||||
CloseSocket();
|
||||
HandleAuthSession(packet);
|
||||
break;
|
||||
}
|
||||
|
||||
HandleSendAuthSession();
|
||||
break;
|
||||
}
|
||||
case CMSG_ENABLE_NAGLE:
|
||||
{
|
||||
TC_LOG_DEBUG("network", "%s", opcodeName.c_str());
|
||||
sScriptMgr->OnPacketReceive(_worldSession, packet);
|
||||
if (_worldSession)
|
||||
_worldSession->HandleEnableNagleAlgorithm();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (!_worldSession)
|
||||
{
|
||||
TC_LOG_ERROR("network.opcode", "ProcessIncoming: Client not authed opcode = %u", uint32(opcode));
|
||||
CloseSocket();
|
||||
case CMSG_KEEP_ALIVE:
|
||||
TC_LOG_DEBUG("network", "%s", opcodeName.c_str());
|
||||
sScriptMgr->OnPacketReceive(_worldSession, packet);
|
||||
break;
|
||||
case CMSG_LOG_DISCONNECT:
|
||||
packet.rfinish(); // contains uint32 disconnectReason;
|
||||
TC_LOG_DEBUG("network", "%s", opcodeName.c_str());
|
||||
sScriptMgr->OnPacketReceive(_worldSession, packet);
|
||||
return;
|
||||
case CMSG_ENABLE_NAGLE:
|
||||
{
|
||||
TC_LOG_DEBUG("network", "%s", opcodeName.c_str());
|
||||
sScriptMgr->OnPacketReceive(_worldSession, packet);
|
||||
if (_worldSession)
|
||||
_worldSession->HandleEnableNagleAlgorithm();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (!_worldSession)
|
||||
{
|
||||
TC_LOG_ERROR("network.opcode", "ProcessIncoming: Client not authed opcode = %u", uint32(opcode));
|
||||
CloseSocket();
|
||||
return;
|
||||
}
|
||||
|
||||
// Our Idle timer will reset on any non PING opcodes.
|
||||
// Catches people idling on the login screen and any lingering ingame connections.
|
||||
_worldSession->ResetTimeOutTime();
|
||||
// Our Idle timer will reset on any non PING opcodes.
|
||||
// Catches people idling on the login screen and any lingering ingame connections.
|
||||
_worldSession->ResetTimeOutTime();
|
||||
|
||||
// Copy the packet to the heap before enqueuing
|
||||
_worldSession->QueuePacket(new WorldPacket(std::move(packet)));
|
||||
break;
|
||||
// Copy the packet to the heap before enqueuing
|
||||
_worldSession->QueuePacket(new WorldPacket(std::move(packet)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ClientPktHeader* header = reinterpret_cast<ClientPktHeader*>(GetDataBuffer());
|
||||
|
||||
std::string initializer(reinterpret_cast<char const*>(header) + sizeof(header->size));
|
||||
if (initializer != ClientConnectionInitialize)
|
||||
{
|
||||
CloseSocket();
|
||||
return;
|
||||
}
|
||||
|
||||
_initialized = true;
|
||||
HandleSendAuthSession();
|
||||
}
|
||||
|
||||
AsyncReadHeader();
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ struct ClientPktHeader
|
||||
uint16 size;
|
||||
uint32 cmd;
|
||||
|
||||
bool IsValid() const { return size >= 4 && size < 10240 && (cmd < NUM_OPCODE_HANDLERS || (cmd >> 16) == 0x4C52); }
|
||||
bool IsValid() const { return size >= 4 && size < 10240 && cmd < NUM_OPCODE_HANDLERS; }
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
@@ -60,11 +60,18 @@ struct WorldPacketBuffer
|
||||
|
||||
typedef boost::asio::const_buffer const* const_iterator;
|
||||
|
||||
WorldPacketBuffer(ServerPktHeader header, WorldPacket const& packet) : _header(header), _packet(packet)
|
||||
WorldPacketBuffer(ServerPktHeader header, WorldPacket const& packet) : _header(header), _packet(packet), _bufferCount(0)
|
||||
{
|
||||
_buffers[0] = boost::asio::const_buffer(_header.header, _header.getHeaderLength());
|
||||
_buffers[_bufferCount++] = boost::asio::const_buffer(_header.header, _header.getHeaderLength());
|
||||
if (!_packet.empty())
|
||||
_buffers[1] = boost::asio::const_buffer(_packet.contents(), _packet.size());
|
||||
_buffers[_bufferCount++] = boost::asio::const_buffer(_packet.contents(), _packet.size());
|
||||
}
|
||||
|
||||
WorldPacketBuffer(std::string const& str) : _header(str.length() + 1 /*null terminator*/, 0), _packet(), _bufferCount(0)
|
||||
{
|
||||
_buffers[_bufferCount++] = boost::asio::const_buffer(_header.header, _header.getHeaderLength() - 2 /*sizeof(opcode)*/);
|
||||
if (!str.empty())
|
||||
_buffers[_bufferCount++] = boost::asio::const_buffer(str.c_str(), _header.size);
|
||||
}
|
||||
|
||||
const_iterator begin() const
|
||||
@@ -74,13 +81,14 @@ struct WorldPacketBuffer
|
||||
|
||||
const_iterator end() const
|
||||
{
|
||||
return _buffers + (_packet.empty() ? 1 : 2);
|
||||
return _buffers + _bufferCount;
|
||||
}
|
||||
|
||||
private:
|
||||
boost::asio::const_buffer _buffers[2];
|
||||
ServerPktHeader _header;
|
||||
WorldPacket _packet;
|
||||
uint32 _bufferCount;
|
||||
};
|
||||
|
||||
namespace boost
|
||||
@@ -98,6 +106,10 @@ class WorldSocket : public Socket<WorldSocket, WorldPacketBuffer>
|
||||
{
|
||||
typedef Socket<WorldSocket, WorldPacketBuffer> Base;
|
||||
|
||||
static std::string const ServerConnectionInitialize;
|
||||
|
||||
static std::string const ClientConnectionInitialize;
|
||||
|
||||
public:
|
||||
WorldSocket(tcp::socket&& socket);
|
||||
|
||||
@@ -129,6 +141,7 @@ private:
|
||||
uint32 _OverSpeedPings;
|
||||
|
||||
WorldSession* _worldSession;
|
||||
bool _initialized;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user