summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modules/m_spanningtree/main.cpp30
-rw-r--r--src/modules/m_spanningtree/main.h4
-rw-r--r--src/modules/m_spanningtree/utils.cpp42
3 files changed, 55 insertions, 21 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index b391df971..dcd02ba9b 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -49,12 +49,12 @@ ModuleSpanningTree::ModuleSpanningTree(InspIRCd* Me)
{
I_OnPreCommand, I_OnGetServerDescription, I_OnUserInvite, I_OnPostLocalTopicChange,
I_OnWallops, I_OnUserNotice, I_OnUserMessage, I_OnBackgroundTimer,
- I_OnUserJoin, I_OnChangeLocalUserHost, I_OnChangeName, I_OnUserPart,
+ I_OnUserJoin, I_OnChangeLocalUserHost, I_OnChangeName, I_OnUserPart, I_OnUnloadModule,
I_OnUserQuit, I_OnUserPostNick, I_OnUserKick, I_OnRemoteKill, I_OnRehash,
- I_OnOper, I_OnAddLine, I_OnDelLine, I_ProtoSendMode, I_OnMode,
+ I_OnOper, I_OnAddLine, I_OnDelLine, I_ProtoSendMode, I_OnMode, I_OnLoadModule,
I_OnStats, I_ProtoSendMetaData, I_OnEvent, I_OnSetAway, I_OnPostCommand
};
- ServerInstance->Modules->Attach(eventlist, this, 27);
+ ServerInstance->Modules->Attach(eventlist, this, 29);
delete ServerInstance->PI;
ServerInstance->PI = new SpanningTreeProtocolInterface(this, Utils, ServerInstance);
@@ -714,6 +714,30 @@ void ModuleSpanningTree::OnRehash(User* user, const std::string &parameter)
Utils->ReadConfiguration(true);
}
+void ModuleSpanningTree::OnLoadModule(Module* mod, const std::string &name)
+{
+ this->RedoConfig(mod, name);
+}
+
+void ModuleSpanningTree::OnUnloadModule(Module* mod, const std::string &name)
+{
+ this->RedoConfig(mod, name);
+}
+
+void ModuleSpanningTree::RedoConfig(Module* mod, const std::string &name)
+{
+ /* If m_sha256.so is loaded (we use this for HMAC) or any module implementing a BufferedSocket interface is loaded,
+ * then we need to re-read our config again taking this into account.
+ *
+ * We determine if a module supports BufferedSocket simply by sending it the Request for its BufferedSocket name,
+ * and if it responds non-NULL, it implements the interface.
+ */
+ if (name == "m_sha256.so" || BufferedSocketNameRequest((Module*)this, mod).Send() != NULL)
+ {
+ Utils->ReadConfiguration(true);
+ }
+}
+
// note: the protocol does not allow direct umode +o except
// via NICK with 8 params. sending OPERTYPE infers +o modechange
// locally.
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index 830fc9926..1a9c63277 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -49,6 +49,8 @@ class ModuleSpanningTree : public Module
CommandRSQuit* command_rsquit;
SpanningTreeUtilities* Utils;
+ void RedoConfig(Module* mod, const std::string &name);
+
public:
CacheRefreshTimer *RefreshTimer;
@@ -180,6 +182,8 @@ class ModuleSpanningTree : public Module
virtual void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::string &modeline);
virtual void ProtoSendMetaData(void* opaque, TargetTypeFlags target_type, void* target, const std::string &extname, const std::string &extdata);
virtual void OnEvent(Event* event);
+ virtual void OnLoadModule(Module* mod,const std::string &name);
+ virtual void OnUnloadModule(Module* mod,const std::string &name);
virtual ~ModuleSpanningTree();
virtual Version GetVersion();
void Prioritize();
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index b9216ca9a..91b8dd239 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -155,24 +155,6 @@ SpanningTreeUtilities::SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningT
this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc, ServerInstance->Config->GetSID());
- modulelist* ml = ServerInstance->Modules->FindInterface("BufferedSocketHook");
-
- /* Did we find any modules? */
- if (ml)
- {
- /* Yes, enumerate them all to find out the hook name */
- for (modulelist::iterator m = ml->begin(); m != ml->end(); m++)
- {
- /* Make a request to it for its name, its implementing
- * BufferedSocketHook so we know its safe to do this
- */
- std::string name = BufferedSocketNameRequest((Module*)Creator, *m).Send();
- /* Build a map of them */
- hooks[name.c_str()] = *m;
- hooknames.push_back(name);
- }
- }
-
this->ReadConfiguration(true);
}
@@ -449,6 +431,30 @@ void SpanningTreeUtilities::RefreshIPCache()
void SpanningTreeUtilities::ReadConfiguration(bool rebind)
{
ConfigReader* Conf = new ConfigReader(ServerInstance);
+
+ /* We don't need to worry about these being *unloaded* on the fly, only loaded,
+ * because we 'use' the interface locking the module in memory.
+ */
+ hooks.clear();
+ hooknames.clear();
+ modulelist* ml = ServerInstance->Modules->FindInterface("BufferedSocketHook");
+
+ /* Did we find any modules? */
+ if (ml)
+ {
+ /* Yes, enumerate them all to find out the hook name */
+ for (modulelist::iterator m = ml->begin(); m != ml->end(); m++)
+ {
+ /* Make a request to it for its name, its implementing
+ * BufferedSocketHook so we know its safe to do this
+ */
+ std::string name = BufferedSocketNameRequest((Module*)Creator, *m).Send();
+ /* Build a map of them */
+ hooks[name.c_str()] = *m;
+ hooknames.push_back(name);
+ }
+ }
+
if (rebind)
{
for (unsigned int i = 0; i < Bindings.size(); i++)