[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()) if (!player->isHandshaked())
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Have not completed handshake with player %d", player->getId()); 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; return;
} }
@ -126,6 +127,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
if (!result) 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)->setPlayer(player.get());
playerPacketController->GetPacket(ID_USER_DISCONNECTED)->Send(false); playerPacketController->GetPacket(ID_USER_DISCONNECTED)->Send(false);
Players::deletePlayerByGUID(packet->guid); Players::deletePlayerByGUID(packet->guid);

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

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

Loading…
Cancel
Save