[Server] Limit handshake attempts

new-script-api
Koncord 7 years ago
parent 729f6e745e
commit 4ebfcc4a21

@ -114,7 +114,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
if (!player->isHandshaked())
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Have not completed handshake with player %d", player->getId());
//KickPlayer(player->guid);
if(player->handshakeAttempts() > 5)
kickPlayer(player->guid);
return;
}
@ -126,6 +127,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
if (!result)
{
LOG_MESSAGE(Log::LOG_TRACE, "Player \"%s\" Disconnected by ON_PLAYER_CONNECT event", player->getName().c_str());
playerPacketController->GetPacket(ID_USER_DISCONNECTED)->setPlayer(player.get());
playerPacketController->GetPacket(ID_USER_DISCONNECTED)->Send(false);
Players::deletePlayerByGUID(packet->guid);

@ -94,7 +94,7 @@ Player::Player(RakNet::RakNetGUID guid) : BasePlayer(guid), NetActor(), changedM
basePlayer = this;
netCreature = this;
printf("Player::Player()\n");
handshakeState = false;
handshakeCounter = 0;
loadState = NOTLOADED;
resetUpdateFlags();
cell.blank();
@ -226,12 +226,17 @@ void Player::setId(unsigned short id)
bool Player::isHandshaked()
{
return handshakeState;
return handshakeCounter == numeric_limits<int>::max();
}
void Player::setHandshake()
{
handshakeState = true;
handshakeCounter = numeric_limits<int>::max();
}
int Player::handshakeAttempts()
{
return handshakeCounter++;
}
int Player::getLoadState()

@ -57,10 +57,11 @@ public:
void setId(unsigned short id);
bool isHandshaked();
int handshakeAttempts();
void setHandshake();
int getLoadState();
void setLoadState(int state);
int getLoadState();
virtual ~Player();
@ -180,7 +181,7 @@ public:
private:
CellController::TContainer cells;
bool handshakeState;
int handshakeCounter;
int loadState;
bool /*statsChanged, attributesChanged, skillsChanged, baseInfoChanged, positionChanged,*/ changedMap;
CharClass cClass;

Loading…
Cancel
Save