From: <ps...@us...> - 2008-08-29 15:05:59
|
Revision: 1177 http://znc.svn.sourceforge.net/znc/?rev=1177&view=rev Author: psychon Date: 2008-08-29 15:06:08 +0000 (Fri, 29 Aug 2008) Log Message: ----------- Add a config option 'MaxJoins' to limit the number of joins ZNC does at once This should hopefully fix a couple of 'Excess flood' problems we were having. Thanks to SilverLeo for finally writing this :P Modified Paths: -------------- trunk/User.cpp trunk/User.h trunk/modules/webadmin.cpp trunk/znc.cpp Modified: trunk/User.cpp =================================================================== --- trunk/User.cpp 2008-08-28 18:50:42 UTC (rev 1176) +++ trunk/User.cpp 2008-08-29 15:06:08 UTC (rev 1177) @@ -41,6 +41,7 @@ m_sChanPrefixes = ""; m_uBufferCount = 50; m_uMaxJoinTries = 0; + m_uMaxJoins = 5; m_bKeepBuffer = false; m_bAutoCycle = true; m_bBeingDeleted = false; @@ -295,6 +296,7 @@ SetDefaultChanModes(User.GetDefaultChanModes()); SetBufferCount(User.GetBufferCount()); SetJoinTries(User.JoinTries()); + SetMaxJoins(User.MaxJoins()); // Allowed Hosts m_ssAllowedHosts.clear(); @@ -405,8 +407,6 @@ pChan->Clone(*pNewChan); } } - - JoinChans(); // !Chans // CTCP Replies @@ -587,6 +587,7 @@ PrintLine(File, "PrependTimestamp", CString((GetTimestampPrepend()) ? "true" : "false")); PrintLine(File, "TimezoneOffset", CString(m_fTimezoneOffset)); PrintLine(File, "JoinTries", CString(m_uMaxJoinTries)); + PrintLine(File, "MaxJoins", CString(m_uMaxJoins)); File.Write("\n"); // Allow Hosts @@ -659,6 +660,7 @@ } void CUser::JoinChans() { + unsigned int uJoins = m_uMaxJoins; for (unsigned int a = 0; a < m_vChans.size(); a++) { CChan* pChan = m_vChans[a]; if (!pChan->IsOn() && !pChan->IsDisabled()) { @@ -668,6 +670,10 @@ } else { pChan->IncJoinTries(); PutIRC("JOIN " + pChan->GetName() + " " + pChan->GetKey()); + + // Limit the number of joins + if (uJoins != 0 && --uJoins == 0) + return; } } } Modified: trunk/User.h =================================================================== --- trunk/User.h 2008-08-28 18:50:42 UTC (rev 1176) +++ trunk/User.h 2008-08-29 15:06:08 UTC (rev 1177) @@ -141,6 +141,7 @@ void SetTimestampPrepend(bool b) { m_bPrependTimestamp = b; } void SetTimezoneOffset(float b) { m_fTimezoneOffset = b; } void SetJoinTries(unsigned int i) { m_uMaxJoinTries = i; } + void SetMaxJoins(unsigned int i) { m_uMaxJoins = i; } void SetIRCConnectEnabled(bool b) { m_bIRCConnectEnabled = b; } // !Setters @@ -193,6 +194,7 @@ unsigned long long BytesRead() const { return m_uBytesRead; } unsigned long long BytesWritten() const { return m_uBytesWritten; } unsigned int JoinTries() const { return m_uMaxJoinTries; } + unsigned int MaxJoins() const { return m_uMaxJoins; } // !Getters private: protected: @@ -251,6 +253,7 @@ unsigned long long m_uBytesRead; unsigned long long m_uBytesWritten; unsigned int m_uMaxJoinTries; + unsigned int m_uMaxJoins; #ifdef _MODULES CModules* m_pModules; Modified: trunk/modules/webadmin.cpp =================================================================== --- trunk/modules/webadmin.cpp 2008-08-28 18:50:42 UTC (rev 1176) +++ trunk/modules/webadmin.cpp 2008-08-29 15:06:08 UTC (rev 1177) @@ -733,8 +733,6 @@ } } - m_pUser->JoinChans(); - if (!CZNC::Get().WriteConfig()) { GetErrorPage(sPageRet, "Channel added/modified, but config was not written"); return true; Modified: trunk/znc.cpp =================================================================== --- trunk/znc.cpp 2008-08-28 18:50:42 UTC (rev 1176) +++ trunk/znc.cpp 2008-08-29 15:06:08 UTC (rev 1177) @@ -1278,6 +1278,9 @@ } else if (sName.CaseCmp("JoinTries") == 0) { pUser->SetJoinTries(sValue.ToUInt()); continue; + } else if (sName.CaseCmp("MaxJoins") == 0) { + pUser->SetMaxJoins(sValue.ToUInt()); + continue; } else if (sName.CaseCmp("LoadModule") == 0) { CString sModName = sValue.Token(0); CUtils::PrintAction("Loading Module [" + sModName + "]"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |