summaryrefslogtreecommitdiff
path: root/src/modules/m_rline.cpp
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-04-21 18:03:07 +0200
committerattilamolnar <attilamolnar@hush.com>2013-04-21 18:03:07 +0200
commit216877cc5b595b5b6bbc5f953e226618201cc0f6 (patch)
tree5341c63ad1e1baf702ae23cca2dcfb4e2488cd01 /src/modules/m_rline.cpp
parent822f3f13f18b7e79d5740416f9417dabb9296859 (diff)
m_filter, m_rline Remove rlines and filters when the regex engine changes or becomes unavailable
Diffstat (limited to 'src/modules/m_rline.cpp')
-rw-r--r--src/modules/m_rline.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp
index a234c02c6..bbe8ede9a 100644
--- a/src/modules/m_rline.cpp
+++ b/src/modules/m_rline.cpp
@@ -224,9 +224,13 @@ class ModuleRLine : public Module
RLineFactory f;
CommandRLine r;
bool MatchOnNickChange;
+ bool initing;
+ RegexFactory* factory;
public:
- ModuleRLine() : rxfactory(this, "regex"), f(rxfactory), r(this, f)
+ ModuleRLine()
+ : rxfactory(this, "regex"), f(rxfactory), r(this, f)
+ , initing(true)
{
}
@@ -237,7 +241,7 @@ class ModuleRLine : public Module
ServerInstance->Modules->AddService(r);
ServerInstance->XLines->RegisterFactory(&f);
- Implementation eventlist[] = { I_OnUserConnect, I_OnRehash, I_OnUserPostNick, I_OnStats, I_OnBackgroundTimer };
+ Implementation eventlist[] = { I_OnUserConnect, I_OnRehash, I_OnUserPostNick, I_OnStats, I_OnBackgroundTimer, I_OnUnloadModule };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
@@ -272,14 +276,29 @@ class ModuleRLine : public Module
ZlineOnMatch = tag->getBool("zlineonmatch");
std::string newrxengine = tag->getString("engine");
+ factory = rxfactory ? (rxfactory.operator->()) : NULL;
+
if (newrxengine.empty())
rxfactory.SetProvider("regex");
else
rxfactory.SetProvider("regex/" + newrxengine);
+
if (!rxfactory)
{
- ServerInstance->SNO->WriteToSnoMask('a', "WARNING: Regex engine '%s' is not loaded - R-Line functionality disabled until this is corrected.", newrxengine.c_str());
+ if (newrxengine.empty())
+ ServerInstance->SNO->WriteToSnoMask('a', "WARNING: No regex engine loaded - R-Line functionality disabled until this is corrected.");
+ else
+ ServerInstance->SNO->WriteToSnoMask('a', "WARNING: Regex engine '%s' is not loaded - R-Line functionality disabled until this is corrected.", newrxengine.c_str());
+
+ ServerInstance->XLines->DelAll(f.GetType());
}
+ else if ((!initing) && (rxfactory.operator->() != factory))
+ {
+ ServerInstance->SNO->WriteToSnoMask('a', "Regex engine has changed, removing all R-Lines");
+ ServerInstance->XLines->DelAll(f.GetType());
+ }
+
+ initing = false;
}
virtual ModResult OnStats(char symbol, User* user, string_list &results)
@@ -317,6 +336,19 @@ class ModuleRLine : public Module
}
}
+ void OnUnloadModule(Module* mod)
+ {
+ // If the regex engine became unavailable or has changed, remove all rlines
+ if (!rxfactory)
+ {
+ ServerInstance->XLines->DelAll(f.GetType());
+ }
+ else if (rxfactory.operator->() != factory)
+ {
+ factory = rxfactory.operator->();
+ ServerInstance->XLines->DelAll(f.GetType());
+ }
+ }
};
MODULE_INIT(ModuleRLine)