mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Add autoban depending on client version
This commit is contained in:
parent
4f33aceb1c
commit
069b1763dd
|
@ -359,6 +359,8 @@ MACRO_CONFIG_INT(SvSoloServer, sv_solo_server, 0, 0, 1, CFGFLAG_SERVER|CFGFLAG_G
|
|||
MACRO_CONFIG_STR(SvClientSuggestion, sv_client_suggestion, 128, "Get DDNet client from DDNet.tw to use all features on DDNet!", CFGFLAG_SERVER, "Broadcast to display to players without DDNet client")
|
||||
MACRO_CONFIG_STR(SvClientSuggestionOld, sv_client_suggestion_old, 128, "Your DDNet client is old, update it on DDNet.tw!", CFGFLAG_SERVER, "Broadcast to display to players with an old version of DDNet client")
|
||||
MACRO_CONFIG_STR(SvClientSuggestionBot, sv_client_suggestion_bot, 128, "Your client has bots and can be remotely controlled!\nPlease use another client like DDNet client from DDNet.tw", CFGFLAG_SERVER, "Broadcast to display to players with a known botting client")
|
||||
MACRO_CONFIG_STR(SvBotVersionNumbers, sv_bot_version_numbers, 128, "99001;99002", CFGFLAG_SERVER, "Semicolon seperated list of known bot clients to be punished by (sv_bot_punishment)")
|
||||
MACRO_CONFIG_INT(SvBotPunishment, sv_bot_punishment, 1, 0, 1024, CFGFLAG_SERVER, "0 - Disable, 1 - kick, >1 ban in minutes")
|
||||
|
||||
// netlimit
|
||||
MACRO_CONFIG_INT(SvNetlimit, sv_netlimit, 0, 0, 10000, CFGFLAG_SERVER, "Netlimit: Maximum amount of traffic a client is allowed to use (in kb/s)")
|
||||
|
|
|
@ -1800,6 +1800,16 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
//tell known bot clients that they're botting and we know it
|
||||
if (((Version >= 15 && Version < 100) || Version == 502) && g_Config.m_SvClientSuggestionBot[0] != '\0')
|
||||
SendBroadcast(g_Config.m_SvClientSuggestionBot, ClientID);
|
||||
//autoban known bot versions
|
||||
if(g_Config.m_SvBotPunishment && isBotVersion(Version))
|
||||
{
|
||||
char aBuf[128];
|
||||
if(g_Config.m_SvBotPunishment == 1)
|
||||
str_format(aBuf, sizeof(aBuf), "kick %d bot client", ClientID);
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "ban %d %d %s", ClientID, g_Config.m_SvBotPunishment, "bot client");
|
||||
Console()->ExecuteLine(aBuf);
|
||||
}
|
||||
}
|
||||
else if (MsgID == NETMSGTYPE_CL_SHOWOTHERS)
|
||||
{
|
||||
|
@ -3550,6 +3560,25 @@ void CGameContext::Converse(int ClientID, char *pStr)
|
|||
}
|
||||
}
|
||||
|
||||
bool CGameContext::isBotVersion(int Version)
|
||||
{
|
||||
char aVersion[16];
|
||||
str_format(aVersion, sizeof(aVersion), "%d", Version);
|
||||
char aVersions[sizeof(g_Config.m_SvBotVersionNumbers)];
|
||||
str_copy(aVersions, g_Config.m_SvBotVersionNumbers, sizeof(aVersions));
|
||||
char *p = strtok(aVersions, ";");;
|
||||
|
||||
while(p)
|
||||
{
|
||||
if(!str_comp(p, aVersion))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
p = strtok(NULL, ";");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CGameContext::List(int ClientID, const char *pFilter)
|
||||
{
|
||||
int Total = 0;
|
||||
|
|
|
@ -389,6 +389,7 @@ private:
|
|||
void Whisper(int ClientID, char *pStr);
|
||||
void WhisperID(int ClientID, int VictimID, char *pMessage);
|
||||
void Converse(int ClientID, char *pStr);
|
||||
bool isBotVersion(int Version);
|
||||
|
||||
public:
|
||||
CLayers *Layers() { return &m_Layers; }
|
||||
|
|
Loading…
Reference in a new issue