From: <sil...@us...> - 2010-01-10 12:33:00
|
Revision: 1702 http://znc.svn.sourceforge.net/znc/?rev=1702&view=rev Author: silverleo Date: 2010-01-10 12:32:34 +0000 (Sun, 10 Jan 2010) Log Message: ----------- Change ConnectDelay to be server specific and not global. This way users that connect to different servers can connect faster. Modified Paths: -------------- trunk/znc.cpp trunk/znc.h Modified: trunk/znc.cpp =================================================================== --- trunk/znc.cpp 2010-01-10 12:04:08 UTC (rev 1701) +++ trunk/znc.cpp 2010-01-10 12:32:34 UTC (rev 1702) @@ -35,7 +35,6 @@ m_pModules = new CGlobalModules(); #endif m_pISpoofLockFile = NULL; - m_uiConnectDelay = 30; m_uiAnonIPLimit = 10; SetISpoofFormat(""); // Set ISpoofFormat to default m_uBytesRead = 0; @@ -43,6 +42,7 @@ m_pConnectUserTimer = NULL; m_eConfigState = ECONFIG_NOTHING; m_TimeStarted = time(NULL); + m_sConnectThrottle.SetTTL(30000); } CZNC::~CZNC() { @@ -146,12 +146,17 @@ if (!pServer) return false; + if (m_sConnectThrottle.GetItem(pServer->GetName())) + return false; + if (!WriteISpoof(pUser)) { DEBUG("ISpoof could not be written"); pUser->PutStatus("ISpoof could not be written, retrying..."); return true; } + m_sConnectThrottle.AddItem(pServer->GetName()); + DEBUG("User [" << pUser->GetUserName() << "] is connecting to [" << pServer->GetName() << ":" << pServer->GetPort() << "] ..."); pUser->PutStatus("Attempting to connect to [" + pServer->GetName() + ":" + CString(pServer->GetPort()) + "] ..."); @@ -556,7 +561,7 @@ m_LockFile.Write("Listen" + s6 + " = " + sHostPortion + CString((pListener->IsSSL()) ? "+" : "") + CString(pListener->GetPort()) + "\n"); } - m_LockFile.Write("ConnectDelay = " + CString(m_uiConnectDelay) + "\n"); + m_LockFile.Write("ConnectDelay = " + CString(m_sConnectThrottle.GetTTL()/1000) + "\n"); if (!m_sISpoofFile.empty()) { m_LockFile.Write("ISpoofFile = " + m_sISpoofFile.FirstLine() + "\n"); @@ -1535,7 +1540,7 @@ m_sStatusPrefix = sValue; continue; } else if (sName.Equals("ConnectDelay")) { - m_uiConnectDelay = sValue.ToUInt(); + m_sConnectThrottle.SetTTL(sValue.ToUInt()*1000); continue; } else if (sName.Equals("AnonIPLimit")) { m_uiAnonIPLimit = sValue.ToUInt(); @@ -1901,7 +1906,7 @@ if (m_pConnectUserTimer != NULL) return; - m_pConnectUserTimer = new CConnectUserTimer(m_uiConnectDelay); + m_pConnectUserTimer = new CConnectUserTimer(3); GetManager().AddCron(m_pConnectUserTimer); } Modified: trunk/znc.h =================================================================== --- trunk/znc.h 2010-01-10 12:04:08 UTC (rev 1701) +++ trunk/znc.h 2010-01-10 12:32:34 UTC (rev 1702) @@ -162,7 +162,6 @@ VCString m_vsMotd; CFile m_LockFile; CFile* m_pISpoofLockFile; - unsigned int m_uiConnectDelay; unsigned int m_uiAnonIPLimit; #ifdef _MODULES CGlobalModules* m_pModules; @@ -170,6 +169,7 @@ unsigned long long m_uBytesRead; unsigned long long m_uBytesWritten; CConnectUserTimer *m_pConnectUserTimer; + TCacheMap<CString> m_sConnectThrottle; }; class CRealListener : public CZNCSock { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |