mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38:19 +00:00
Merge pull request #8774 from heinrich5991/pr_ddnet_no_ban_vpn
Don't show "you've been banned" for VPN bans
This commit is contained in:
commit
580b2690a0
|
@ -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;
|
||||
|
||||
|
|
|
@ -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, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, 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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, 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)");
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ protected:
|
|||
};
|
||||
int64_t m_Expires;
|
||||
char m_aReason[REASON_LENGTH];
|
||||
bool m_DisplayTime;
|
||||
bool m_VerbatimReason;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
@ -151,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, bool DisplayTime);
|
||||
int Ban(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason, bool VerbatimReason);
|
||||
template<class T>
|
||||
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<T> *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)
|
||||
|
|
Loading…
Reference in a new issue