remove other banmaster related code

This commit is contained in:
Ravomavain 2012-05-02 00:56:14 +02:00 committed by GreYFoX
parent f98734e86e
commit 52ba9eea04
4 changed files with 0 additions and 163 deletions

View file

@ -32,9 +32,6 @@
#include <vector>
#include <engine/shared/linereader.h>
// banmaster
#include <banmaster/banmaster.h>
#include "register.h"
#include "server.h"
@ -44,8 +41,6 @@
#include <windows.h>
#endif
static const char SERVER_BANMASTERFILE[] = "banmasters.cfg";
static const char *StrUTF8Ltrim(const char *pStr)
{
while(*pStr)
@ -1207,38 +1202,6 @@ void CServer::PumpNetwork()
{
SendServerInfo(&Packet.m_Address, ((unsigned char *)Packet.m_pData)[sizeof(SERVERBROWSE_GETINFO)]);
}
/*if(Packet.m_DataSize >= sizeof(BANMASTER_IPOK) &&
mem_comp(Packet.m_pData, BANMASTER_IPOK, sizeof(BANMASTER_IPOK)) == 0 &&
m_NetServer.BanmasterCheck(&Packet.m_Address) != -1)
{
}*/
if((unsigned)Packet.m_DataSize >= sizeof(BANMASTER_IPBAN) &&
mem_comp(Packet.m_pData, BANMASTER_IPBAN, sizeof(BANMASTER_IPBAN)) == 0)
{
if(!g_Config.m_SvGlobalBantime)
return;
if(m_NetServer.BanmasterCheck(&Packet.m_Address) == -1)
return;
CUnpacker Up;
char aIp[NETADDR_MAXSTRSIZE];
char aReason[256];
NETADDR Addr;
Up.Reset((unsigned char*)Packet.m_pData + sizeof(BANMASTER_IPBAN), Packet.m_DataSize - sizeof(BANMASTER_IPBAN));
str_copy(aIp, Up.GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES), sizeof(aIp));
str_copy(aReason, Up.GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES), sizeof(aReason));
if(net_addr_from_str(&Addr, aIp))
{
dbg_msg("globalbans", "dropped weird message from banmaster");
return;
}
// TODO(heinrich5991): fix banmaster global ban addition
//m_NetServer.BanAdd(Addr, g_Config.m_SvGlobalBantime * 60, aReason);
dbg_msg("globalbans", "added ban, ip=%s, reason='%s'", aIp, aReason);
}
}
}
else
@ -1359,8 +1322,6 @@ int CServer::Run()
m_ServerBan.Init(Console(), Storage(), this);
m_Econ.Init(Console(), &m_ServerBan);
Console()->ExecuteFile(SERVER_BANMASTERFILE);
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "server name is '%s'", g_Config.m_SvName);
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
@ -1686,11 +1647,6 @@ void CServer::RegisterCommands()
Console()->Register("reload", "", CFGFLAG_SERVER, ConMapReload, this, "Reload the map");
// banmaster
Console()->Register("add_banmaster", "s", CFGFLAG_SERVER, ConAddBanmaster, this, "");
Console()->Register("banmasters", "", CFGFLAG_SERVER, ConBanmasters, this, "");
Console()->Register("clear_banmasters", "", CFGFLAG_SERVER, ConClearBanmasters, this, "");
Console()->Chain("sv_name", ConchainSpecialInfoupdate, this);
Console()->Chain("password", ConchainSpecialInfoupdate, this);
@ -1852,42 +1808,3 @@ char *CServer::GetAnnouncementLine(char const *pFileName)
return 0;
}
void CServer::ConAddBanmaster(IConsole::IResult *pResult, void *pUser)
{
CServer *pServer = (CServer *)pUser;
int Result = pServer->m_NetServer.BanmasterAdd(pResult->GetString(0));
if(Result == 0)
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server/banmaster", "succesfully added banmaster");
else if (Result == 1)
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server/banmaster", "invalid address for banmaster / net lookup failed");
else
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server/banmaster", "too many banmasters");
}
void CServer::ConBanmasters(IConsole::IResult *pResult, void *pUser)
{
CServer *pServer = (CServer *)pUser;
int NumBanmasters = pServer->m_NetServer.BanmasterNum();
char aBuf[128];
char aIpString[64];
for(int i = 0; i < NumBanmasters; i++)
{
NETADDR *pBanmaster = pServer->m_NetServer.BanmasterGet(i);
net_addr_str(pBanmaster, aIpString, sizeof(aIpString), false);
str_format(aBuf, sizeof(aBuf), "%d: %s", i, aIpString);
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server/banmaster", aBuf);
}
}
void CServer::ConClearBanmasters(IConsole::IResult *pResult, void *pUser)
{
CServer *pServer = (CServer *)pUser;
pServer->m_NetServer.BanmastersClear();
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server/banmaster", "cleared banmaster list");
}

View file

@ -255,10 +255,6 @@ public:
int m_aPrevStates[MAX_CLIENTS];
char *GetAnnouncementLine(char const *FileName);
unsigned m_AnnouncementLastLine;
static void ConAddBanmaster(IConsole::IResult *pResult, void *pUser);
static void ConBanmasters(IConsole::IResult *pResult, void *pUser);
static void ConClearBanmasters(IConsole::IResult *pResult, void *pUser);
};
#endif

View file

@ -284,21 +284,6 @@ public:
//
void SetMaxClientsPerIP(int Max);
// Banmaster
int BanmasterAdd(const char *pAddrStr);
int BanmasterNum() const;
NETADDR* BanmasterGet(int Index);
int BanmasterCheck(NETADDR *pAddr);
void BanmastersClear();
enum
{
MAX_BANMASTERS=16
};
private:
NETADDR m_aBanmasters[MAX_BANMASTERS];
int m_NumBanmasters;
};
class CNetConsole

View file

@ -8,8 +8,6 @@
#include "network.h"
#include <banmaster/banmaster.h>
bool CNetServer::Open(NETADDR BindAddr, CNetBan *pNetBan, int MaxClients, int MaxClientsPerIP, int Flags)
{
// zero out the whole structure
@ -142,22 +140,6 @@ int CNetServer::Recv(CNetChunk *pChunk)
// client that wants to connect
if(!Found)
{
CNetChunk Packet;
char aBuffer[sizeof(BANMASTER_IPCHECK) + NETADDR_MAXSTRSIZE];
mem_copy(aBuffer, BANMASTER_IPCHECK, sizeof(BANMASTER_IPCHECK));
net_addr_str(&Addr, aBuffer + sizeof(BANMASTER_IPCHECK), sizeof(aBuffer) - sizeof(BANMASTER_IPCHECK), false);
Packet.m_ClientID = -1;
Packet.m_Flags = NETSENDFLAG_CONNLESS;
Packet.m_DataSize = str_length(aBuffer) + 1;
Packet.m_pData = aBuffer;
for(int i = 0; i < m_NumBanmasters; i++)
{
Packet.m_Address = m_aBanmasters[i];
Send(&Packet);
}
// only allow a specific number of players with the same ip
NETADDR ThisAddr = Addr, OtherAddr;
int FoundAddr = 1;
@ -266,46 +248,3 @@ void CNetServer::SetMaxClientsPerIP(int Max)
m_MaxClientsPerIP = Max;
}
int CNetServer::BanmasterAdd(const char *pAddrStr)
{
if(m_NumBanmasters >= MAX_BANMASTERS)
return 2;
if(net_host_lookup(pAddrStr, &m_aBanmasters[m_NumBanmasters], NETTYPE_IPV4))
return 1;
if(m_aBanmasters[m_NumBanmasters].port == 0)
m_aBanmasters[m_NumBanmasters].port = BANMASTER_PORT;
m_NumBanmasters++;
return 0;
}
int CNetServer::BanmasterNum() const
{
return m_NumBanmasters;
}
NETADDR* CNetServer::BanmasterGet(int Index)
{
if(Index < 0 || Index >= m_NumBanmasters)
return 0;
return &m_aBanmasters[Index];
}
int CNetServer::BanmasterCheck(NETADDR *pAddr)
{
for(int i = 0; i < m_NumBanmasters; i++)
if(net_addr_comp(&m_aBanmasters[i], pAddr) == 0)
return i;
return -1;
}
void CNetServer::BanmastersClear()
{
m_NumBanmasters = 0;
}