From 165070019d0f88cd1fe6317792366520afbc9abb Mon Sep 17 00:00:00 2001 From: psychon Date: Sun, 12 Jul 2009 11:31:49 +0000 Subject: [PATCH] Add new config option AnonIPLimit This makes the limit added in r1561 configurable. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1563 726aef4b-f618-498e-8847-2d620e286838 --- znc.cpp | 10 +++++++++- znc.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/znc.cpp b/znc.cpp index 81b804a0..9bbb1801 100644 --- a/znc.cpp +++ b/znc.cpp @@ -36,6 +36,7 @@ CZNC::CZNC() { #endif m_pISpoofLockFile = NULL; m_uiConnectDelay = 30; + m_uiAnonIPLimit = 10; SetISpoofFormat(""); // Set ISpoofFormat to default m_uBytesRead = 0; m_uBytesWritten = 0; @@ -400,7 +401,9 @@ bool CZNC::IsHostAllowed(const CString& sHostMask) const { } bool CZNC::AllowConnectionFrom(const CString& sIP) const { - if (GetManager().GetAnonConnectionCount(sIP) >= 10) + if (m_uiAnonIPLimit == 0) + return true; + if (GetManager().GetAnonConnectionCount(sIP) >= m_uiAnonIPLimit) return false; return true; } @@ -511,6 +514,8 @@ bool CZNC::WriteConfig() { return false; } + m_LockFile.Write("AnonIPLimit = " + CString(m_uiAnonIPLimit) + "\n"); + for (size_t l = 0; l < m_vpListeners.size(); l++) { CListener* pListener = m_vpListeners[l]; CString sHostPortion = pListener->GetBindHost(); @@ -1497,6 +1502,9 @@ bool CZNC::DoRehash(CString& sError) } else if (sName.Equals("ConnectDelay")) { m_uiConnectDelay = sValue.ToUInt(); continue; + } else if (sName.Equals("AnonIPLimit")) { + m_uiAnonIPLimit = sValue.ToUInt(); + continue; } } diff --git a/znc.h b/znc.h index 7844b30f..42430ecf 100644 --- a/znc.h +++ b/znc.h @@ -158,6 +158,7 @@ protected: CFile m_LockFile; CFile* m_pISpoofLockFile; unsigned int m_uiConnectDelay; + unsigned int m_uiAnonIPLimit; #ifdef _MODULES CGlobalModules* m_pModules; #endif