diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-16 22:50:51 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-16 22:50:51 +0000 |
commit | 31c75f6ef553b899d7916d88f2f10ae67ff285fb (patch) | |
tree | 051de45d0beed9be83da503e255cc72f27fdc45a /src/modules | |
parent | 3841c4b04a96389a4661535d12d5215a621d8736 (diff) |
Add support for zline on rline [jackmcbarn]
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11736 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_rline.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index 3b8aacb3f..b792ef4fb 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -17,6 +17,8 @@ static Module* rxengine = NULL; static Module* mymodule = NULL; /* Needed to let RLine send request! */ +static bool ZlineOnMatch = false; +static std::vector<ZLine *> background_zlines; /* $ModDesc: RLINE: Regexp user banning. */ @@ -72,6 +74,9 @@ class RLine : public XLine void Apply(User* u) { + if (ZlineOnMatch) { + background_zlines.push_back(new ZLine(ServerInstance, ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, ServerInstance->Config->ServerName, reason.c_str(), u->GetIPString())); + } DefaultApply(u, "R", true); } @@ -208,8 +213,8 @@ class ModuleRLine : public Module ServerInstance->AddCommand(&r); ServerInstance->XLines->RegisterFactory(&f); - Implementation eventlist[] = { I_OnUserConnect, I_OnRehash, I_OnUserPostNick, I_OnLoadModule, I_OnStats }; - ServerInstance->Modules->Attach(eventlist, this, 5); + Implementation eventlist[] = { I_OnUserConnect, I_OnRehash, I_OnUserPostNick, I_OnLoadModule, I_OnStats, I_OnBackgroundTimer }; + ServerInstance->Modules->Attach(eventlist, this, 6); } @@ -241,7 +246,11 @@ class ModuleRLine : public Module { ConfigReader Conf(ServerInstance); + if (!Conf.ReadFlag("rline", "zlineonmatch", 0) && ZlineOnMatch) + background_zlines.clear(); + MatchOnNickChange = Conf.ReadFlag("rline", "matchonnickchange", 0); + ZlineOnMatch = Conf.ReadFlag("rline", "zlineonmatch", 0); std::string newrxengine = Conf.ReadValue("rline", "engine", 0); if (!RegexEngine.empty()) @@ -311,6 +320,22 @@ class ModuleRLine : public Module } } + virtual void OnBackgroundTimer(time_t curtime) + { + if (!ZlineOnMatch) return; + for (std::vector<ZLine *>::iterator i = background_zlines.begin(); i != background_zlines.end(); i++) + { + ZLine *zl = *i; + if (ServerInstance->XLines->AddLine(zl,NULL)) + { + ServerInstance->SNO->WriteToSnoMask('x',"Z-line added due to R-line match on *@%s%s%s: %s", + zl->ipaddr.c_str(), zl->duration ? " to expire on " : "", zl->duration ? ServerInstance->TimeString(zl->expiry).c_str() : "", zl->reason.c_str()); + ServerInstance->XLines->ApplyLines(); + } + } + background_zlines.clear(); + } + }; MODULE_INIT(ModuleRLine) |