mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-18 22:19:54 -04:00
Core/NetworkIO: Removed MSG_VERIFY_CONNECTIVITY as an opcode
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user