From 4508a9aeca21806e723850fc4225addb416d2305 Mon Sep 17 00:00:00 2001 From: prozacx Date: Fri, 27 May 2005 06:58:13 +0000 Subject: [PATCH] Fixed flooding issue with KeepNick - only send NICK orignick after a 433 is sent back git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@372 726aef4b-f618-498e-8847-2d620e286838 --- IRCSock.cpp | 5 ++++- IRCSock.h | 3 +++ Timers.h | 8 +++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/IRCSock.cpp b/IRCSock.cpp index d913ff72..4ad4e652 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -13,6 +13,7 @@ CIRCSock::CIRCSock(CZNC* pZNC, CUser* pUser) : Csock() { m_bISpoofReleased = false; m_bKeepNick = true; m_bAuthed = false; + m_bOrigNickPending = false; EnableReadLine(); m_RawBuffer.SetLineCount(100); // This should be more than enough raws, especially since we are buffering the MOTD separately m_MotdBuffer.SetLineCount(200); // This should be more than enough motd lines @@ -202,6 +203,7 @@ void CIRCSock::ReadLine(const CString& sData) { if ((m_bKeepNick) && (m_pUser->GetKeepNick())) { if (sBadNick.CaseCmp(sConfNick) == 0) { if ((!m_pUserSock) || (!m_pUserSock->DecKeepNickCounter())) { + SetOrigNickPending(false); return; } } @@ -604,8 +606,9 @@ void CIRCSock::KeepNick() { const CString& sConfNick = m_pUser->GetNick(); CString sAwayNick = CNick::Concat(sConfNick, m_pUser->GetAwaySuffix(), GetMaxNickLen()); - if ((m_bAuthed) && (m_bKeepNick) && (m_pUser->GetKeepNick()) && (GetNick().CaseCmp(sConfNick) != 0) && (GetNick().CaseCmp(sAwayNick) != 0)) { + if (m_bAuthed && m_bKeepNick && !IsOrigNickPending() && m_pUser->GetKeepNick() && GetNick().CaseCmp(sConfNick) != 0 && GetNick().CaseCmp(sAwayNick) != 0) { PutServ("NICK " + sConfNick); + SetOrigNickPending(true); } } diff --git a/IRCSock.h b/IRCSock.h index 7f32b936..f1a791fa 100644 --- a/IRCSock.h +++ b/IRCSock.h @@ -52,6 +52,7 @@ public: // Setters void SetPass(const CString& s) { m_sPass = s; } void SetKeepNick(bool b) { m_bKeepNick = b; } + void SetOrigNickPending(bool b) { m_bOrigNickPending = b; } // !Setters // Getters @@ -67,6 +68,7 @@ public: CString GetNickMask() const { return m_Nick.GetNickMask(); } const CString& GetNick() const { return m_Nick.GetNick(); } const CString& GetPass() const { return m_sPass; } + bool IsOrigNickPending() const { return m_bOrigNickPending; } // !Getters private: void SetNick(const CString& sNick); @@ -74,6 +76,7 @@ protected: bool m_bISpoofReleased; bool m_bAuthed; bool m_bKeepNick; + bool m_bOrigNickPending; CString m_sPerms; CString m_sPermModes; map m_mueChanModes; diff --git a/Timers.h b/Timers.h index b37bf1ed..cf615bb1 100644 --- a/Timers.h +++ b/Timers.h @@ -13,11 +13,17 @@ protected: virtual void RunJob() { CIRCSock* pSock = m_pUser->GetIRCSock(); if (pSock) { + if (m_uTrys++ >= 20) { + pSock->SetOrigNickPending(false); + m_uTrys = 0; + } + pSock->KeepNick(); } } - CUser* m_pUser; + CUser* m_pUser; + unsigned int m_uTrys; }; class CJoinTimer : public CCron {