mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 05:58:19 +00:00
Merge pull request #8650 from def-/pr-ban-time
Don't show ban time for vpn bans
This commit is contained in:
commit
7dc682565b
|
@ -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) = 0;
|
||||
virtual void Ban(int ClientId, int Seconds, const char *pReason, bool DisplayTime) = 0;
|
||||
virtual void RedirectClient(int ClientId, int Port, bool Verbose = false) = 0;
|
||||
virtual void ChangeMap(const char *pMap) = 0;
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ void CServerBan::InitServerBan(IConsole *pConsole, IStorage *pStorage, CServer *
|
|||
}
|
||||
|
||||
template<class T>
|
||||
int CServerBan::BanExt(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason)
|
||||
int CServerBan::BanExt(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason, bool DisplayTime)
|
||||
{
|
||||
// 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);
|
||||
int Result = Ban(pBanPool, pData, Seconds, pReason, DisplayTime);
|
||||
if(Result != 0)
|
||||
return Result;
|
||||
|
||||
|
@ -122,15 +122,15 @@ 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)
|
||||
int CServerBan::BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason, bool DisplayTime)
|
||||
{
|
||||
return BanExt(&m_BanAddrPool, pAddr, Seconds, pReason);
|
||||
return BanExt(&m_BanAddrPool, pAddr, Seconds, pReason, DisplayTime);
|
||||
}
|
||||
|
||||
int CServerBan::BanRange(const CNetRange *pRange, int Seconds, const char *pReason)
|
||||
{
|
||||
if(pRange->IsValid())
|
||||
return BanExt(&m_BanRangePool, pRange, Seconds, pReason);
|
||||
return BanExt(&m_BanRangePool, pRange, Seconds, pReason, true);
|
||||
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", "ban failed (invalid range)");
|
||||
return -1;
|
||||
|
@ -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);
|
||||
pThis->BanAddr(pThis->Server()->m_NetServer.ClientAddr(ClientId), Minutes * 60, pReason, true);
|
||||
}
|
||||
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)
|
||||
void CServer::Ban(int ClientId, int Seconds, const char *pReason, bool DisplayTime)
|
||||
{
|
||||
NETADDR Addr;
|
||||
GetClientAddr(ClientId, &Addr);
|
||||
m_NetServer.NetBan()->BanAddr(&Addr, Seconds, pReason);
|
||||
m_NetServer.NetBan()->BanAddr(&Addr, Seconds, pReason, DisplayTime);
|
||||
}
|
||||
|
||||
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");
|
||||
m_NetServer.NetBan()->BanAddr(&pPacket->m_Address, 600, "Stressing network", true);
|
||||
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");
|
||||
m_ServerBan.BanAddr(m_NetServer.ClientAddr(ClientId), Config()->m_SvRconBantime * 60, "Too many remote console authentication tries", true);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2893,7 +2893,7 @@ int CServer::Run()
|
|||
|
||||
if(Config()->m_SvDnsblBan)
|
||||
{
|
||||
m_NetServer.NetBan()->BanAddr(m_NetServer.ClientAddr(ClientId), 60, Config()->m_SvDnsblBanReason);
|
||||
m_NetServer.NetBan()->BanAddr(m_NetServer.ClientAddr(ClientId), 60, Config()->m_SvDnsblBanReason, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,14 +46,14 @@ class CServerBan : public CNetBan
|
|||
class CServer *m_pServer;
|
||||
|
||||
template<class T>
|
||||
int BanExt(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason);
|
||||
int BanExt(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason, bool DisplayTime);
|
||||
|
||||
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) override;
|
||||
int BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason, bool DisplayTime) 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) override;
|
||||
void Ban(int ClientId, int Seconds, const char *pReason, bool DisplayTime) override;
|
||||
void RedirectClient(int ClientId, int Port, bool Verbose = false) override;
|
||||
|
||||
void DemoRecorder_HandleAutoStart() override;
|
||||
|
|
|
@ -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");
|
||||
m_NetConsole.NetBan()->BanAddr(m_NetConsole.ClientAddr(ClientId), g_Config.m_EcBantime * 60, "Too many authentication tries", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ typename CNetBan::CBan<T> *CNetBan::CBanPool<T, HashCount>::Get(int Index) const
|
|||
}
|
||||
|
||||
template<class T>
|
||||
int CNetBan::Ban(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason)
|
||||
int CNetBan::Ban(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason, bool DisplayTime)
|
||||
{
|
||||
// do not ban localhost
|
||||
if(NetMatch(pData, &m_LocalhostIpV4) || NetMatch(pData, &m_LocalhostIpV6))
|
||||
|
@ -222,6 +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;
|
||||
str_copy(Info.m_aReason, pReason);
|
||||
|
||||
// check if it already exists
|
||||
|
@ -308,15 +309,15 @@ void CNetBan::Update()
|
|||
}
|
||||
}
|
||||
|
||||
int CNetBan::BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason)
|
||||
int CNetBan::BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason, bool DisplayTime)
|
||||
{
|
||||
return Ban(&m_BanAddrPool, pAddr, Seconds, pReason);
|
||||
return Ban(&m_BanAddrPool, pAddr, Seconds, pReason, DisplayTime);
|
||||
}
|
||||
|
||||
int CNetBan::BanRange(const CNetRange *pRange, int Seconds, const char *pReason)
|
||||
{
|
||||
if(pRange->IsValid())
|
||||
return Ban(&m_BanRangePool, pRange, Seconds, pReason);
|
||||
return Ban(&m_BanRangePool, pRange, Seconds, pReason, true);
|
||||
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", "ban failed (invalid range)");
|
||||
return -1;
|
||||
|
@ -414,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);
|
||||
pThis->BanAddr(&Addr, Minutes * 60, pReason, true);
|
||||
else
|
||||
pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", "ban error (invalid network address)");
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ protected:
|
|||
};
|
||||
int64_t m_Expires;
|
||||
char m_aReason[REASON_LENGTH];
|
||||
bool m_DisplayTime;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
@ -150,7 +151,7 @@ protected:
|
|||
template<class T>
|
||||
void MakeBanInfo(const CBan<T> *pBan, char *pBuf, unsigned BuffSize, int Type) const;
|
||||
template<class T>
|
||||
int Ban(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason);
|
||||
int Ban(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason, bool DisplayTime);
|
||||
template<class T>
|
||||
int Unban(T *pBanPool, const typename T::CDataType *pData);
|
||||
|
||||
|
@ -176,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);
|
||||
virtual int BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason, bool DisplayTime);
|
||||
virtual int BanRange(const CNetRange *pRange, int Seconds, const char *pReason);
|
||||
int UnbanByAddr(const NETADDR *pAddr);
|
||||
int UnbanByRange(const CNetRange *pRange);
|
||||
|
@ -227,7 +228,7 @@ void CNetBan::MakeBanInfo(const CBan<T> *pBan, char *pBuf, unsigned BuffSize, in
|
|||
}
|
||||
|
||||
// add info part
|
||||
if(pBan->m_Info.m_Expires != CBanInfo::EXPIRES_NEVER)
|
||||
if(pBan->m_Info.m_DisplayTime && pBan->m_Info.m_Expires != CBanInfo::EXPIRES_NEVER)
|
||||
{
|
||||
int Mins = ((pBan->m_Info.m_Expires - time_timestamp()) + 59) / 60;
|
||||
if(Mins <= 1)
|
||||
|
|
Loading…
Reference in a new issue