From d0a38e41ab7f8878dc43fa9ac33290e72aa678be Mon Sep 17 00:00:00 2001 From: psychon Date: Sat, 26 Sep 2009 14:49:15 +0000 Subject: [PATCH] Add a new module hook OnIRCConnecting This hook is called just before some user tries to connect() to an IRC server. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1638 726aef4b-f618-498e-8847-2d620e286838 --- Modules.cpp | 2 ++ Modules.h | 3 +++ znc.cpp | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/Modules.cpp b/Modules.cpp index b82938ad..40d4d9fb 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -484,6 +484,7 @@ void CModule::OnPreRehash() {} void CModule::OnPostRehash() {} void CModule::OnIRCDisconnected() {} void CModule::OnIRCConnected() {} +CModule::EModRet CModule::OnIRCConnecting(CIRCSock *IRCSock) { return CONTINUE; } CModule::EModRet CModule::OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName) { return CONTINUE; } CModule::EModRet CModule::OnBroadcast(CString& sMessage) { return CONTINUE; } @@ -624,6 +625,7 @@ bool CModules::OnBoot() { bool CModules::OnPreRehash() { MODUNLOADCHK(OnPreRehash()); return false; } bool CModules::OnPostRehash() { MODUNLOADCHK(OnPostRehash()); return false; } bool CModules::OnIRCConnected() { MODUNLOADCHK(OnIRCConnected()); return false; } +bool CModules::OnIRCConnecting(CIRCSock *pIRCSock) { MODHALTCHK(OnIRCConnecting(pIRCSock)); } bool CModules::OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName) { MODHALTCHK(OnIRCRegistration(sPass, sNick, sIdent, sRealName)); } bool CModules::OnBroadcast(CString& sMessage) { MODHALTCHK(OnBroadcast(sMessage)); } bool CModules::OnIRCDisconnected() { MODUNLOADCHK(OnIRCDisconnected()); return false; } diff --git a/Modules.h b/Modules.h index e1a03f80..344d5bac 100644 --- a/Modules.h +++ b/Modules.h @@ -24,6 +24,7 @@ using std::set; class CAuthBase; class CChan; class CClient; +class CIRCSock; // !Forward Declarations // User Module Macros @@ -239,6 +240,7 @@ public: virtual void OnPostRehash(); virtual void OnIRCDisconnected(); virtual void OnIRCConnected(); + virtual EModRet OnIRCConnecting(CIRCSock *pIRCSock); virtual EModRet OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName); virtual EModRet OnBroadcast(CString& sMessage); @@ -399,6 +401,7 @@ public: bool OnPostRehash(); bool OnIRCDisconnected(); bool OnIRCConnected(); + bool OnIRCConnecting(CIRCSock *pIRCSock); bool OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName); bool OnBroadcast(CString& sMessage); diff --git a/znc.cpp b/znc.cpp index 2468d1e0..e7a9329f 100644 --- a/znc.cpp +++ b/znc.cpp @@ -165,6 +165,13 @@ bool CZNC::ConnectUser(CUser *pUser) { } #endif + MODULECALL(OnIRCConnecting(pIRCSock), pUser, NULL, + DEBUG("Some module aborted the connection attempt"); + ReleaseISpoof(); + delete pIRCSock; + return false; + ); + if (!m_Manager.Connect(pServer->GetName(), pServer->GetPort(), sSockName, 120, bSSL, pUser->GetVHost(), pIRCSock)) { ReleaseISpoof(); pUser->PutStatus("Unable to connect. (Bad host?)");