[Server] Forcibly kick players after too many handshake attempts

This commit is contained in:
David Cernat 2018-04-17 16:36:48 +03:00
parent 17678ee60f
commit 2bb7a4253e
2 changed files with 8 additions and 5 deletions

View file

@ -121,8 +121,11 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Attempts so far: %i", player->getHandshakeAttempts()); LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Attempts so far: %i", player->getHandshakeAttempts());
if (player->getHandshakeAttempts() > 5) if (player->getHandshakeAttempts() > 20)
kickPlayer(player->guid); kickPlayer(player->guid, false);
else if (player->getHandshakeAttempts() > 5)
kickPlayer(player->guid, true);
return; return;
} }
@ -499,9 +502,9 @@ int Networking::mainLoop()
return exitCode; return exitCode;
} }
void Networking::kickPlayer(RakNet::RakNetGUID guid) void Networking::kickPlayer(RakNet::RakNetGUID guid, bool sendNotification)
{ {
peer->CloseConnection(guid, true); peer->CloseConnection(guid, sendNotification);
} }
void Networking::banAddress(const char *ipAddress) void Networking::banAddress(const char *ipAddress)

View file

@ -22,7 +22,7 @@ namespace mwmp
void newPlayer(RakNet::RakNetGUID guid); void newPlayer(RakNet::RakNetGUID guid);
void disconnectPlayer(RakNet::RakNetGUID guid); void disconnectPlayer(RakNet::RakNetGUID guid);
void kickPlayer(RakNet::RakNetGUID guid); void kickPlayer(RakNet::RakNetGUID guid, bool sendNotification = true);
void banAddress(const char *ipAddress); void banAddress(const char *ipAddress);
void unbanAddress(const char *ipAddress); void unbanAddress(const char *ipAddress);