From bc77d8b2611873e341c5decd10d2cc7d17277412 Mon Sep 17 00:00:00 2001 From: psychon Date: Mon, 11 May 2009 16:16:10 +0000 Subject: [PATCH] Fix a wrong cached /mode reply ZNC replies to /mode #chan with the cached channel modes without querying the IRCd. This was added to avoid traffic spikes to the ircd when a client logged in. The logic in this code had a bug that made it also reply with stale cached values if we once were but aren't anymore in that channel (e.g. after you've been kicked). Thanks to tomaw for reporting this. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1507 726aef4b-f618-498e-8847-2d620e286838 --- Client.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Client.cpp b/Client.cpp index 09afc5c8..e63d8643 100644 --- a/Client.cpp +++ b/Client.cpp @@ -284,7 +284,10 @@ void CClient::ReadLine(const CString& sData) { if (m_pUser->IsChan(sTarget)) { CChan *pChan = m_pUser->FindChan(sTarget); - if (pChan && sModes.empty() && !pChan->GetModeString().empty()) { + // If we are on that channel and already received a + // /mode reply from the server, we can answer this + // request ourself. + if (pChan && pChan->IsOn() && sModes.empty() && !pChan->GetModeString().empty()) { PutClient(":" + m_pUser->GetIRCServer() + " 324 " + GetNick() + " " + sTarget + " " + pChan->GetModeString()); if (pChan->GetCreationDate() > 0) { PutClient(":" + m_pUser->GetIRCServer() + " 329 " + GetNick() + " " + sTarget + " " + CString(pChan->GetCreationDate()));