diff options
81 files changed, 131 insertions, 289 deletions
diff --git a/include/configreader.h b/include/configreader.h index 6786604b5..0fbf234c3 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -614,3 +614,14 @@ class CoreExport ConfigReaderThread : public Thread void Finish(); bool IsDone() { return done; } }; + +class CoreExport ConfigStatus +{ + public: + User* const srcuser; + + ConfigStatus(User* user = NULL) + : srcuser(user) + { + } +}; diff --git a/include/modules.h b/include/modules.h index d13ff58b0..68044ae89 100644 --- a/include/modules.h +++ b/include/modules.h @@ -250,7 +250,7 @@ enum Priority { PRIORITY_FIRST, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER } enum Implementation { I_BEGIN, - I_OnUserConnect, I_OnUserQuit, I_OnUserDisconnect, I_OnUserJoin, I_OnUserPart, I_OnRehash, + I_OnUserConnect, I_OnUserQuit, I_OnUserDisconnect, I_OnUserJoin, I_OnUserPart, I_OnSendSnotice, I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper, I_OnInfo, I_OnWhois, I_OnUserPreInvite, I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNick, I_OnUserMessage, I_OnMode, I_OnGetServerDescription, I_OnSyncUser, @@ -319,6 +319,13 @@ class CoreExport Module : public classbase, public usecountbase { } + /** This method is called when you should reload module specific configuration: + * on boot, on a /REHASH and on module load. + * @param status The current status, can be inspected for more information; + * also used for reporting configuration errors and warnings. + */ + virtual void ReadConfig(ConfigStatus& status); + /** Returns the version number of a Module. * The method should return a Version object with its version information assigned via * Version::Version @@ -409,14 +416,6 @@ class CoreExport Module : public classbase, public usecountbase */ virtual void OnModuleRehash(User* user, const std::string ¶meter); - /** Called on rehash. - * This method is called after a rehash has completed. You should use it to reload any module - * configuration from the main configuration file. - * @param user The user that performed the rehash, if it was initiated by a user and that user - * is still connected. - */ - virtual void OnRehash(User* user); - /** Called whenever a snotice is about to be sent to a snomask. * snomask and type may both be modified; the message may not. * @param snomask The snomask the message is going to (e.g. 'A') @@ -1191,7 +1190,9 @@ class CoreExport ModuleManager /** Internal unload module hook */ bool CanUnload(Module*); + public: + typedef std::map<std::string, Module*> ModuleMap; /** Event handler hooks. * This needs to be public to be used by FOREACH_MOD and friends. @@ -1353,6 +1354,11 @@ class CoreExport ModuleManager * @return The list of module names */ const std::vector<std::string> GetAllModuleNames(int filter); + + /** Get a map of all loaded modules keyed by their name + * @return A ModuleMap containing all loaded modules + */ + const ModuleMap& GetModules() const { return Modules; } }; /** Do not mess with these functions unless you know the C preprocessor diff --git a/include/typedefs.h b/include/typedefs.h index c38f89d4d..98ea4a0b9 100644 --- a/include/typedefs.h +++ b/include/typedefs.h @@ -25,6 +25,7 @@ class BanCacheManager; class BufferedSocket; class Channel; class Command; +class ConfigStatus; class ConfigTag; class Extensible; class FakeUser; diff --git a/src/commands/cmd_dns.cpp b/src/commands/cmd_dns.cpp index 2b7114128..f97d68783 100644 --- a/src/commands/cmd_dns.cpp +++ b/src/commands/cmd_dns.cpp @@ -798,11 +798,9 @@ class ModuleDNS : public Module void init() { ServerInstance->Modules->AddService(this->manager); - - this->OnRehash(NULL); } - void OnRehash(User* user) + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { std::string oldserver = DNSServer; DNSServer = ServerInstance->Config->ConfValue("dns")->getString("server"); diff --git a/src/commands/cmd_whowas.cpp b/src/commands/cmd_whowas.cpp index 75d1ee8ff..ea1020fbc 100644 --- a/src/commands/cmd_whowas.cpp +++ b/src/commands/cmd_whowas.cpp @@ -231,7 +231,6 @@ class ModuleWhoWas : public Module void init() { ServerInstance->Modules->AddService(cmd); - OnRehash(NULL); } void OnGarbageCollect() @@ -253,7 +252,7 @@ class ModuleWhoWas : public Module return MOD_RES_PASSTHRU; } - void OnRehash(User* user) + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("whowas"); unsigned int NewGroupSize = tag->getInt("groupsize", 10, 0, 10000); diff --git a/src/configreader.cpp b/src/configreader.cpp index 957adc829..a08047678 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -837,7 +837,12 @@ void ConfigReaderThread::Finish() static_cast<ListModeBase*>(*ban)->DoRehash(); Config->ApplyDisabledCommands(Config->DisabledCommands); User* user = ServerInstance->FindNick(TheUserUID); - FOREACH_MOD(OnRehash, (user)); + + ConfigStatus status(user); + const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules(); + for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i) + i->second->ReadConfig(status); + ServerInstance->ISupport.Build(); ServerInstance->Logs->CloseLogs(); diff --git a/src/listmode.cpp b/src/listmode.cpp index fb76beab2..a377f19e3 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -92,7 +92,6 @@ void ListModeBase::DoRehash() void ListModeBase::DoImplements(Module* m) { ServerInstance->Modules->AddService(extItem); - this->DoRehash(); } unsigned int ListModeBase::FindLimit(const std::string& channame) diff --git a/src/modmanager_dynamic.cpp b/src/modmanager_dynamic.cpp index 750a1c448..64d2bf69c 100644 --- a/src/modmanager_dynamic.cpp +++ b/src/modmanager_dynamic.cpp @@ -74,8 +74,11 @@ bool ModuleManager::Load(const std::string& filename, bool defer) } else { + ConfigStatus confstatus; + AttachAll(newmod); newmod->init(); + newmod->ReadConfig(confstatus); Version v = newmod->GetVersion(); ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "New module introduced: %s (Module version %s)%s", @@ -228,6 +231,8 @@ void ModuleManager::LoadAll() } } + ConfigStatus confstatus; + for(std::map<std::string, Module*>::iterator i = Modules.begin(); i != Modules.end(); i++) { Module* mod = i->second; @@ -236,6 +241,7 @@ void ModuleManager::LoadAll() ServerInstance->Logs->Log("MODULE", LOG_DEBUG, "Initializing %s", i->first.c_str()); AttachAll(mod); mod->init(); + mod->ReadConfig(confstatus); } catch (CoreException& modexcept) { diff --git a/src/modmanager_static.cpp b/src/modmanager_static.cpp index 321bf520d..eeb8b6f96 100644 --- a/src/modmanager_static.cpp +++ b/src/modmanager_static.cpp @@ -102,8 +102,11 @@ bool ModuleManager::Load(const std::string& name, bool defer) } else { + ConfigStatus confstatus; + AttachAll(mod); mod->init(); + mod->ReadConfig(confstatus); } } catch (CoreException& modexcept) @@ -203,6 +206,8 @@ void ModuleManager::LoadAll() } } + ConfigStatus confstatus; + for(std::map<std::string, Module*>::iterator i = Modules.begin(); i != Modules.end(); i++) { Module* mod = i->second; @@ -210,6 +215,7 @@ void ModuleManager::LoadAll() { AttachAll(mod); mod->init(); + mod->ReadConfig(confstatus); } catch (CoreException& modexcept) { diff --git a/src/modules.cpp b/src/modules.cpp index 47c994088..d581b76a5 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -81,6 +81,7 @@ void Module::DetachEvent(Implementation i) ServerInstance->Modules->Detach(i, this); } +void Module::ReadConfig(ConfigStatus& status) { } ModResult Module::OnSendSnotice(char &snomask, std::string &type, const std::string &message) { DetachEvent(I_OnSendSnotice); return MOD_RES_PASSTHRU; } void Module::OnUserConnect(LocalUser*) { DetachEvent(I_OnUserConnect); } void Module::OnUserQuit(User*, const std::string&, const std::string&) { DetachEvent(I_OnUserQuit); } @@ -90,7 +91,6 @@ void Module::OnPostJoin(Membership*) { DetachEvent(I_OnPostJoin); } void Module::OnUserPart(Membership*, std::string&, CUList&) { DetachEvent(I_OnUserPart); } void Module::OnPreRehash(User*, const std::string&) { DetachEvent(I_OnPreRehash); } void Module::OnModuleRehash(User*, const std::string&) { DetachEvent(I_OnModuleRehash); } -void Module::OnRehash(User*) { DetachEvent(I_OnRehash); } ModResult Module::OnUserPreJoin(LocalUser*, Channel*, const std::string&, std::string&, const std::string&) { DetachEvent(I_OnUserPreJoin); return MOD_RES_PASSTHRU; } void Module::OnMode(User*, User*, Channel*, const std::vector<std::string>&, const std::vector<TranslateType>&) { DetachEvent(I_OnMode); } void Module::OnOper(User*, const std::string&) { DetachEvent(I_OnOper); } diff --git a/src/modules/extra/m_ldapauth.cpp b/src/modules/extra/m_ldapauth.cpp index 517a6d395..827179f84 100644 --- a/src/modules/extra/m_ldapauth.cpp +++ b/src/modules/extra/m_ldapauth.cpp @@ -122,7 +122,6 @@ public: { ServerInstance->Modules->AddService(ldapAuthed); ServerInstance->Modules->AddService(ldapVhost); - OnRehash(NULL); } ~ModuleLDAPAuth() @@ -131,7 +130,7 @@ public: ldap_unbind_ext(conn, NULL, NULL); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("ldapauth"); whitelistedcidrs.clear(); diff --git a/src/modules/extra/m_ldapoper.cpp b/src/modules/extra/m_ldapoper.cpp index af7b48d07..67ba9a7e5 100644 --- a/src/modules/extra/m_ldapoper.cpp +++ b/src/modules/extra/m_ldapoper.cpp @@ -97,18 +97,13 @@ public: { } - void init() CXX11_OVERRIDE - { - OnRehash(NULL); - } - ~ModuleLDAPAuth() { if (conn) ldap_unbind_ext(conn, NULL, NULL); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("ldapoper"); diff --git a/src/modules/extra/m_mssql.cpp b/src/modules/extra/m_mssql.cpp index e6bac038c..84e02be98 100644 --- a/src/modules/extra/m_mssql.cpp +++ b/src/modules/extra/m_mssql.cpp @@ -779,7 +779,7 @@ class ModuleMsSQL : public Module connections.clear(); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { queryDispatcher->LockQueue(); ReadConf(); diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 2d20a82ab..3aed09416 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -108,7 +108,7 @@ class ModuleSQL : public Module ModuleSQL(); void init() CXX11_OVERRIDE; ~ModuleSQL(); - void OnRehash(User* user) CXX11_OVERRIDE; + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE; void OnUnloadModule(Module* mod) CXX11_OVERRIDE; Version GetVersion() CXX11_OVERRIDE; }; @@ -381,8 +381,6 @@ void ModuleSQL::init() { Dispatcher = new DispatcherThread(this); ServerInstance->Threads->Start(Dispatcher); - - OnRehash(NULL); } ModuleSQL::~ModuleSQL() @@ -399,7 +397,7 @@ ModuleSQL::~ModuleSQL() } } -void ModuleSQL::OnRehash(User* user) +void ModuleSQL::ReadConfig(ConfigStatus& status) { ConnMap conns; ConfigTagList tags = ServerInstance->Config->ConfTags("database"); diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 2300c9d5b..1ed5be6f0 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -508,18 +508,13 @@ class ModulePgSQL : public Module { } - void init() CXX11_OVERRIDE - { - ReadConf(); - } - ~ModulePgSQL() { delete retimer; ClearAllConnections(); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ReadConf(); } diff --git a/src/modules/extra/m_regex_posix.cpp b/src/modules/extra/m_regex_posix.cpp index 935cdbf92..bde5c3947 100644 --- a/src/modules/extra/m_regex_posix.cpp +++ b/src/modules/extra/m_regex_posix.cpp @@ -79,7 +79,6 @@ class ModuleRegexPOSIX : public Module ModuleRegexPOSIX() : ref(this) { ServerInstance->Modules->AddService(ref); - OnRehash(NULL); } Version GetVersion() CXX11_OVERRIDE @@ -87,7 +86,7 @@ class ModuleRegexPOSIX : public Module return Version("Regex Provider Module for POSIX Regular Expressions", VF_VENDOR); } - void OnRehash(User* u) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ref.extended = ServerInstance->Config->ConfValue("posix")->getBool("extended"); } diff --git a/src/modules/extra/m_regex_stdlib.cpp b/src/modules/extra/m_regex_stdlib.cpp index 5ec358d58..2f75a60a8 100644 --- a/src/modules/extra/m_regex_stdlib.cpp +++ b/src/modules/extra/m_regex_stdlib.cpp @@ -62,7 +62,6 @@ public: ModuleRegexStd() : ref(this) { ServerInstance->Modules->AddService(ref); - OnRehash(NULL); } Version GetVersion() CXX11_OVERRIDE @@ -70,7 +69,7 @@ public: return Version("Regex Provider Module for std::regex", VF_VENDOR); } - void OnRehash(User* u) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* Conf = ServerInstance->Config->ConfValue("stdregex"); std::string regextype = Conf->getString("type", "ecmascript"); diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp index 54a2788eb..1c213e8e0 100644 --- a/src/modules/extra/m_sqlite3.cpp +++ b/src/modules/extra/m_sqlite3.cpp @@ -202,11 +202,6 @@ class ModuleSQLite3 : public Module ConnMap conns; public: - void init() CXX11_OVERRIDE - { - ReadConf(); - } - ~ModuleSQLite3() { ClearConns(); @@ -223,7 +218,7 @@ class ModuleSQLite3 : public Module conns.clear(); } - void ReadConf() + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ClearConns(); ConfigTagList tags = ServerInstance->Config->ConfTags("database"); @@ -237,11 +232,6 @@ class ModuleSQLite3 : public Module } } - void OnRehash(User* user) CXX11_OVERRIDE - { - ReadConf(); - } - Version GetVersion() CXX11_OVERRIDE { return Version("sqlite3 provider", VF_VENDOR); diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 53fc38ec0..9f21d6d28 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -638,7 +638,7 @@ class ModuleSSLGnuTLS : public Module ServerInstance->Modules->AddService(starttls); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { sslports.clear(); @@ -687,7 +687,6 @@ class ModuleSSLGnuTLS : public Module std::string certfile; std::string cafile; std::string crlfile; - OnRehash(user); ConfigTag* Conf = ServerInstance->Config->ConfValue("gnutls"); diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 29c3568ef..0957b5912 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -502,7 +502,7 @@ class ModuleSSLOpenSSL : public Module } } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { sslports.clear(); @@ -550,7 +550,6 @@ class ModuleSSLOpenSSL : public Module std::string certfile; std::string cafile; std::string dhfile; - OnRehash(user); ConfigTag* conf = ServerInstance->Config->ConfValue("openssl"); diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 4d942854c..7d2eabd15 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -69,7 +69,8 @@ class ModuleAlias : public Module bool AllowBots; UserModeReference botmode; - void ReadAliases() + public: + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* fantasy = ServerInstance->Config->ConfValue("fantasy"); AllowBots = fantasy->getBool("allowbots", false); @@ -96,17 +97,11 @@ class ModuleAlias : public Module } } - public: ModuleAlias() : botmode(this, "bot") { } - void init() CXX11_OVERRIDE - { - ReadAliases(); - } - Version GetVersion() CXX11_OVERRIDE { return Version("Provides aliases of commands.", VF_VENDOR); @@ -369,11 +364,6 @@ class ModuleAlias : public Module ServerInstance->Parser->CallHandler(command, pars, user); } - void OnRehash(User* user) CXX11_OVERRIDE - { - ReadAliases(); - } - void Prioritize() { // Prioritise after spanningtree so that channel aliases show the alias before the effects. diff --git a/src/modules/m_auditorium.cpp b/src/modules/m_auditorium.cpp index af828c130..00227c66e 100644 --- a/src/modules/m_auditorium.cpp +++ b/src/modules/m_auditorium.cpp @@ -54,11 +54,9 @@ class ModuleAuditorium : public Module void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(aum); - - OnRehash(NULL); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("auditorium"); OpsVisible = tag->getBool("opvisible"); diff --git a/src/modules/m_autoop.cpp b/src/modules/m_autoop.cpp index 6bc5f464c..32e097188 100644 --- a/src/modules/m_autoop.cpp +++ b/src/modules/m_autoop.cpp @@ -127,7 +127,7 @@ class ModuleAutoOp : public Module mh.DoSyncChannel(chan, proto, opaque); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { mh.DoRehash(); } diff --git a/src/modules/m_banexception.cpp b/src/modules/m_banexception.cpp index e142af0de..ad4244945 100644 --- a/src/modules/m_banexception.cpp +++ b/src/modules/m_banexception.cpp @@ -117,7 +117,7 @@ class ModuleBanException : public Module be.DoSyncChannel(chan, proto, opaque); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { be.DoRehash(); } diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp index b71247d71..963f94fc2 100644 --- a/src/modules/m_blockamsg.cpp +++ b/src/modules/m_blockamsg.cpp @@ -59,7 +59,6 @@ class ModuleBlockAmsg : public Module void init() CXX11_OVERRIDE { - this->OnRehash(NULL); ServerInstance->Modules->AddService(blockamsg); } @@ -68,7 +67,7 @@ class ModuleBlockAmsg : public Module return Version("Attempt to block /amsg, at least some of the irritating mIRC scripts.",VF_VENDOR); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("blockamsg"); ForgetDelay = tag->getInt("delay", -1); diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp index f80c6d16d..c3c8b2297 100644 --- a/src/modules/m_blockcaps.cpp +++ b/src/modules/m_blockcaps.cpp @@ -45,7 +45,6 @@ public: void init() CXX11_OVERRIDE { - OnRehash(NULL); ServerInstance->Modules->AddService(bc); } @@ -54,11 +53,6 @@ public: tokens["EXTBAN"].push_back('B'); } - void OnRehash(User* user) CXX11_OVERRIDE - { - ReadConf(); - } - ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if (target_type == TYPE_CHANNEL) @@ -101,7 +95,7 @@ public: return MOD_RES_PASSTHRU; } - void ReadConf() + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("blockcaps"); percent = tag->getInt("percent", 100, 1, 100); diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 3d2394fb1..de74773ad 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -363,8 +363,6 @@ public: void init() CXX11_OVERRIDE { - OnRehash(NULL); - ServerInstance->Modules->AddService(myumode); ServerInstance->Modules->AddService(cmd); ServerInstance->Modules->AddService(cmd.extInfo); @@ -427,7 +425,7 @@ public: RemoveFromAllAccepts(user); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("callerid"); cmd.maxaccepts = tag->getInt("maxaccepts", 16); diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index 747c16d83..fe0321ab1 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -55,9 +55,6 @@ class ModuleCensor : public Module void init() CXX11_OVERRIDE { - /* Read the configuration file on startup. - */ - OnRehash(NULL); ServerInstance->Modules->AddService(cu); ServerInstance->Modules->AddService(cc); } @@ -103,7 +100,7 @@ class ModuleCensor : public Module return MOD_RES_PASSTHRU; } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { /* * reload our config file on rehash - we must destroy and re-allocate the classes diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index 2352fa217..9fbc77850 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -236,12 +236,11 @@ public: void init() CXX11_OVERRIDE { - OnRehash(NULL); ServiceProvider* providerlist[] = { &cmd, &cmd.realhost, &cmd.realip, &cmd.webirc_hostname, &cmd.webirc_ip, &waiting }; ServerInstance->Modules->AddServices(providerlist, sizeof(providerlist)/sizeof(ServiceProvider*)); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { cmd.Hosts.clear(); diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp index 38ee14e60..3a7ad9057 100644 --- a/src/modules/m_chanfilter.cpp +++ b/src/modules/m_chanfilter.cpp @@ -80,11 +80,9 @@ class ModuleChanFilter : public Module ServerInstance->Modules->AddService(cf); cf.DoImplements(this); - - OnRehash(NULL); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { hidemask = ServerInstance->Config->ConfValue("chanfilter")->getBool("hidemask"); cf.DoRehash(); diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp index f1f9ed614..0e0841f67 100644 --- a/src/modules/m_chanhistory.cpp +++ b/src/modules/m_chanhistory.cpp @@ -118,11 +118,9 @@ class ModuleChanHistory : public Module { ServerInstance->Modules->AddService(m); ServerInstance->Modules->AddService(m.ext); - - OnRehash(NULL); } - void OnRehash(User*) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("chanhistory"); m.maxlines = tag->getInt("maxlines", 50); diff --git a/src/modules/m_chanlog.cpp b/src/modules/m_chanlog.cpp index dc5750ba6..736285be8 100644 --- a/src/modules/m_chanlog.cpp +++ b/src/modules/m_chanlog.cpp @@ -29,12 +29,7 @@ class ModuleChanLog : public Module ChanLogTargets logstreams; public: - void init() CXX11_OVERRIDE - { - OnRehash(NULL); - } - - void OnRehash(User *user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { std::string snomasks; std::string channel; diff --git a/src/modules/m_channames.cpp b/src/modules/m_channames.cpp index fcb2ef6d7..8b050df2b 100644 --- a/src/modules/m_channames.cpp +++ b/src/modules/m_channames.cpp @@ -62,7 +62,6 @@ class ModuleChannelNames : public Module void init() CXX11_OVERRIDE { ServerInstance->IsChannel = &myhandler; - OnRehash(NULL); } void ValidateChans() @@ -102,7 +101,7 @@ class ModuleChannelNames : public Module badchan = false; } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("channames"); std::string denyToken = tag->getString("denyrange"); diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp index 664508301..4d8223d13 100644 --- a/src/modules/m_chghost.cpp +++ b/src/modules/m_chghost.cpp @@ -96,11 +96,10 @@ class ModuleChgHost : public Module void init() CXX11_OVERRIDE { - OnRehash(NULL); ServerInstance->Modules->AddService(cmd); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { std::string hmap = ServerInstance->Config->ConfValue("hostname")->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789"); diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index 4e203d14c..bef4e94b8 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -148,8 +148,6 @@ class ModuleCloaking : public Module void init() CXX11_OVERRIDE { - OnRehash(NULL); - ServerInstance->Modules->AddService(cu); ServerInstance->Modules->AddService(ck); ServerInstance->Modules->AddService(cu.ext); @@ -331,7 +329,7 @@ class ModuleCloaking : public Module return Version("Provides masking of user hostnames", VF_COMMON|VF_VENDOR, testcloak); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("cloak"); prefix = tag->getString("prefix"); diff --git a/src/modules/m_conn_waitpong.cpp b/src/modules/m_conn_waitpong.cpp index c15205df3..76f41c4bf 100644 --- a/src/modules/m_conn_waitpong.cpp +++ b/src/modules/m_conn_waitpong.cpp @@ -39,10 +39,9 @@ class ModuleWaitPong : public Module void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(ext); - OnRehash(NULL); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("waitpong"); sendsnotice = tag->getBool("sendsnotice", true); diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index 227373a36..39639927c 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -29,17 +29,12 @@ class ModuleConnectBan : public Module unsigned int ipv6_cidr; public: - void init() CXX11_OVERRIDE - { - OnRehash(NULL); - } - Version GetVersion() CXX11_OVERRIDE { return Version("Throttles the connections of IP ranges who try to connect flood.", VF_VENDOR); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("connectban"); diff --git a/src/modules/m_connflood.cpp b/src/modules/m_connflood.cpp index 23b570bf6..2ab906e27 100644 --- a/src/modules/m_connflood.cpp +++ b/src/modules/m_connflood.cpp @@ -36,17 +36,12 @@ public: { } - void init() CXX11_OVERRIDE - { - InitConf(); - } - Version GetVersion() CXX11_OVERRIDE { return Version("Connection throttle", VF_VENDOR); } - void InitConf() + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { /* read configuration variables */ ConfigTag* tag = ServerInstance->Config->ConfValue("connflood"); @@ -109,12 +104,6 @@ public: } return MOD_RES_PASSTHRU; } - - void OnRehash(User* user) CXX11_OVERRIDE - { - InitConf(); - } - }; MODULE_INIT(ModuleConnFlood) diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index d65537537..169ba7203 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -258,12 +258,6 @@ class ModuleDCCAllow : public Module ext = new SimpleExtItem<dccallowlist>("dccallow", this); ServerInstance->Modules->AddService(*ext); ServerInstance->Modules->AddService(cmd); - ReadFileConf(); - } - - void OnRehash(User* user) CXX11_OVERRIDE - { - ReadFileConf(); } void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) CXX11_OVERRIDE @@ -453,7 +447,7 @@ class ModuleDCCAllow : public Module } } - void ReadFileConf() + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { bfl.clear(); ConfigTagList tags = ServerInstance->Config->ConfTags("banfile"); diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp index 2e07aea41..3fdd2533e 100644 --- a/src/modules/m_deaf.cpp +++ b/src/modules/m_deaf.cpp @@ -56,11 +56,9 @@ class ModuleDeaf : public Module void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(m1); - - OnRehash(NULL); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("deaf"); deaf_bypasschars = tag->getString("bypasschars"); diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp index 237447ac7..34b2fedd5 100644 --- a/src/modules/m_denychans.cpp +++ b/src/modules/m_denychans.cpp @@ -32,7 +32,7 @@ class ModuleDenyChannels : public Module { } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { /* check for redirect validity and loops/chains */ ConfigTagList tags = ServerInstance->Config->ConfTags("badchan"); @@ -46,8 +46,8 @@ class ModuleDenyChannels : public Module if (!ServerInstance->IsChannel(redirect)) { - if (user) - user->WriteNotice("Invalid badchan redirect '" + redirect + "'"); + if (status.srcuser) + status.srcuser->WriteNotice("Invalid badchan redirect '" + redirect + "'"); throw ModuleException("Invalid badchan redirect, not a channel"); } @@ -66,8 +66,8 @@ class ModuleDenyChannels : public Module if (!goodchan) { /* <badchan:redirect> is a badchan */ - if (user) - user->WriteNotice("Badchan " + name + " redirects to badchan " + redirect); + if (status.srcuser) + status.srcuser->WriteNotice("Badchan " + name + " redirects to badchan " + redirect); throw ModuleException("Badchan redirect loop"); } } diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 3c9d64d49..a785678b5 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -231,7 +231,6 @@ class ModuleDNSBL : public Module void init() CXX11_OVERRIDE { - ReadConf(); ServerInstance->Modules->AddService(nameExt); ServerInstance->Modules->AddService(countExt); } @@ -243,7 +242,7 @@ class ModuleDNSBL : public Module /** Fill our conf vector with data */ - void ReadConf() + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { DNSBLConfEntries.clear(); @@ -315,11 +314,6 @@ class ModuleDNSBL : public Module } } - void OnRehash(User* user) CXX11_OVERRIDE - { - ReadConf(); - } - void OnSetUserIP(LocalUser* user) CXX11_OVERRIDE { if ((user->exempt) || (user->client_sa.sa.sa_family != AF_INET) || !DNS) diff --git a/src/modules/m_exemptchanops.cpp b/src/modules/m_exemptchanops.cpp index a74658bcd..57057c411 100644 --- a/src/modules/m_exemptchanops.cpp +++ b/src/modules/m_exemptchanops.cpp @@ -117,8 +117,6 @@ class ModuleExemptChanOps : public Module { ServerInstance->Modules->AddService(eh.ec); ServerInstance->OnCheckExemption = &eh; - - OnRehash(NULL); } ~ModuleExemptChanOps() @@ -131,7 +129,7 @@ class ModuleExemptChanOps : public Module return Version("Provides the ability to allow channel operators to be exempt from certain modes.",VF_VENDOR); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { eh.ec.DoRehash(); } diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index d60dd7942..ec75ebebb 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -183,7 +183,7 @@ class ModuleFilter : public Module FilterResult* FilterMatch(User* user, const std::string &text, int flags); bool DeleteFilter(const std::string &freeform); std::pair<bool, std::string> AddFilter(const std::string &freeform, FilterAction type, const std::string &reason, long duration, const std::string &flags); - void OnRehash(User* user) CXX11_OVERRIDE; + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE; Version GetVersion() CXX11_OVERRIDE; std::string EncodeFilter(FilterResult* filter); FilterResult DecodeFilter(const std::string &data); @@ -301,7 +301,6 @@ ModuleFilter::ModuleFilter() void ModuleFilter::init() { ServerInstance->Modules->AddService(filtcommand); - OnRehash(NULL); } CullResult ModuleFilter::cull() @@ -451,7 +450,7 @@ ModResult ModuleFilter::OnPreCommand(std::string &command, std::vector<std::stri return MOD_RES_PASSTHRU; } -void ModuleFilter::OnRehash(User* user) +void ModuleFilter::ReadConfig(ConfigStatus& status) { ConfigTagList tags = ServerInstance->Config->ConfTags("exemptfromfilter"); exemptfromfilter.clear(); diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp index 7d7e9663a..6259636ce 100644 --- a/src/modules/m_helpop.cpp +++ b/src/modules/m_helpop.cpp @@ -108,12 +108,11 @@ class ModuleHelpop : public Module void init() CXX11_OVERRIDE { - ReadConfig(); ServerInstance->Modules->AddService(ho); ServerInstance->Modules->AddService(cmd); } - void ReadConfig() + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { helpop_map.clear(); @@ -146,11 +145,6 @@ class ModuleHelpop : public Module } - void OnRehash(User* user) CXX11_OVERRIDE - { - ReadConfig(); - } - void OnWhois(User* src, User* dst) CXX11_OVERRIDE { if (dst->IsModeSet(ho)) diff --git a/src/modules/m_hidechans.cpp b/src/modules/m_hidechans.cpp index 1bf87bd14..1bf6c1866 100644 --- a/src/modules/m_hidechans.cpp +++ b/src/modules/m_hidechans.cpp @@ -40,7 +40,6 @@ class ModuleHideChans : public Module void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(hm); - OnRehash(NULL); } Version GetVersion() CXX11_OVERRIDE @@ -48,7 +47,7 @@ class ModuleHideChans : public Module return Version("Provides support for hiding channels with user mode +I", VF_VENDOR); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { AffectsOpers = ServerInstance->Config->ConfValue("hidechans")->getBool("affectsopers"); } diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp index 74c58b22a..d0e44b394 100644 --- a/src/modules/m_hostchange.cpp +++ b/src/modules/m_hostchange.cpp @@ -51,12 +51,7 @@ class ModuleHostChange : public Module std::string MySeparator; public: - void init() CXX11_OVERRIDE - { - OnRehash(NULL); - } - - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* host = ServerInstance->Config->ConfValue("host"); MySuffix = host->getString("suffix"); diff --git a/src/modules/m_httpd_acl.cpp b/src/modules/m_httpd_acl.cpp index 272316440..74d25deba 100644 --- a/src/modules/m_httpd_acl.cpp +++ b/src/modules/m_httpd_acl.cpp @@ -49,7 +49,7 @@ class ModuleHTTPAccessList : public Module { } - void OnRehash(User* user) + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { acl_list.clear(); ConfigTagList acls = ServerInstance->Config->ConfTags("httpdacl"); @@ -93,11 +93,6 @@ class ModuleHTTPAccessList : public Module } } - void init() CXX11_OVERRIDE - { - OnRehash(NULL); - } - void BlockAccess(HTTPRequest* http, int returnval, const std::string &extraheaderkey = "", const std::string &extraheaderval="") { ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "BlockAccess (%d)", returnval); diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index bbd66530e..a9a62fecf 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -279,7 +279,6 @@ class ModuleIdent : public Module void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(ext); - OnRehash(NULL); } Version GetVersion() CXX11_OVERRIDE @@ -287,7 +286,7 @@ class ModuleIdent : public Module return Version("Provides support for RFC1413 ident lookups", VF_VENDOR); } - void OnRehash(User *user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { RequestTimeout = ServerInstance->Config->ConfValue("ident")->getInt("timeout", 5); if (!RequestTimeout) diff --git a/src/modules/m_inviteexception.cpp b/src/modules/m_inviteexception.cpp index 700df27fb..2424808f6 100644 --- a/src/modules/m_inviteexception.cpp +++ b/src/modules/m_inviteexception.cpp @@ -54,8 +54,6 @@ public: void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(ie); - - OnRehash(NULL); ie.DoImplements(this); } @@ -93,7 +91,7 @@ public: ie.DoSyncChannel(chan, proto, opaque); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { invite_bypass_key = ServerInstance->Config->ConfValue("inviteexception")->getBool("bypasskey", true); ie.DoRehash(); diff --git a/src/modules/m_ircv3.cpp b/src/modules/m_ircv3.cpp index f46ae97b4..e8018aea6 100644 --- a/src/modules/m_ircv3.cpp +++ b/src/modules/m_ircv3.cpp @@ -76,12 +76,7 @@ class ModuleIRCv3 : public Module { } - void init() CXX11_OVERRIDE - { - OnRehash(NULL); - } - - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* conf = ServerInstance->Config->ConfValue("ircv3"); accountnotify = conf->getBool("accountnotify", true); diff --git a/src/modules/m_jumpserver.cpp b/src/modules/m_jumpserver.cpp index 81022a907..c8a196832 100644 --- a/src/modules/m_jumpserver.cpp +++ b/src/modules/m_jumpserver.cpp @@ -170,10 +170,11 @@ class ModuleJumpServer : public Module return MOD_RES_PASSTHRU; } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { // Emergency way to unlock - if (!user) js.redirect_new_users = false; + if (!status.srcuser) + js.redirect_new_users = false; } Version GetVersion() CXX11_OVERRIDE diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index 96ea66d7b..79d8cddb6 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -99,11 +99,9 @@ class ModuleKnock : public Module { ServerInstance->Modules->AddService(kn); ServerInstance->Modules->AddService(cmd); - - OnRehash(NULL); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { std::string knocknotify = ServerInstance->Config->ConfValue("knock")->getString("notify"); irc::string notify(knocknotify.c_str()); diff --git a/src/modules/m_lockserv.cpp b/src/modules/m_lockserv.cpp index 8fae86e1e..a31e4d324 100644 --- a/src/modules/m_lockserv.cpp +++ b/src/modules/m_lockserv.cpp @@ -93,10 +93,11 @@ class ModuleLockserv : public Module ServerInstance->Modules->AddService(unlockcommand); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { // Emergency way to unlock - if (!user) locked = false; + if (!status.srcuser) + locked = false; } ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE diff --git a/src/modules/m_maphide.cpp b/src/modules/m_maphide.cpp index 21072c1fc..41de2997d 100644 --- a/src/modules/m_maphide.cpp +++ b/src/modules/m_maphide.cpp @@ -23,12 +23,7 @@ class ModuleMapHide : public Module { std::string url; public: - void init() CXX11_OVERRIDE - { - OnRehash(NULL); - } - - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { url = ServerInstance->Config->ConfValue("security")->getString("maphide"); } diff --git a/src/modules/m_nationalchars.cpp b/src/modules/m_nationalchars.cpp index 99e525398..d65d3b49c 100644 --- a/src/modules/m_nationalchars.cpp +++ b/src/modules/m_nationalchars.cpp @@ -239,8 +239,6 @@ class ModuleNationalChars : public Module national_case_insensitive_map = m_lower; ServerInstance->IsNick = &myhandler; - - OnRehash(NULL); } void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE @@ -248,7 +246,7 @@ class ModuleNationalChars : public Module tokens["CASEMAPPING"] = casemapping; } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("nationalchars"); charset = tag->getString("file"); diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp index 4078e54a4..b9010d330 100644 --- a/src/modules/m_nonicks.cpp +++ b/src/modules/m_nonicks.cpp @@ -38,7 +38,6 @@ class ModuleNoNickChange : public Module void init() CXX11_OVERRIDE { - OnRehash(NULL); ServerInstance->Modules->AddService(nn); } @@ -80,7 +79,7 @@ class ModuleNoNickChange : public Module return MOD_RES_PASSTHRU; } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { override = ServerInstance->Config->ConfValue("nonicks")->getBool("operoverride", false); } diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp index b0c206ab3..83a049480 100644 --- a/src/modules/m_ojoin.cpp +++ b/src/modules/m_ojoin.cpp @@ -128,9 +128,6 @@ class ModuleOjoin : public Module void init() CXX11_OVERRIDE { - /* Load config stuff */ - OnRehash(NULL); - std::string npre = ServerInstance->Config->ConfValue("ojoin")->getString("prefix"); char NPrefix = npre.empty() ? 0 : npre[0]; if (NPrefix && ServerInstance->Modes->FindPrefix(NPrefix)) @@ -157,7 +154,7 @@ class ModuleOjoin : public Module return MOD_RES_PASSTHRU; } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* Conf = ServerInstance->Config->ConfValue("ojoin"); mycommand.notice = Conf->getBool("notice", true); diff --git a/src/modules/m_operjoin.cpp b/src/modules/m_operjoin.cpp index 80bb73ad4..8a5041190 100644 --- a/src/modules/m_operjoin.cpp +++ b/src/modules/m_operjoin.cpp @@ -50,13 +50,7 @@ class ModuleOperjoin : public Module } public: - void init() CXX11_OVERRIDE - { - OnRehash(NULL); - } - - - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("operjoin"); diff --git a/src/modules/m_operlog.cpp b/src/modules/m_operlog.cpp index 42a0e4ecf..0da0c1f20 100644 --- a/src/modules/m_operlog.cpp +++ b/src/modules/m_operlog.cpp @@ -29,7 +29,6 @@ class ModuleOperLog : public Module void init() CXX11_OVERRIDE { ServerInstance->SNO->EnableSnomask('r', "OPERLOG"); - OnRehash(NULL); } Version GetVersion() CXX11_OVERRIDE @@ -37,7 +36,7 @@ class ModuleOperLog : public Module return Version("A module which logs all oper commands to the ircd log at default loglevel.", VF_VENDOR); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { tosnomask = ServerInstance->Config->ConfValue("operlog")->getBool("tosnomask", false); } diff --git a/src/modules/m_opermotd.cpp b/src/modules/m_opermotd.cpp index 1be81e641..543fa6854 100644 --- a/src/modules/m_opermotd.cpp +++ b/src/modules/m_opermotd.cpp @@ -83,7 +83,6 @@ class ModuleOpermotd : public Module void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(cmd); - OnRehash(NULL); } Version GetVersion() CXX11_OVERRIDE @@ -97,7 +96,7 @@ class ModuleOpermotd : public Module cmd.ShowOperMOTD(user); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { cmd.opermotd.clear(); ConfigTag* conf = ServerInstance->Config->ConfValue("opermotd"); diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index e342e7dab..7e0d796d7 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -46,14 +46,12 @@ class ModuleOverride : public Module void init() CXX11_OVERRIDE { - // read our config options (main config file) - OnRehash(NULL); ServerInstance->SNO->EnableSnomask('v', "OVERRIDE"); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { - // re-read our config options on a rehash + // re-read our config options ConfigTag* tag = ServerInstance->Config->ConfValue("override"); NoisyOverride = tag->getBool("noisy"); RequireKey = tag->getBool("requirekey"); diff --git a/src/modules/m_passforward.cpp b/src/modules/m_passforward.cpp index 7f3cb6421..589fc06a6 100644 --- a/src/modules/m_passforward.cpp +++ b/src/modules/m_passforward.cpp @@ -24,17 +24,12 @@ class ModulePassForward : public Module std::string nickrequired, forwardmsg, forwardcmd; public: - void init() CXX11_OVERRIDE - { - OnRehash(NULL); - } - Version GetVersion() CXX11_OVERRIDE { return Version("Sends server password to NickServ", VF_VENDOR); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("passforward"); nickrequired = tag->getString("nick", "NickServ"); diff --git a/src/modules/m_password_hash.cpp b/src/modules/m_password_hash.cpp index 4f7d9e449..c8532e2ff 100644 --- a/src/modules/m_password_hash.cpp +++ b/src/modules/m_password_hash.cpp @@ -82,9 +82,6 @@ class ModuleOperHash : public Module void init() CXX11_OVERRIDE { - /* Read the config file first */ - OnRehash(NULL); - ServerInstance->Modules->AddService(cmd); } diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index a19a184e0..ec04c7a45 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -169,8 +169,6 @@ public: void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(p); - - OnRehash(NULL); } CullResult cull() @@ -199,7 +197,7 @@ public: return Module::cull(); } - void OnRehash(User *user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("permchanneldb"); permchannelsconf = tag->getString("filename"); diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp index 43f7065b5..4a8574a6a 100644 --- a/src/modules/m_remove.cpp +++ b/src/modules/m_remove.cpp @@ -206,7 +206,6 @@ class ModuleRemove : public Module { ServerInstance->Modules->AddService(cmd1); ServerInstance->Modules->AddService(cmd2); - OnRehash(NULL); } void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE @@ -214,7 +213,7 @@ class ModuleRemove : public Module tokens["REMOVE"]; } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { supportnokicks = ServerInstance->Config->ConfValue("remove")->getBool("supportnokicks"); } diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index 4591d8ad2..6ba65a767 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -352,10 +352,9 @@ class RepeatModule : public Module ServerInstance->Modules->AddService(rm); ServerInstance->Modules->AddService(rm.ChanSet); ServerInstance->Modules->AddService(rm.MemberInfoExt); - rm.ReadConfig(); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { rm.ReadConfig(); } diff --git a/src/modules/m_restrictchans.cpp b/src/modules/m_restrictchans.cpp index 21686add3..dcdd8a8a8 100644 --- a/src/modules/m_restrictchans.cpp +++ b/src/modules/m_restrictchans.cpp @@ -26,7 +26,8 @@ class ModuleRestrictChans : public Module { std::set<irc::string> allowchans; - void ReadConfig() + public: + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { allowchans.clear(); ConfigTagList tags = ServerInstance->Config->ConfTags("allowchannel"); @@ -38,17 +39,6 @@ class ModuleRestrictChans : public Module } } - public: - void init() CXX11_OVERRIDE - { - ReadConfig(); - } - - void OnRehash(User* user) CXX11_OVERRIDE - { - ReadConfig(); - } - ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven) CXX11_OVERRIDE { irc::string x(cname.c_str()); diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index 7a65947d3..01d8b753a 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -223,8 +223,6 @@ class ModuleRLine : public Module void init() CXX11_OVERRIDE { - OnRehash(NULL); - ServerInstance->Modules->AddService(r); ServerInstance->XLines->RegisterFactory(&f); } @@ -254,7 +252,7 @@ class ModuleRLine : public Module return MOD_RES_PASSTHRU; } - void OnRehash(User *user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("rline"); diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index 8b6d4ed85..1ef1fa073 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -256,8 +256,6 @@ class ModuleSASL : public Module void init() CXX11_OVERRIDE { - OnRehash(NULL); - ServiceProvider* providelist[] = { &auth, &sasl, &authExt }; ServerInstance->Modules->AddServices(providelist, 3); @@ -265,7 +263,7 @@ class ModuleSASL : public Module ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "WARNING: m_services_account.so and m_cap.so are not loaded! m_sasl.so will NOT function correctly until these two modules are loaded!"); } - void OnRehash(User*) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { sasl_target = ServerInstance->Config->ConfValue("sasl")->getString("target", "*"); } diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index cfafd4f05..9e1aeea1a 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -27,17 +27,12 @@ class ModuleSecureList : public Module time_t WaitTime; public: - void init() CXX11_OVERRIDE - { - OnRehash(NULL); - } - Version GetVersion() CXX11_OVERRIDE { return Version("Disallows /LIST for recently connected clients to hinder spam bots", VF_VENDOR); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { allowlist.clear(); diff --git a/src/modules/m_sethost.cpp b/src/modules/m_sethost.cpp index fb9fd7f1f..80953ee6f 100644 --- a/src/modules/m_sethost.cpp +++ b/src/modules/m_sethost.cpp @@ -76,11 +76,10 @@ class ModuleSetHost : public Module void init() CXX11_OVERRIDE { - OnRehash(NULL); ServerInstance->Modules->AddService(cmd); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { std::string hmap = ServerInstance->Config->ConfValue("hostname")->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789"); diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index dbc1812c7..b5d579d00 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -181,8 +181,6 @@ class ModuleShun : public Module { ServerInstance->XLines->RegisterFactory(&f); ServerInstance->Modules->AddService(cmd); - - OnRehash(NULL); } ~ModuleShun() @@ -206,7 +204,7 @@ class ModuleShun : public Module return MOD_RES_DENY; } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("shun"); std::string cmds = tag->getString("enabledcommands"); diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index b6cb897e7..c17cd8e36 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -301,13 +301,12 @@ class ModuleSilence : public Module void init() CXX11_OVERRIDE { - OnRehash(NULL); ServerInstance->Modules->AddService(cmdsilence); ServerInstance->Modules->AddService(cmdsvssilence); ServerInstance->Modules->AddService(cmdsilence.ext); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { maxsilence = ServerInstance->Config->ConfValue("showwhois")->getInt("maxentries", 32); if (!maxsilence) diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 9ece3c03d..1e59e1607 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -618,7 +618,7 @@ void ModuleSpanningTree::OnPreRehash(User* user, const std::string ¶meter) } } -void ModuleSpanningTree::OnRehash(User* user) +void ModuleSpanningTree::ReadConfig(ConfigStatus& status) { // Re-read config stuff try @@ -633,7 +633,7 @@ void ModuleSpanningTree::OnRehash(User* user) std::string msg = "Error in configuration: "; msg.append(e.GetReason()); ServerInstance->SNO->WriteToSnoMask('l', msg); - if (user && !IS_LOCAL(user)) + if (status.srcuser && !IS_LOCAL(status.srcuser)) ServerInstance->PI->SendSNONotice("L", msg); } } diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index f03a36db2..10f698f22 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -142,7 +142,7 @@ class ModuleSpanningTree : public Module void OnUserPostNick(User* user, const std::string &oldnick) CXX11_OVERRIDE; void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts) CXX11_OVERRIDE; void OnPreRehash(User* user, const std::string ¶meter) CXX11_OVERRIDE; - void OnRehash(User* user) CXX11_OVERRIDE; + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE; void OnOper(User* user, const std::string &opertype) CXX11_OVERRIDE; void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason); void OnAddLine(User *u, XLine *x) CXX11_OVERRIDE; diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 40db1339c..0ec0a57f9 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -131,8 +131,6 @@ SpanningTreeUtilities::SpanningTreeUtilities(ModuleSpanningTree* C) : Creator(C), TreeRoot(NULL) { ServerInstance->Timers->AddTimer(&RefreshTimer); - - this->ReadConfiguration(); } CullResult SpanningTreeUtilities::cull() diff --git a/src/modules/m_sqlauth.cpp b/src/modules/m_sqlauth.cpp index ba969e54d..fe65d2805 100644 --- a/src/modules/m_sqlauth.cpp +++ b/src/modules/m_sqlauth.cpp @@ -84,10 +84,9 @@ class ModuleSQLAuth : public Module void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(pendingExt); - OnRehash(NULL); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* conf = ServerInstance->Config->ConfValue("sqlauth"); std::string dbid = conf->getString("dbid"); diff --git a/src/modules/m_sqloper.cpp b/src/modules/m_sqloper.cpp index 295f4aa94..fb5b65e56 100644 --- a/src/modules/m_sqloper.cpp +++ b/src/modules/m_sqloper.cpp @@ -111,12 +111,7 @@ class ModuleSQLOper : public Module public: ModuleSQLOper() : SQL(this, "SQL") {} - void init() CXX11_OVERRIDE - { - OnRehash(NULL); - } - - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("sqloper"); diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index 94f53c164..be1dcfc91 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -376,13 +376,12 @@ class Modulewatch : public Module void init() CXX11_OVERRIDE { - OnRehash(NULL); ServerInstance->Modules->AddService(cmdw); ServerInstance->Modules->AddService(sw); ServerInstance->Modules->AddService(cmdw.ext); } - void OnRehash(User* user) CXX11_OVERRIDE + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { maxwatch = ServerInstance->Config->ConfValue("watch")->getInt("maxentries", 32); if (!maxwatch) diff --git a/src/modules/m_xline_db.cpp b/src/modules/m_xline_db.cpp index 63eb6d3ee..d482dca2b 100644 --- a/src/modules/m_xline_db.cpp +++ b/src/modules/m_xline_db.cpp @@ -31,7 +31,7 @@ class ModuleXLineDB : public Module { /* Load the configuration * Note: - * this is on purpose not in the OnRehash() method. It would be non-trivial to change the database on-the-fly. + * This is on purpose not changed on a rehash. It would be non-trivial to change the database on-the-fly. * Imagine a scenario where the new file already exists. Merging the current XLines with the existing database is likely a bad idea * ...and so is discarding all current in-memory XLines for the ones in the database. */ |