Overhaul channel join handling

Instead of sending a single JOIN line for each channel, znc now tries to stuff
all of the channel that it has decided to join into a single JOIN command.

Apparently this helps with some IRCds which decide when to flood someone off
based on the number of lines received, not based on the number of bytes.

Let's hope for the best...


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2182 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2010-11-15 21:06:18 +00:00
parent 3327a974fe
commit 6a1d27d149
2 changed files with 36 additions and 3 deletions
+35 -3
View File
@@ -770,10 +770,42 @@ void CUser::JoinChans() {
}
}
for (set<CChan*>::iterator it = sChans.begin();
it != sChans.end(); ++it) {
PutIRC("JOIN " + (*it)->GetName() + " " + (*it)->GetKey());
while (!sChans.empty())
JoinChans(sChans);
}
void CUser::JoinChans(set<CChan*>& sChans) {
CString sKeys, sJoin;
bool bHaveKey = false;
size_t uiJoinLength = strlen("JOIN ");
while (!sChans.empty()) {
set<CChan*>::iterator it = sChans.begin();
const CString& sName = (*it)->GetName();
const CString& sKey = (*it)->GetKey();
size_t len = sName.length() + sKey.length();
len += 2; // two comma
if (!sKeys.empty() && uiJoinLength + len >= 512)
break;
if (!sJoin.empty()) {
sJoin += ",";
sKeys += ",";
}
uiJoinLength += len;
sJoin += sName;
if (!sKey.empty()) {
sKeys += sKey;
bHaveKey = true;
}
sChans.erase(it);
}
if (bHaveKey)
PutIRC("JOIN " + sJoin + " " + sKeys);
else
PutIRC("JOIN " + sJoin);
}
bool CUser::JoinChan(CChan* pChan) {