mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Fix: Rcon spoofing protection bans clients after password change
This commit is contained in:
parent
6badc5a715
commit
45823466ec
|
@ -1906,6 +1906,68 @@ void CServer::ConchainConsoleOutputLevelUpdate(IConsole::IResult *pResult, void
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CServer::ConchainRconPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
||||||
|
{
|
||||||
|
pfnCallback(pResult, pCallbackUserData);
|
||||||
|
if(pResult->NumArguments() == 1)
|
||||||
|
{
|
||||||
|
CServer *pServer = (CServer *)pUserData;
|
||||||
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||||
|
{
|
||||||
|
if(pServer->m_aClients[i].m_State == CServer::CClient::STATE_EMPTY)
|
||||||
|
continue;
|
||||||
|
if(pServer->m_aClients[i].m_Authed == AUTHED_ADMIN)
|
||||||
|
{
|
||||||
|
CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS);
|
||||||
|
Msg.AddInt(0); //authed
|
||||||
|
Msg.AddInt(0); //cmdlist
|
||||||
|
pServer->SendMsgEx(&Msg, MSGFLAG_VITAL, i, true);
|
||||||
|
|
||||||
|
pServer->m_aClients[i].m_Authed = AUTHED_NO;
|
||||||
|
pServer->m_aClients[i].m_LastAuthed = AUTHED_NO;
|
||||||
|
pServer->m_aClients[i].m_AuthTries = 0;
|
||||||
|
pServer->m_aClients[i].m_pRconCmdToSend = 0;
|
||||||
|
|
||||||
|
pServer->SendRconLine(i, "Logged out by password change.");
|
||||||
|
char aBuf[64];
|
||||||
|
str_format(aBuf, sizeof(aBuf), "ClientID=%d logged out by password change", i);
|
||||||
|
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CServer::ConchainRconModPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
||||||
|
{
|
||||||
|
pfnCallback(pResult, pCallbackUserData);
|
||||||
|
if(pResult->NumArguments() == 1)
|
||||||
|
{
|
||||||
|
CServer *pServer = (CServer *)pUserData;
|
||||||
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||||
|
{
|
||||||
|
if(pServer->m_aClients[i].m_State == CServer::CClient::STATE_EMPTY)
|
||||||
|
continue;
|
||||||
|
if(pServer->m_aClients[i].m_Authed == AUTHED_MOD)
|
||||||
|
{
|
||||||
|
CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS);
|
||||||
|
Msg.AddInt(0); //authed
|
||||||
|
Msg.AddInt(0); //cmdlist
|
||||||
|
pServer->SendMsgEx(&Msg, MSGFLAG_VITAL, i, true);
|
||||||
|
|
||||||
|
pServer->m_aClients[i].m_Authed = AUTHED_NO;
|
||||||
|
pServer->m_aClients[i].m_LastAuthed = AUTHED_NO;
|
||||||
|
pServer->m_aClients[i].m_AuthTries = 0;
|
||||||
|
pServer->m_aClients[i].m_pRconCmdToSend = 0;
|
||||||
|
|
||||||
|
pServer->SendRconLine(i, "Logged out by password change.");
|
||||||
|
char aBuf[64];
|
||||||
|
str_format(aBuf, sizeof(aBuf), "ClientID=%d logged out by password change", i);
|
||||||
|
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CServer::RegisterCommands()
|
void CServer::RegisterCommands()
|
||||||
{
|
{
|
||||||
m_pConsole = Kernel()->RequestInterface<IConsole>();
|
m_pConsole = Kernel()->RequestInterface<IConsole>();
|
||||||
|
@ -1931,6 +1993,9 @@ void CServer::RegisterCommands()
|
||||||
Console()->Chain("mod_command", ConchainModCommandUpdate, this);
|
Console()->Chain("mod_command", ConchainModCommandUpdate, this);
|
||||||
Console()->Chain("console_output_level", ConchainConsoleOutputLevelUpdate, this);
|
Console()->Chain("console_output_level", ConchainConsoleOutputLevelUpdate, this);
|
||||||
|
|
||||||
|
Console()->Chain("sv_rcon_password", ConchainRconPasswordChange, this);
|
||||||
|
Console()->Chain("sv_rcon_mod_password", ConchainRconModPasswordChange, this);
|
||||||
|
|
||||||
// register console commands in sub parts
|
// register console commands in sub parts
|
||||||
m_ServerBan.InitServerBan(Console(), Storage(), this);
|
m_ServerBan.InitServerBan(Console(), Storage(), this);
|
||||||
m_pGameServer->OnConsoleInit();
|
m_pGameServer->OnConsoleInit();
|
||||||
|
|
|
@ -258,6 +258,8 @@ public:
|
||||||
static void ConchainMaxclientsperipUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
static void ConchainMaxclientsperipUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||||
static void ConchainModCommandUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
static void ConchainModCommandUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||||
static void ConchainConsoleOutputLevelUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
static void ConchainConsoleOutputLevelUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||||
|
static void ConchainRconPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||||
|
static void ConchainRconModPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||||
|
|
||||||
void RegisterCommands();
|
void RegisterCommands();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue