mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Add a limit of 10 unidentified connections per IP
Everything which isn't a CClient with a successful login counts as an unidentified connection in this context. Modules who don't want this kind of limit on their listening sockets can override CSocket::ConnectionFrom(), but their sockets will still count towards this limit. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1561 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
17
Socket.cpp
17
Socket.cpp
@@ -191,3 +191,20 @@ int CZNCSock::GetAddrInfo(const CS_STRING &sHostname, CSSockAddr &csSockAddr) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned int CSockManager::GetAnonConnectionCount(const CString &sIP) const {
|
||||
const_iterator it;
|
||||
unsigned int ret = 0;
|
||||
|
||||
for (it = begin(); it != end(); it++) {
|
||||
CZNCSock *pSock = *it;
|
||||
// Logged in CClients have "USR::<username>" as their sockname
|
||||
if (pSock->GetRemoteIP() == sIP && pSock->GetSockName().Left(5) != "USR::") {
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG("There are [" << ret << "] clients from [" << sIP << "]");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user