mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fixed ban adding in mastersrv (check for existing ban)
This commit is contained in:
parent
05d274444a
commit
3eb1c64428
|
@ -254,43 +254,6 @@ void PurgeServers()
|
|||
}
|
||||
}
|
||||
|
||||
void ConAddBan(IConsole::IResult *pResult, void *pUser)
|
||||
{
|
||||
int i;
|
||||
if(m_NumBans == MAX_BANS)
|
||||
{
|
||||
dbg_msg("mastersrv", "error: banlist is full");
|
||||
return;
|
||||
}
|
||||
|
||||
net_addr_from_str(&m_aBans[m_NumBans].m_Address, pResult->GetString(0));
|
||||
|
||||
for(i = 0; i < m_NumBans; i++)
|
||||
{
|
||||
if(net_addr_comp(&m_aBans[i].m_Address, &m_aBans[m_NumBans].m_Address) == 0)
|
||||
{
|
||||
dbg_msg("mastersrv", "duplicate ban: %d.%d.%d.%d:%d",
|
||||
m_aBans[m_NumBans].m_Address.ip[0], m_aBans[m_NumBans].m_Address.ip[1],
|
||||
m_aBans[m_NumBans].m_Address.ip[2], m_aBans[m_NumBans].m_Address.ip[3],
|
||||
m_aBans[m_NumBans].m_Address.port);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dbg_msg("mastersrv", "ban added: %d.%d.%d.%d:%d",
|
||||
m_aBans[m_NumBans].m_Address.ip[0], m_aBans[m_NumBans].m_Address.ip[1],
|
||||
m_aBans[m_NumBans].m_Address.ip[2], m_aBans[m_NumBans].m_Address.ip[3],
|
||||
m_aBans[m_NumBans].m_Address.port);
|
||||
m_NumBans++;
|
||||
}
|
||||
|
||||
void ReloadBans()
|
||||
{
|
||||
m_NumBans = 0;
|
||||
m_pConsole->ExecuteFile("master.cfg");
|
||||
}
|
||||
|
||||
bool CheckBan(NETADDR Addr)
|
||||
{
|
||||
for(int i = 0; i < m_NumBans; i++)
|
||||
|
@ -311,6 +274,38 @@ bool CheckBan(NETADDR Addr)
|
|||
return false;
|
||||
}
|
||||
|
||||
void ConAddBan(IConsole::IResult *pResult, void *pUser)
|
||||
{
|
||||
if(m_NumBans == MAX_BANS)
|
||||
{
|
||||
dbg_msg("mastersrv", "error: banlist is full");
|
||||
return;
|
||||
}
|
||||
|
||||
net_addr_from_str(&m_aBans[m_NumBans].m_Address, pResult->GetString(0));
|
||||
|
||||
if(CheckBan(m_aBans[m_NumBans].m_Address))
|
||||
{
|
||||
dbg_msg("mastersrv", "duplicate ban: %d.%d.%d.%d:%d",
|
||||
m_aBans[m_NumBans].m_Address.ip[0], m_aBans[m_NumBans].m_Address.ip[1],
|
||||
m_aBans[m_NumBans].m_Address.ip[2], m_aBans[m_NumBans].m_Address.ip[3],
|
||||
m_aBans[m_NumBans].m_Address.port);
|
||||
return;
|
||||
}
|
||||
|
||||
dbg_msg("mastersrv", "ban added: %d.%d.%d.%d:%d",
|
||||
m_aBans[m_NumBans].m_Address.ip[0], m_aBans[m_NumBans].m_Address.ip[1],
|
||||
m_aBans[m_NumBans].m_Address.ip[2], m_aBans[m_NumBans].m_Address.ip[3],
|
||||
m_aBans[m_NumBans].m_Address.port);
|
||||
m_NumBans++;
|
||||
}
|
||||
|
||||
void ReloadBans()
|
||||
{
|
||||
m_NumBans = 0;
|
||||
m_pConsole->ExecuteFile("master.cfg");
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv) // ignore_convention
|
||||
{
|
||||
int64 LastBuild = 0, LastBanReload = 0;
|
||||
|
|
Loading…
Reference in a new issue