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


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1177 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-08-29 15:06:08 +00:00
parent 5c588352d9
commit da8c892d4f
4 changed files with 14 additions and 4 deletions

View File

@@ -41,6 +41,7 @@ CUser::CUser(const CString& sUserName) {
m_sChanPrefixes = "";
m_uBufferCount = 50;
m_uMaxJoinTries = 0;
m_uMaxJoins = 5;
m_bKeepBuffer = false;
m_bAutoCycle = true;
m_bBeingDeleted = false;
@@ -295,6 +296,7 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneChans) {
SetDefaultChanModes(User.GetDefaultChanModes());
SetBufferCount(User.GetBufferCount());
SetJoinTries(User.JoinTries());
SetMaxJoins(User.MaxJoins());
// Allowed Hosts
m_ssAllowedHosts.clear();
@@ -405,8 +407,6 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneChans) {
pChan->Clone(*pNewChan);
}
}
JoinChans();
// !Chans
// CTCP Replies
@@ -587,6 +587,7 @@ bool CUser::WriteConfig(CFile& File) {
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 @@ CChan* CUser::FindChan(const CString& sName) const {
}
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 @@ void CUser::JoinChans() {
} else {
pChan->IncJoinTries();
PutIRC("JOIN " + pChan->GetName() + " " + pChan->GetKey());
// Limit the number of joins
if (uJoins != 0 && --uJoins == 0)
return;
}
}
}