Skip to content

Commit

Permalink
Merge branch 'master' into fix-server-name-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando-A-Rocha authored Oct 17, 2024
2 parents ad0c852 + 84437e4 commit 49bfec0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#include "version.h"
#include "net/SimHeaders.h"
#include <signal.h>
#include <regex>

#define MAX_BULLETSYNC_DISTANCE 400.0f
#define MAX_EXPLOSION_SYNC_DISTANCE 400.0f
Expand Down Expand Up @@ -1783,7 +1784,21 @@ void CGame::Packet_PlayerJoinData(CPlayerJoinDataPacket& Packet)

SString strIP = pPlayer->GetSourceIP();
SString strIPAndSerial("IP: %s Serial: %s Version: %s", strIP.c_str(), strSerial.c_str(), strPlayerVersion.c_str());
if (!CheckNickProvided(szNick)) // check the nick is valid

// Prevent player from connecting if serial is invalid
const std::regex serialRegex("^[A-F0-9]{32}$");
if (!std::regex_match(strSerial, serialRegex))
{
// Tell the console
CLogger::LogPrintf("CONNECT: %s failed to connect (Invalid serial) (%s)\n", szNick, strIPAndSerial.c_str());

// Tell the player the problem
DisconnectPlayer(this, *pPlayer, CPlayerDisconnectedPacket::SERIAL_VERIFICATION);
return;
}

// Check the nick is valid
if (!CheckNickProvided(szNick))
{
// Tell the console
CLogger::LogPrintf("CONNECT: %s failed to connect (Invalid nickname) (%s)\n", szNick, strIPAndSerial.c_str());
Expand Down

0 comments on commit 49bfec0

Please sign in to comment.