From 31c75f6ef553b899d7916d88f2f10ae67ff285fb Mon Sep 17 00:00:00 2001 From: danieldg Date: Wed, 16 Sep 2009 22:50:51 +0000 Subject: Add support for zline on rline [jackmcbarn] git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11736 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_rline.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/modules') 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 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::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) -- cgit v1.2.3