From 87aa251d738cea9b62acb834b7ef561a617fe1a9 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Tue, 20 Aug 2024 16:51:37 +0200 Subject: [PATCH] Don't show "you've been banned" for VPN bans Players are supposed to turn of their VPN or complain to the admins if they get banned for using a VPN. Calling this "banned" seems to be confusing, as players ask for an unban even after they turned off the VPN. --- src/engine/server.h | 2 +- src/engine/server/server.cpp | 20 ++++++++++---------- src/engine/server/server.h | 6 +++--- src/engine/shared/econ.cpp | 2 +- src/engine/shared/netban.cpp | 12 ++++++------ src/engine/shared/netban.h | 8 ++++---- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/engine/server.h b/src/engine/server.h index 6b1a4a91d..64ec543ca 100644 --- a/src/engine/server.h +++ b/src/engine/server.h @@ -250,7 +250,7 @@ public: virtual int GetAuthedState(int ClientId) const = 0; virtual const char *GetAuthName(int ClientId) const = 0; virtual void Kick(int ClientId, const char *pReason) = 0; - virtual void Ban(int ClientId, int Seconds, const char *pReason, bool DisplayTime) = 0; + virtual void Ban(int ClientId, int Seconds, const char *pReason, bool VerbatimReason) = 0; virtual void RedirectClient(int ClientId, int Port, bool Verbose = false) = 0; virtual void ChangeMap(const char *pMap) = 0; diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index b2947020f..de815e4ac 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -60,7 +60,7 @@ void CServerBan::InitServerBan(IConsole *pConsole, IStorage *pStorage, CServer * } template -int CServerBan::BanExt(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason, bool DisplayTime) +int CServerBan::BanExt(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason, bool VerbatimReason) { // validate address if(Server()->m_RconClientId >= 0 && Server()->m_RconClientId < MAX_CLIENTS && @@ -99,7 +99,7 @@ int CServerBan::BanExt(T *pBanPool, const typename T::CDataType *pData, int Seco } } - int Result = Ban(pBanPool, pData, Seconds, pReason, DisplayTime); + int Result = Ban(pBanPool, pData, Seconds, pReason, VerbatimReason); if(Result != 0) return Result; @@ -122,9 +122,9 @@ int CServerBan::BanExt(T *pBanPool, const typename T::CDataType *pData, int Seco return Result; } -int CServerBan::BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason, bool DisplayTime) +int CServerBan::BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason, bool VerbatimReason) { - return BanExt(&m_BanAddrPool, pAddr, Seconds, pReason, DisplayTime); + return BanExt(&m_BanAddrPool, pAddr, Seconds, pReason, VerbatimReason); } int CServerBan::BanRange(const CNetRange *pRange, int Seconds, const char *pReason) @@ -150,7 +150,7 @@ void CServerBan::ConBanExt(IConsole::IResult *pResult, void *pUser) if(ClientId < 0 || ClientId >= MAX_CLIENTS || pThis->Server()->m_aClients[ClientId].m_State == CServer::CClient::STATE_EMPTY) pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", "ban error (invalid client id)"); else - pThis->BanAddr(pThis->Server()->m_NetServer.ClientAddr(ClientId), Minutes * 60, pReason, true); + pThis->BanAddr(pThis->Server()->m_NetServer.ClientAddr(ClientId), Minutes * 60, pReason, false); } else ConBan(pResult, pUser); @@ -473,11 +473,11 @@ void CServer::Kick(int ClientId, const char *pReason) m_NetServer.Drop(ClientId, pReason); } -void CServer::Ban(int ClientId, int Seconds, const char *pReason, bool DisplayTime) +void CServer::Ban(int ClientId, int Seconds, const char *pReason, bool VerbatimReason) { NETADDR Addr; GetClientAddr(ClientId, &Addr); - m_NetServer.NetBan()->BanAddr(&Addr, Seconds, pReason, DisplayTime); + m_NetServer.NetBan()->BanAddr(&Addr, Seconds, pReason, VerbatimReason); } void CServer::RedirectClient(int ClientId, int Port, bool Verbose) @@ -1459,7 +1459,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) if(m_aClients[ClientId].m_Traffic > Limit) { - m_NetServer.NetBan()->BanAddr(&pPacket->m_Address, 600, "Stressing network", true); + m_NetServer.NetBan()->BanAddr(&pPacket->m_Address, 600, "Stressing network", false); return; } if(Diff > 100) @@ -1825,7 +1825,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) if(!Config()->m_SvRconBantime) m_NetServer.Drop(ClientId, "Too many remote console authentication tries"); else - m_ServerBan.BanAddr(m_NetServer.ClientAddr(ClientId), Config()->m_SvRconBantime * 60, "Too many remote console authentication tries", true); + m_ServerBan.BanAddr(m_NetServer.ClientAddr(ClientId), Config()->m_SvRconBantime * 60, "Too many remote console authentication tries", false); } } else @@ -2970,7 +2970,7 @@ int CServer::Run() if(Config()->m_SvDnsblBan) { - m_NetServer.NetBan()->BanAddr(m_NetServer.ClientAddr(ClientId), 60, Config()->m_SvDnsblBanReason, false); + m_NetServer.NetBan()->BanAddr(m_NetServer.ClientAddr(ClientId), 60, Config()->m_SvDnsblBanReason, true); } } } diff --git a/src/engine/server/server.h b/src/engine/server/server.h index 566858a99..66ee206e8 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -46,14 +46,14 @@ class CServerBan : public CNetBan class CServer *m_pServer; template - int BanExt(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason, bool DisplayTime); + int BanExt(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason, bool VerbatimReason); public: class CServer *Server() const { return m_pServer; } void InitServerBan(class IConsole *pConsole, class IStorage *pStorage, class CServer *pServer); - int BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason, bool DisplayTime) override; + int BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason, bool VerbatimReason) override; int BanRange(const CNetRange *pRange, int Seconds, const char *pReason) override; static void ConBanExt(class IConsole::IResult *pResult, void *pUser); @@ -279,7 +279,7 @@ public: void SetClientFlags(int ClientId, int Flags) override; void Kick(int ClientId, const char *pReason) override; - void Ban(int ClientId, int Seconds, const char *pReason, bool DisplayTime) override; + void Ban(int ClientId, int Seconds, const char *pReason, bool VerbatimReason) override; void RedirectClient(int ClientId, int Port, bool Verbose = false) override; void DemoRecorder_HandleAutoStart() override; diff --git a/src/engine/shared/econ.cpp b/src/engine/shared/econ.cpp index eec607245..354e9eded 100644 --- a/src/engine/shared/econ.cpp +++ b/src/engine/shared/econ.cpp @@ -130,7 +130,7 @@ void CEcon::Update() if(!g_Config.m_EcBantime) m_NetConsole.Drop(ClientId, "Too many authentication tries"); else - m_NetConsole.NetBan()->BanAddr(m_NetConsole.ClientAddr(ClientId), g_Config.m_EcBantime * 60, "Too many authentication tries", true); + m_NetConsole.NetBan()->BanAddr(m_NetConsole.ClientAddr(ClientId), g_Config.m_EcBantime * 60, "Too many authentication tries", false); } } } diff --git a/src/engine/shared/netban.cpp b/src/engine/shared/netban.cpp index a00709941..4d1bc7059 100644 --- a/src/engine/shared/netban.cpp +++ b/src/engine/shared/netban.cpp @@ -208,7 +208,7 @@ typename CNetBan::CBan *CNetBan::CBanPool::Get(int Index) const } template -int CNetBan::Ban(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason, bool DisplayTime) +int CNetBan::Ban(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason, bool VerbatimReason) { // do not ban localhost if(NetMatch(pData, &m_LocalhostIpV4) || NetMatch(pData, &m_LocalhostIpV6)) @@ -222,7 +222,7 @@ int CNetBan::Ban(T *pBanPool, const typename T::CDataType *pData, int Seconds, c // set up info CBanInfo Info = {0}; Info.m_Expires = Stamp; - Info.m_DisplayTime = DisplayTime; + Info.m_VerbatimReason = VerbatimReason; str_copy(Info.m_aReason, pReason); // check if it already exists @@ -309,15 +309,15 @@ void CNetBan::Update() } } -int CNetBan::BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason, bool DisplayTime) +int CNetBan::BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason, bool VerbatimReason) { - return Ban(&m_BanAddrPool, pAddr, Seconds, pReason, DisplayTime); + return Ban(&m_BanAddrPool, pAddr, Seconds, pReason, VerbatimReason); } int CNetBan::BanRange(const CNetRange *pRange, int Seconds, const char *pReason) { if(pRange->IsValid()) - return Ban(&m_BanRangePool, pRange, Seconds, pReason, true); + return Ban(&m_BanRangePool, pRange, Seconds, pReason, false); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", "ban failed (invalid range)"); return -1; @@ -415,7 +415,7 @@ void CNetBan::ConBan(IConsole::IResult *pResult, void *pUser) NETADDR Addr; if(net_addr_from_str(&Addr, pStr) == 0) - pThis->BanAddr(&Addr, Minutes * 60, pReason, true); + pThis->BanAddr(&Addr, Minutes * 60, pReason, false); else pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", "ban error (invalid network address)"); } diff --git a/src/engine/shared/netban.h b/src/engine/shared/netban.h index b880d673c..f51afc07c 100644 --- a/src/engine/shared/netban.h +++ b/src/engine/shared/netban.h @@ -81,7 +81,7 @@ protected: }; int64_t m_Expires; char m_aReason[REASON_LENGTH]; - bool m_DisplayTime; + bool m_VerbatimReason; }; template @@ -151,7 +151,7 @@ protected: template void MakeBanInfo(const CBan *pBan, char *pBuf, unsigned BuffSize, int Type) const; template - int Ban(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason, bool DisplayTime); + int Ban(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason, bool VerbatimReason); template int Unban(T *pBanPool, const typename T::CDataType *pData); @@ -177,7 +177,7 @@ public: void Init(class IConsole *pConsole, class IStorage *pStorage); void Update(); - virtual int BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason, bool DisplayTime); + virtual int BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason, bool VerbatimReason); virtual int BanRange(const CNetRange *pRange, int Seconds, const char *pReason); int UnbanByAddr(const NETADDR *pAddr); int UnbanByRange(const CNetRange *pRange); @@ -228,7 +228,7 @@ void CNetBan::MakeBanInfo(const CBan *pBan, char *pBuf, unsigned BuffSize, in } // add info part - if(pBan->m_Info.m_DisplayTime && pBan->m_Info.m_Expires != CBanInfo::EXPIRES_NEVER) + if(!pBan->m_Info.m_VerbatimReason && pBan->m_Info.m_Expires != CBanInfo::EXPIRES_NEVER) { int Mins = ((pBan->m_Info.m_Expires - time_timestamp()) + 59) / 60; if(Mins <= 1)