mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 18:18:18 +00:00
commit
0b01d1c1fe
|
@ -1444,7 +1444,7 @@ void CServer::ConBan(IConsole::IResult *pResult, void *pUser)
|
||||||
const char *pReason = "No reason given";
|
const char *pReason = "No reason given";
|
||||||
|
|
||||||
if(pResult->NumArguments() > 1)
|
if(pResult->NumArguments() > 1)
|
||||||
Minutes = max(0, pResult->GetInteger(1));
|
Minutes = min(max(0, pResult->GetInteger(1)), 1000000); // todo: fix this in year 2035
|
||||||
|
|
||||||
if(pResult->NumArguments() > 2)
|
if(pResult->NumArguments() > 2)
|
||||||
pReason = pResult->GetString(2);
|
pReason = pResult->GetString(2);
|
||||||
|
|
|
@ -174,15 +174,11 @@ int CNetServer::BanAdd(NETADDR Addr, int Seconds, const char *pReason)
|
||||||
if(Seconds)
|
if(Seconds)
|
||||||
Stamp = time_timestamp() + Seconds;
|
Stamp = time_timestamp() + Seconds;
|
||||||
|
|
||||||
// search to see if it already exists
|
// search to remove it if it already exists
|
||||||
pBan = m_aBans[IpHash];
|
pBan = m_aBans[IpHash];
|
||||||
MACRO_LIST_FIND(pBan, m_pHashNext, net_addr_comp(&pBan->m_Info.m_Addr, &Addr) == 0);
|
MACRO_LIST_FIND(pBan, m_pHashNext, net_addr_comp(&pBan->m_Info.m_Addr, &Addr) == 0);
|
||||||
if(pBan)
|
if(pBan)
|
||||||
{
|
BanRemoveByObject(pBan);
|
||||||
// adjust the ban
|
|
||||||
pBan->m_Info.m_Expires = Stamp;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!m_BanPool_FirstFree)
|
if(!m_BanPool_FirstFree)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -206,15 +202,20 @@ int CNetServer::BanAdd(NETADDR Addr, int Seconds, const char *pReason)
|
||||||
CBan *pInsertAfter = m_BanPool_FirstUsed;
|
CBan *pInsertAfter = m_BanPool_FirstUsed;
|
||||||
MACRO_LIST_FIND(pInsertAfter, m_pNext, Stamp < pInsertAfter->m_Info.m_Expires);
|
MACRO_LIST_FIND(pInsertAfter, m_pNext, Stamp < pInsertAfter->m_Info.m_Expires);
|
||||||
|
|
||||||
if(pInsertAfter)
|
if(pInsertAfter && Stamp != -1)
|
||||||
pInsertAfter = pInsertAfter->m_pPrev;
|
pInsertAfter = pInsertAfter->m_pPrev;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// add to last
|
// add to last
|
||||||
|
if (m_BanPool_FirstUsed->m_Info.m_Expires == -1)
|
||||||
|
pInsertAfter = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
pInsertAfter = m_BanPool_FirstUsed;
|
pInsertAfter = m_BanPool_FirstUsed;
|
||||||
while(pInsertAfter->m_pNext)
|
while(pInsertAfter->m_pNext && pInsertAfter->m_pNext->m_Info.m_Expires != -1)
|
||||||
pInsertAfter = pInsertAfter->m_pNext;
|
pInsertAfter = pInsertAfter->m_pNext;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(pInsertAfter)
|
if(pInsertAfter)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue