diff options
| author | oy <Tom_Adams@web.de> | 2011-07-31 13:05:12 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-07-31 13:05:12 +0200 |
| commit | 94188021509a376fc352b7707d9a324335a97eba (patch) | |
| tree | e0ad6c8d81a91217e4b035d764f3d57fb8a2c2c1 /src/engine/shared/econ.cpp | |
| parent | 1705c90e148d680c4b8002d12ac15a7d228f6408 (diff) | |
| download | zcatch-94188021509a376fc352b7707d9a324335a97eba.tar.gz zcatch-94188021509a376fc352b7707d9a324335a97eba.zip | |
protected econ authentication against brute force
Diffstat (limited to 'src/engine/shared/econ.cpp')
| -rw-r--r-- | src/engine/shared/econ.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/engine/shared/econ.cpp b/src/engine/shared/econ.cpp index 18a551e7..617cdbd6 100644 --- a/src/engine/shared/econ.cpp +++ b/src/engine/shared/econ.cpp @@ -16,6 +16,7 @@ int CEcon::NewClientCallback(int ClientID, void *pUser) pThis->m_aClients[ClientID].m_State = CClient::STATE_CONNECTED; pThis->m_aClients[ClientID].m_TimeConnected = time_get(); + pThis->m_aClients[ClientID].m_AuthTries = 0; pThis->m_NetConsole.Send(ClientID, "Enter password:"); return 0; @@ -112,7 +113,22 @@ void CEcon::Update() Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "econ", aBuf); } else - m_NetConsole.Send(ClientID, "Wrong password"); + { + m_aClients[ClientID].m_AuthTries++; + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "Wrong password %d/%d.", m_aClients[ClientID].m_AuthTries, MAX_AUTH_TRIES); + m_NetConsole.Send(ClientID, aBuf); + if(m_aClients[ClientID].m_AuthTries >= MAX_AUTH_TRIES) + { + if(!g_Config.m_EcBantime) + m_NetConsole.Drop(ClientID, "Too many authentication tries"); + else + { + NETADDR Addr = m_NetConsole.ClientAddr(ClientID); + m_NetConsole.AddBan(Addr, g_Config.m_EcBantime*60); + } + } + } } else if(m_aClients[ClientID].m_State == CClient::STATE_AUTHED) { |