mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Ban system bug fix and improvements
* Format the ip as '[ip]:port' in all logging calls for consistency. * Fixed a bug causing the IP to be send up as full instead of base only to master server (should always be base only). * Temporarily uncommented the plugin callback logic.
This commit is contained in:
parent
98f09b25de
commit
6b23570beb
@ -98,15 +98,19 @@ CClient* CServer::ConnectClient(CServer* pServer, user_creds_s* pChallenge)
|
||||
pChallenge->netAdr.ToString(pszAddresBuffer, sizeof(pszAddresBuffer), true);
|
||||
|
||||
const bool bEnableLogging = sv_showconnecting->GetBool();
|
||||
const int nPort = int(ntohs(pChallenge->netAdr.GetPort()));
|
||||
|
||||
if (bEnableLogging)
|
||||
DevMsg(eDLL_T::SERVER, "Processing connectionless challenge for '%s' ('%llu')\n", pszAddresBuffer, nNucleusID);
|
||||
DevMsg(eDLL_T::SERVER, "Processing connectionless challenge for '[%s]:%i' ('%llu')\n",
|
||||
pszAddresBuffer, nPort, nNucleusID);
|
||||
|
||||
// Only proceed connection if the client's name is valid and UTF-8 encoded.
|
||||
if (!VALID_CHARSTAR(pszPersonaName) || !IsValidUTF8(pszPersonaName) || !IsValidPersonaName(pszPersonaName))
|
||||
{
|
||||
pServer->RejectConnection(pServer->m_Socket, &pChallenge->netAdr, "#Valve_Reject_Invalid_Name");
|
||||
if (bEnableLogging)
|
||||
Warning(eDLL_T::SERVER, "Connection rejected for '%s' ('%llu' has an invalid name!)\n", pszAddresBuffer, nNucleusID);
|
||||
Warning(eDLL_T::SERVER, "Connection rejected for '[%s]:%i' ('%llu' has an invalid name!)\n",
|
||||
pszAddresBuffer, nPort, nNucleusID);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -117,7 +121,8 @@ CClient* CServer::ConnectClient(CServer* pServer, user_creds_s* pChallenge)
|
||||
{
|
||||
pServer->RejectConnection(pServer->m_Socket, &pChallenge->netAdr, "#Valve_Reject_Banned");
|
||||
if (bEnableLogging)
|
||||
Warning(eDLL_T::SERVER, "Connection rejected for '%s' ('%llu' is banned from this server!)\n", pszAddresBuffer, nNucleusID);
|
||||
Warning(eDLL_T::SERVER, "Connection rejected for '[%s]:%i' ('%llu' is banned from this server!)\n",
|
||||
pszAddresBuffer, nPort, nNucleusID);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -125,15 +130,18 @@ CClient* CServer::ConnectClient(CServer* pServer, user_creds_s* pChallenge)
|
||||
|
||||
CClient* pClient = v_CServer_ConnectClient(pServer, pChallenge);
|
||||
|
||||
for (auto& callback : !g_pPluginSystem->GetConnectClientCallbacks())
|
||||
{
|
||||
if (!callback(pServer, pClient, pChallenge))
|
||||
return nullptr;
|
||||
}
|
||||
//for (auto& callback : !g_pPluginSystem->GetConnectClientCallbacks())
|
||||
//{
|
||||
// if (!callback(pServer, pClient, pChallenge))
|
||||
// {
|
||||
// pClient->Disconnect(REP_MARK_BAD, "#Valve_Reject_Banned");
|
||||
// return nullptr;
|
||||
// }
|
||||
//}
|
||||
|
||||
if (pClient && sv_globalBanlist->GetBool())
|
||||
{
|
||||
std::thread th(SV_IsClientBanned, pClient, string(pszAddresBuffer), nNucleusID, string(pszPersonaName));
|
||||
std::thread th(SV_IsClientBanned, pClient, string(pszAddresBuffer), nNucleusID, string(pszPersonaName), nPort);
|
||||
th.detach();
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,8 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: checks if particular client is banned on the comp server
|
||||
//-----------------------------------------------------------------------------
|
||||
void SV_IsClientBanned(CClient* pClient, const string& svIPAddr, const uint64_t nNucleusID, const string& svPersonaName)
|
||||
void SV_IsClientBanned(CClient* pClient, const string& svIPAddr,
|
||||
const uint64_t nNucleusID, const string& svPersonaName, const int nPort)
|
||||
{
|
||||
Assert(pClient != nullptr);
|
||||
|
||||
@ -29,7 +30,7 @@ void SV_IsClientBanned(CClient* pClient, const string& svIPAddr, const uint64_t
|
||||
{
|
||||
if (!ThreadInMainThread())
|
||||
{
|
||||
g_TaskScheduler->Dispatch([pClient, svError, svIPAddr, nNucleusID]
|
||||
g_TaskScheduler->Dispatch([pClient, svError, svIPAddr, nNucleusID, nPort]
|
||||
{
|
||||
// Make sure client isn't already disconnected,
|
||||
// and that if there is a valid netchannel, that
|
||||
@ -38,9 +39,11 @@ void SV_IsClientBanned(CClient* pClient, const string& svIPAddr, const uint64_t
|
||||
CNetChan* pChan = pClient->GetNetChan();
|
||||
if (pChan && pClient->GetNucleusID() == nNucleusID)
|
||||
{
|
||||
int nUserID = pClient->GetUserID();
|
||||
|
||||
pClient->Disconnect(Reputation_t::REP_MARK_BAD, svError.c_str());
|
||||
Warning(eDLL_T::SERVER, "Removed client '%s' ('%llu' is banned globally!)\n",
|
||||
svIPAddr.c_str(), nNucleusID);
|
||||
Warning(eDLL_T::SERVER, "Removed client '[%s]:%i' from slot #%i ('%llu' is banned globally!)\n",
|
||||
svIPAddr.c_str(), nPort, nUserID, nNucleusID);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
@ -86,7 +89,7 @@ void SV_CheckForBan(const BannedVec_t* pBannedVec /*= nullptr*/)
|
||||
if (!pClient->IsConnected())
|
||||
continue;
|
||||
|
||||
const char* szIPAddr = pNetChan->GetAddress();
|
||||
const char* szIPAddr = pNetChan->GetAddress(true);
|
||||
const uint64_t nNucleusID = pClient->GetNucleusID();
|
||||
|
||||
if (!pBannedVec)
|
||||
@ -97,9 +100,12 @@ void SV_CheckForBan(const BannedVec_t* pBannedVec /*= nullptr*/)
|
||||
{
|
||||
if (it.second == pClient->GetNucleusID())
|
||||
{
|
||||
const int nUserID = pClient->GetUserID();
|
||||
const int nPort = pNetChan->GetPort();
|
||||
|
||||
pClient->Disconnect(Reputation_t::REP_MARK_BAD, "%s", it.first.c_str());
|
||||
Warning(eDLL_T::SERVER, "Removed client '%s' from slot '%i' ('%llu' is banned globally!)\n",
|
||||
szIPAddr, c, nNucleusID);
|
||||
Warning(eDLL_T::SERVER, "Removed client '[%s]:%i' from slot #%i ('%llu' is banned globally!)\n",
|
||||
szIPAddr, nPort, nUserID, nNucleusID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ inline bool* s_bIsDedicated = nullptr;
|
||||
void SV_InitGameDLL();
|
||||
void SV_ShutdownGameDLL();
|
||||
bool SV_ActivateServer();
|
||||
void SV_IsClientBanned(CClient* pClient, const string& svIPAddr, const uint64_t nNucleusID, const string& svPersonaName);
|
||||
void SV_IsClientBanned(CClient* pClient, const string& svIPAddr, const uint64_t nNucleusID, const string& svPersonaName, const int nPort);
|
||||
void SV_CheckForBan(const BannedVec_t* pBannedVec = nullptr);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user