diff --git a/Client.cpp b/Client.cpp index 290d30da..e0cf0a1e 100644 --- a/Client.cpp +++ b/Client.cpp @@ -84,26 +84,9 @@ void CClient::ReadLine(const CString& sData) { } if (!m_pIRCSock) { - // No need to check against IRC nick or to forward it + // No need to forward it return; } - - if ((m_pUser) && (sNick.CaseCmp(m_pUser->GetNick()) == 0)) { - m_uKeepNickCounter++; - // If the user is changing his nick to the conifg nick, set keepnick to the config value - if (m_pUser->GetKeepNick() && !m_pIRCSock->GetKeepNick()) { - m_pIRCSock->SetKeepNick(true); - PutStatusNotice("Reset KeepNick back to true"); - } - } - - if (m_pUser && GetNick().CaseCmp(m_pUser->GetNick()) == 0) { - // If the user changes his nick away from the config nick, we shut off keepnick for this session - if (m_pUser->GetKeepNick()) { - m_pIRCSock->SetKeepNick(false); - PutStatusNotice("Set KeepNick to false"); - } - } } else if (sCommand.CaseCmp("USER") == 0) { if (!IsAttached()) { if (m_sUser.empty()) { @@ -593,22 +576,7 @@ void CClient::ReadLine(const CString& sData) { } void CClient::SetNick(const CString& s) { - m_sNick = s; - - if (m_pUser) { - if (m_sNick.CaseCmp(m_pUser->GetNick()) == 0) { - m_uKeepNickCounter = 0; - } - } -} - -bool CClient::DecKeepNickCounter() { - if (!m_uKeepNickCounter) { - return false; - } - - m_uKeepNickCounter--; - return true; + m_sNick = s; } void CClient::StatusCTCP(const CString& sLine) { diff --git a/Client.h b/Client.h index 24b247cf..6849e46a 100644 --- a/Client.h +++ b/Client.h @@ -84,7 +84,6 @@ public: m_bGotUser = false; m_bNamesx = false; m_bUHNames = false; - m_uKeepNickCounter = 0; EnableReadLine(); } @@ -98,7 +97,6 @@ public: bool HasNamesx() const { return m_bNamesx; } bool HasUHNames() const { return m_bUHNames; } - bool DecKeepNickCounter(); void UserCommand(const CString& sCommand); void StatusCTCP(const CString& sCommand); void IRCConnected(CIRCSock* pIRCSock); @@ -138,7 +136,6 @@ protected: CString m_sPass; CString m_sUser; CIRCSock* m_pIRCSock; - unsigned int m_uKeepNickCounter; CSmartPtr m_spAuth; CClientTimeout* m_pTimeout; }; diff --git a/IRCSock.cpp b/IRCSock.cpp index 7ea96403..6fa08142 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -16,9 +16,7 @@ CIRCSock::CIRCSock(CUser* pUser) : Csock() { m_pUser = pUser; m_bISpoofReleased = false; - m_bKeepNick = true; m_bAuthed = false; - m_bOrigNickPending = false; m_bNamesx = false; m_bUHNames = false; EnableReadLine(); @@ -181,22 +179,6 @@ void CIRCSock::ReadLine(const CString& sData) { if (sNick == "*") { SendAltNick(sBadNick); return; - } else { - // :irc.server.net 433 mynick badnick :Nickname is already in use. - if ((m_bKeepNick) && (m_pUser->GetKeepNick())) { - if (sBadNick.CaseCmp(sConfNick) == 0) { - vector& vClients = m_pUser->GetClients(); - - for (unsigned int a = 0; a < vClients.size(); a++) { - CClient* pClient = vClients[a]; - - if (!pClient || !pClient->DecKeepNickCounter()) { - SetOrigNickPending(false); - return; - } - } - } - } } break; } @@ -369,8 +351,6 @@ void CIRCSock::ReadLine(const CString& sData) { // We are changing our own nick, the clients always must see this! bIsVisible = true; SetNick(sNewNick); - } else if (Nick.GetNick().CaseCmp(m_pUser->GetNick()) == 0) { - KeepNick(true); } MODULECALL(OnNick(Nick, sNewNick, vFoundChans), m_pUser, NULL, ); @@ -407,10 +387,6 @@ void CIRCSock::ReadLine(const CString& sData) { } } - if (Nick.GetNick().CaseCmp(m_pUser->GetNick()) == 0) { - KeepNick(true); - } - MODULECALL(OnQuit(Nick, sMessage, vFoundChans), m_pUser, NULL, ); if (!bIsVisible) { @@ -649,15 +625,6 @@ void CIRCSock::ReadLine(const CString& sData) { m_pUser->PutUser(sLine); } -void CIRCSock::KeepNick(bool bForce) { - const CString& sConfNick = m_pUser->GetNick(); - - if (m_bAuthed && m_bKeepNick && (!IsOrigNickPending() || bForce) && m_pUser->GetKeepNick() && GetNick().CaseCmp(sConfNick) != 0) { - PutIRC("NICK " + sConfNick); - SetOrigNickPending(true); - } -} - bool CIRCSock::OnCTCPReply(CNick& Nick, CString& sMessage) { MODULECALL(OnCTCPReply(Nick, sMessage), m_pUser, NULL, return true); diff --git a/IRCSock.h b/IRCSock.h index 70153868..50dddf27 100644 --- a/IRCSock.h +++ b/IRCSock.h @@ -47,19 +47,15 @@ public: virtual void SockError(int iErrno); virtual void Timeout(); - void KeepNick(bool bForce = false); void PutIRC(const CString& sLine); void ResetChans(); void Quit(); // 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 - bool GetKeepNick() const { return m_bKeepNick; } unsigned int GetMaxNickLen() const { return m_uMaxNickLen; } EChanModeArgs GetModeType(unsigned char uMode) const; unsigned char GetPermFromMode(unsigned char uMode) const; @@ -71,7 +67,6 @@ 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; } CUser* GetUser() const { return m_pUser; } bool HasNamesx() const { return m_bNamesx; } bool HasUHNames() const { return m_bUHNames; } @@ -88,8 +83,6 @@ private: protected: bool m_bISpoofReleased; bool m_bAuthed; - bool m_bKeepNick; - bool m_bOrigNickPending; bool m_bNamesx; bool m_bUHNames; CString m_sPerms; diff --git a/Timers.h b/Timers.h index f3be49ab..2f2e445d 100644 --- a/Timers.h +++ b/Timers.h @@ -13,35 +13,6 @@ #include "IRCSock.h" #include "User.h" -class CKeepNickTimer : public CCron { -public: - CKeepNickTimer(CUser* pUser) : CCron() { - m_pUser = pUser; - m_uTrys = 0; - SetName("CKeepNickTimer::" + m_pUser->GetUserName()); - Start(5); - } - virtual ~CKeepNickTimer() {} - -private: -protected: - virtual void RunJob() { - CIRCSock* pSock = m_pUser->GetIRCSock(); - - if (pSock) { - if (m_uTrys++ >= 40) { - pSock->SetOrigNickPending(false); - m_uTrys = 0; - } - - pSock->KeepNick(); - } - } - - CUser* m_pUser; - unsigned int m_uTrys; -}; - class CMiscTimer : public CCron { public: CMiscTimer(CUser* pUser) : CCron() { diff --git a/User.cpp b/User.cpp index 90b80f01..b743d3a1 100644 --- a/User.cpp +++ b/User.cpp @@ -34,7 +34,6 @@ CUser::CUser(const CString& sUserName) { m_bBounceDCCs = true; m_bPassHashed = false; m_bUseClientIP = false; - m_bKeepNick = false; m_bDenyLoadMod = false; m_bAdmin= false; m_bDenySetVHost= false; @@ -49,10 +48,8 @@ CUser::CUser(const CString& sUserName) { m_bAppendTimestamp = false; m_bPrependTimestamp = true; m_bIRCConnectEnabled = true; - m_pKeepNickTimer = new CKeepNickTimer(this); m_pJoinTimer = new CJoinTimer(this); m_pMiscTimer = new CMiscTimer(this); - CZNC::Get().GetManager().AddCron(m_pKeepNickTimer); CZNC::Get().GetManager().AddCron(m_pJoinTimer); CZNC::Get().GetManager().AddCron(m_pMiscTimer); m_sUserPath = CZNC::Get().GetUserPath() + "/" + sUserName; @@ -72,7 +69,6 @@ CUser::~CUser() { delete m_vChans[b]; } - CZNC::Get().GetManager().DelCronByAddr(m_pKeepNickTimer); CZNC::Get().GetManager().DelCronByAddr(m_pJoinTimer); CZNC::Get().GetManager().DelCronByAddr(m_pMiscTimer); } @@ -424,7 +420,6 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneChans) { // Flags SetKeepBuffer(User.KeepBuffer()); SetAutoCycle(User.AutoCycle()); - SetKeepNick(User.GetKeepNick()); SetMultiClients(User.MultiClients()); SetBounceDCCs(User.BounceDCCs()); SetUseClientIP(User.UseClientIP()); @@ -579,7 +574,6 @@ bool CUser::WriteConfig(CFile& File) { PrintLine(File, "StatusPrefix", GetStatusPrefix()); PrintLine(File, "ChanModes", GetDefaultChanModes()); PrintLine(File, "Buffer", CString(GetBufferCount())); - PrintLine(File, "KeepNick", CString((GetKeepNick()) ? "true" : "false")); PrintLine(File, "KeepBuffer", CString((KeepBuffer()) ? "true" : "false")); PrintLine(File, "MultiClients", CString((MultiClients()) ? "true" : "false")); PrintLine(File, "BounceDCCs", CString((BounceDCCs()) ? "true" : "false")); @@ -1028,7 +1022,6 @@ void CUser::SetPass(const CString& s, bool bHashed, const CString& sSalt) { void CUser::SetMultiClients(bool b) { m_bMultiClients = b; } void CUser::SetBounceDCCs(bool b) { m_bBounceDCCs = b; } void CUser::SetUseClientIP(bool b) { m_bUseClientIP = b; } -void CUser::SetKeepNick(bool b) { m_bKeepNick = b; } void CUser::SetDenyLoadMod(bool b) { m_bDenyLoadMod = b; } void CUser::SetAdmin(bool b) { m_bAdmin = b; } void CUser::SetDenySetVHost(bool b) { m_bDenySetVHost = b; } @@ -1100,7 +1093,6 @@ bool CUser::ConnectPaused() { } bool CUser::UseClientIP() const { return m_bUseClientIP; } -bool CUser::GetKeepNick() const { return m_bKeepNick; } bool CUser::DenyLoadMod() const { return m_bDenyLoadMod; } bool CUser::IsAdmin() const { return m_bAdmin; } bool CUser::DenySetVHost() const { return m_bDenySetVHost; } diff --git a/User.h b/User.h index 7d4c3741..d0b06a14 100644 --- a/User.h +++ b/User.h @@ -26,7 +26,6 @@ class CChan; class CClient; class CIRCSock; class CJoinTimer; -class CKeepNickTimer; class CMiscTimer; class CServer; @@ -123,7 +122,6 @@ public: void SetBounceDCCs(bool b); void SetMultiClients(bool b); void SetUseClientIP(bool b); - void SetKeepNick(bool b); void SetDenyLoadMod(bool b); void SetAdmin(bool b); void SetDenySetVHost(bool b); @@ -173,7 +171,6 @@ public: const CString& GetDLPath() const { if (!CFile::Exists(m_sDLPath)) { CDir::MakeDir(m_sDLPath); } return m_sDLPath; } bool UseClientIP() const; - bool GetKeepNick() const; bool DenyLoadMod() const; bool IsAdmin() const; bool DenySetVHost() const; @@ -231,7 +228,6 @@ protected: bool m_bBounceDCCs; bool m_bPassHashed; bool m_bUseClientIP; - bool m_bKeepNick; bool m_bDenyLoadMod; bool m_bAdmin; bool m_bDenySetVHost; @@ -243,7 +239,6 @@ protected: bool m_bIRCConnectEnabled; CIRCSock* m_pIRCSock; - CKeepNickTimer* m_pKeepNickTimer; CJoinTimer* m_pJoinTimer; CMiscTimer* m_pMiscTimer; diff --git a/modules/awaynick.cpp b/modules/awaynick.cpp index 16821f17..0706c3ac 100644 --- a/modules/awaynick.cpp +++ b/modules/awaynick.cpp @@ -59,14 +59,6 @@ public: SetNV("nick", m_sFormat); - if (m_pUser->GetKeepNick()) { - sMessage = "KeepNick disabled"; - PutModule("You have KeepNick enabled. " - "This won't work together with awaynick."); - PutModule("Disabling KeepNick for you..."); - m_pUser->SetKeepNick(false); - } - return true; } @@ -103,11 +95,6 @@ public: } virtual void OnUserAttached() { - if (m_pUser->GetKeepNick()) { - PutModule("WARNING: You have KeepNick enabled. " - "This won't work with awaynick."); - } - StartBackNickTimer(); } diff --git a/modules/webadmin.cpp b/modules/webadmin.cpp index d083be9d..4b4927b2 100644 --- a/modules/webadmin.cpp +++ b/modules/webadmin.cpp @@ -893,11 +893,6 @@ bool CWebAdminSock::UserPage(CString& sPageRet, CUser* pUser) { o2["DisplayName"] = "Auto Cycle"; if (!pUser || pUser->AutoCycle()) { o2["Checked"] = "true"; } - CTemplate& o3 = m_Template.AddRow("OptionLoop"); - o3["Name"] = "keepnick"; - o3["DisplayName"] = "Keep Nick"; - if (!pUser || pUser->GetKeepNick()) { o3["Checked"] = "true"; } - CTemplate& o4 = m_Template.AddRow("OptionLoop"); o4["Name"] = "multiclients"; o4["DisplayName"] = "Multi Clients"; @@ -1115,7 +1110,6 @@ CUser* CWebAdminSock::GetNewUser(CString& sPageRet, CUser* pUser) { pNewUser->SetMultiClients(GetParam("multiclients").ToBool()); pNewUser->SetBounceDCCs(GetParam("bouncedccs").ToBool()); pNewUser->SetAutoCycle(GetParam("autocycle").ToBool()); - pNewUser->SetKeepNick(GetParam("keepnick").ToBool()); pNewUser->SetUseClientIP(GetParam("useclientip").ToBool()); pNewUser->SetTimestampAppend(GetParam("appendtimestamp").ToBool()); pNewUser->SetTimestampPrepend(GetParam("prependtimestamp").ToBool()); diff --git a/znc.conf b/znc.conf index c8638ad3..6b3617fd 100644 --- a/znc.conf +++ b/znc.conf @@ -50,7 +50,6 @@ StatusPrefix = * QuitMsg = ZNC by prozac - http://znc.sourceforge.net CTCPReply = VERSION ZNC by prozac - http://znc.sourceforge.net ChanModes = +stn - KeepNick = true // You may use multiple Allow lines to restrict access to this user. All connections are denied by default unless they match an ip below. // Note: IPs only! diff --git a/znc.cpp b/znc.cpp index 07fbab26..8250377d 100644 --- a/znc.cpp +++ b/znc.cpp @@ -691,12 +691,6 @@ bool CZNC::WriteNewConfig(const CString& sConfig) { } // todo: Possibly add motd - if (CUtils::GetBoolInput("Would you like ZNC to keep trying for your primary nick?", false)) { - vsLines.push_back("\tKeepNick = true"); - } else { - vsLines.push_back("\tKeepNick = false"); - } - unsigned int uBufferCount = 0; CUtils::GetNumInput("Number of lines to buffer per channel", uBufferCount, 0, ~0, 50); @@ -1229,7 +1223,9 @@ bool CZNC::DoRehash(CString& sError) pUser->SetRealName(sValue); continue; } else if (sName.CaseCmp("KeepNick") == 0) { - pUser->SetKeepNick((sValue.CaseCmp("true") == 0)); + if (sValue.CaseCmp("true") == 0) { + CUtils::PrintError("WARNING: KeepNick has been deprecated, instead try -> LoadModule = keepnick"); + } continue; } else if (sName.CaseCmp("ChanModes") == 0) { pUser->SetDefaultChanModes(sValue);