mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Reject packets sent before a connection has been fully established
This commit is contained in:
parent
129d1c2fe3
commit
998b12617e
@ -19,6 +19,17 @@ CNLoginServer::CNLoginServer(uint16_t p) {
|
|||||||
void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||||
printPacket(data);
|
printPacket(data);
|
||||||
|
|
||||||
|
if (loginSessions.find(sock) == loginSessions.end() &&
|
||||||
|
data->type != P_CL2LS_REQ_LOGIN && data->type != P_CL2LS_REP_LIVE_CHECK) {
|
||||||
|
|
||||||
|
if (settings::VERBOSITY > 0) {
|
||||||
|
std::cerr << "OpenFusion: LOGIN PKT OUT-OF-SEQ. PacketType: " <<
|
||||||
|
Packets::p2str(data->type) << " (" << data->type << ")" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (data->type) {
|
switch (data->type) {
|
||||||
case P_CL2LS_REQ_LOGIN: {
|
case P_CL2LS_REQ_LOGIN: {
|
||||||
login(sock, data);
|
login(sock, data);
|
||||||
|
@ -29,11 +29,31 @@ CNShardServer::CNShardServer(uint16_t p) {
|
|||||||
void CNShardServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
void CNShardServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||||
printPacket(data);
|
printPacket(data);
|
||||||
|
|
||||||
if (ShardPackets.find(data->type) != ShardPackets.end())
|
// if it's a valid packet
|
||||||
ShardPackets[data->type](sock, data);
|
if (ShardPackets.find(data->type) != ShardPackets.end()) {
|
||||||
else if (settings::VERBOSITY > 0)
|
|
||||||
std::cerr << "OpenFusion: SHARD UNIMPLM ERR. PacketType: " << Packets::p2str(data->type) << " (" << data->type << ")" << std::endl;
|
|
||||||
|
|
||||||
|
// reject gameplay packets if not yet fully connected
|
||||||
|
if (PlayerManager::players.find(sock) == PlayerManager::players.end()
|
||||||
|
&& data->type != P_CL2FE_REQ_PC_ENTER && data->type != P_CL2FE_REP_LIVE_CHECK) {
|
||||||
|
|
||||||
|
if (settings::VERBOSITY > 0) {
|
||||||
|
std::cerr << "OpenFusion: SHARD PKT OUT-OF-SEQ. PacketType: " <<
|
||||||
|
Packets::p2str(data->type) << " (" << data->type << ")" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// run the appropriate packet handler
|
||||||
|
ShardPackets[data->type](sock, data);
|
||||||
|
} else if (settings::VERBOSITY > 0) {
|
||||||
|
std::cerr << "OpenFusion: SHARD UNIMPLM ERR. PacketType: " << Packets::p2str(data->type) << " (" << data->type << ")" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We must re-check if the player is still connected in case
|
||||||
|
* they were dropped when handling the packet.
|
||||||
|
*/
|
||||||
if (PlayerManager::players.find(sock) != PlayerManager::players.end())
|
if (PlayerManager::players.find(sock) != PlayerManager::players.end())
|
||||||
PlayerManager::players[sock]->lastHeartbeat = getTime();
|
PlayerManager::players[sock]->lastHeartbeat = getTime();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user