diff --git a/Modules.cpp b/Modules.cpp index 60d1cda1..284be41c 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -24,6 +24,24 @@ } \ } \ +#define GLOBALMODCALL(func) \ + for (unsigned int a = 0; a < size(); a++) { \ + try { \ + CGlobalModule* pMod = (CGlobalModule*) (*this)[a]; \ + if (m_pUser) { \ + pMod->SetUser(m_pUser); \ + pMod->func; \ + pMod->SetUser(NULL); \ + } else { \ + pMod->func; \ + } \ + } catch (CModule::EModException e) { \ + if (e == CModule::UNLOAD) { \ + UnloadModule((*this)[a]->GetModName()); \ + } \ + } \ + } \ + #define GLOBALMODHALTCHK(func) \ bool bHaltCore = false; \ for (unsigned int a = 0; a < size(); a++) { \ @@ -517,6 +535,7 @@ bool CModule::PutModNotice(const CString& sLine, const CString& sIdent, const CS CModule::EModRet CGlobalModule::OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan) { return CONTINUE; } CModule::EModRet CGlobalModule::OnDeleteUser(CUser& User) { return CONTINUE; } CModule::EModRet CGlobalModule::OnLoginAttempt(CSmartPtr Auth) { return CONTINUE; } +void CGlobalModule::OnFailedLogin(const CString& sUsername, const CString& sRemoteIP) {} CModules::CModules() { @@ -605,6 +624,10 @@ bool CGlobalModules::OnLoginAttempt(CSmartPtr Auth) { GLOBALMODHALTCHK(OnLoginAttempt(Auth)); } +void CGlobalModules::OnFailedLogin(const CString& sUsername, const CString& sRemoteIP) { + GLOBALMODCALL(OnFailedLogin(sUsername, sRemoteIP)); +} + CModule* CModules::FindModule(const CString& sModule) const { for (unsigned int a = 0; a < size(); a++) { if (sModule.CaseCmp((*this)[a]->GetModName()) == 0) { diff --git a/Modules.h b/Modules.h index b1829e0f..b6da3ac8 100644 --- a/Modules.h +++ b/Modules.h @@ -392,6 +392,7 @@ public: virtual EModRet OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan); virtual EModRet OnDeleteUser(CUser& User); virtual EModRet OnLoginAttempt(CSmartPtr Auth); + virtual void OnFailedLogin(const CString& sUsername, const CString& sRemoteIP); private: }; @@ -403,6 +404,7 @@ public: virtual bool OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan); virtual bool OnDeleteUser(CUser& User); virtual bool OnLoginAttempt(CSmartPtr Auth); + virtual void OnFailedLogin(const CString& sUsername, const CString& sRemoteIP); private: };