mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
prevent self kick/ban in the console. Closes #50
and fixed line endings
This commit is contained in:
parent
5437513a0d
commit
0c1261620f
|
@ -181,6 +181,8 @@ CServer::CServer() : m_DemoRecorder(&m_SnapshotDelta)
|
|||
|
||||
m_MapReload = 0;
|
||||
|
||||
m_RconClientId = -1;
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
|
@ -259,9 +261,14 @@ void CServer::SetBrowseInfo(const char *pGameType, int Progression)
|
|||
void CServer::Kick(int ClientID, const char *pReason)
|
||||
{
|
||||
if(ClientID < 0 || ClientID >= MAX_CLIENTS || m_aClients[ClientID].m_State == CClient::STATE_EMPTY)
|
||||
{
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "invalid client id to kick");
|
||||
return;
|
||||
{
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "invalid client id to kick");
|
||||
return;
|
||||
}
|
||||
else if(m_RconClientId == ClientID)
|
||||
{
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "you can't kick yourself");
|
||||
return;
|
||||
}
|
||||
|
||||
m_NetServer.Drop(ClientID, pReason);
|
||||
|
@ -770,7 +777,9 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
|||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "ClientId=%d rcon='%s'", ClientId, pCmd);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
|
||||
m_RconClientId = ClientId;
|
||||
Console()->ExecuteLine(pCmd);
|
||||
m_RconClientId = -1;
|
||||
}
|
||||
}
|
||||
else if(Msg == NETMSG_RCON_AUTH)
|
||||
|
@ -1228,7 +1237,19 @@ void CServer::ConBan(IConsole::IResult *pResult, void *pUser)
|
|||
Minutes = pResult->GetInteger(1);
|
||||
|
||||
if(net_addr_from_str(&Addr, pStr) == 0)
|
||||
{
|
||||
if(pServer->m_RconClientId >= 0 && pServer->m_RconClientId < MAX_CLIENTS && pServer->m_aClients[pServer->m_RconClientId].m_State != CClient::STATE_EMPTY)
|
||||
{
|
||||
NETADDR AddrCheck = pServer->m_NetServer.ClientAddr(pServer->m_RconClientId);
|
||||
Addr.port = AddrCheck.port = 0;
|
||||
if(net_addr_comp(&Addr, &AddrCheck) == 0)
|
||||
{
|
||||
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "you can't ban yourself");
|
||||
return;
|
||||
}
|
||||
}
|
||||
pServer->BanAdd(Addr, Minutes*60);
|
||||
}
|
||||
else if(StrAllnum(pStr))
|
||||
{
|
||||
int ClientId = str_toint(pStr);
|
||||
|
@ -1238,14 +1259,19 @@ void CServer::ConBan(IConsole::IResult *pResult, void *pUser)
|
|||
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "invalid client id");
|
||||
return;
|
||||
}
|
||||
else if(pServer->m_RconClientId == ClientId)
|
||||
{
|
||||
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "you can't ban yourself");
|
||||
return;
|
||||
}
|
||||
|
||||
Addr = pServer->m_NetServer.ClientAddr(ClientId);
|
||||
pServer->BanAdd(Addr, Minutes*60);
|
||||
}
|
||||
else
|
||||
{
|
||||
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "invalid network address to ban");
|
||||
return;
|
||||
else
|
||||
{
|
||||
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "invalid network address to ban");
|
||||
return;
|
||||
}
|
||||
|
||||
Addr.port = 0;
|
||||
|
|
|
@ -106,6 +106,7 @@ public:
|
|||
//int m_CurrentGameTick;
|
||||
int m_RunServer;
|
||||
int m_MapReload;
|
||||
int m_RconClientId;
|
||||
|
||||
char m_aBrowseinfoGametype[16];
|
||||
int m_BrowseinfoProgression;
|
||||
|
|
Loading…
Reference in a new issue