Skip to content

Commit

Permalink
Fix to allow for OnRehash to know what user initiated the rehash
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6207 e03df62e-2008-0410-955e-edbf42e46eb7
  • Loading branch information
braindigitalis committed Jan 1, 2007
1 parent 8a0a8ce commit 42d5b95
Show file tree
Hide file tree
Showing 47 changed files with 80 additions and 80 deletions.
6 changes: 4 additions & 2 deletions include/modules.h
Expand Up @@ -75,7 +75,7 @@ enum MessageType {
* ipv4 servers, so this value will be ten times as
* high on ipv6 servers.
*/
#define NATIVE_API_VERSION 11009
#define NATIVE_API_VERSION 11010
#ifdef IPV6
#define API_VERSION (NATIVE_API_VERSION * 10)
#else
Expand Down Expand Up @@ -518,9 +518,11 @@ class Module : public Extensible
* system. You should use it to reload any files so that your module keeps in step with the
* rest of the application. If a parameter is given, the core has done nothing. The module
* receiving the event can decide if this parameter has any relevence to it.
* @param user The user performing the rehash, if any -- if this is server initiated, the
* value of this variable will be NULL.
* @param parameter The (optional) parameter given to REHASH from the user.
*/
virtual void OnRehash(const std::string &parameter);
virtual void OnRehash(userrec* user, const std::string &parameter);

/** Called when a raw command is transmitted or received.
* This method is the lowest level of handler available to a module. It will be called with raw
Expand Down
2 changes: 1 addition & 1 deletion src/cmd_rehash.cpp
Expand Up @@ -45,7 +45,7 @@ CmdResult cmd_rehash::Handle (const char** parameters, int pcnt, userrec *user)
if (old_disabled != ServerInstance->Config->DisabledCommands)
InitializeDisabledCommands(ServerInstance->Config->DisabledCommands, ServerInstance);

FOREACH_MOD(I_OnRehash,OnRehash(parameter));
FOREACH_MOD(I_OnRehash,OnRehash(user, parameter));

return CMD_SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion src/inspircd.cpp
Expand Up @@ -144,7 +144,7 @@ void InspIRCd::Rehash(int status)
FOREACH_MOD_I(SI, I_OnGarbageCollect, OnGarbageCollect());
SI->Config->Read(false,NULL);
SI->Res->Rehash();
FOREACH_MOD_I(SI,I_OnRehash,OnRehash(""));
FOREACH_MOD_I(SI,I_OnRehash,OnRehash(NULL,""));
}

/** Because hash_map doesnt free its buckets when we delete items (this is a 'feature')
Expand Down
2 changes: 1 addition & 1 deletion src/modules.cpp
Expand Up @@ -109,7 +109,7 @@ void Module::OnUserDisconnect(userrec* user) { }
void Module::OnUserJoin(userrec* user, chanrec* channel) { }
void Module::OnPostJoin(userrec* user, chanrec* channel) { }
void Module::OnUserPart(userrec* user, chanrec* channel, const std::string &partmessage) { }
void Module::OnRehash(const std::string &parameter) { }
void Module::OnRehash(userrec* user, const std::string &parameter) { }
void Module::OnServerRaw(std::string &raw, bool inbound, userrec* user) { }
int Module::OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs) { return 0; }
void Module::OnMode(userrec* user, void* dest, int target_type, const std::string &text) { };
Expand Down
4 changes: 2 additions & 2 deletions src/modules/extra/m_filter_pcre.cpp
Expand Up @@ -47,7 +47,7 @@ class ModuleFilterPCRE : public FilterBase
ModuleFilterPCRE(InspIRCd* Me)
: FilterBase::FilterBase(Me, "m_filter_pcre.so")
{
OnRehash("");
OnRehash(NULL,"");
}

virtual ~ModuleFilterPCRE()
Expand Down Expand Up @@ -115,7 +115,7 @@ class ModuleFilterPCRE : public FilterBase
}
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
ConfigReader MyConf(ServerInstance);

Expand Down
2 changes: 1 addition & 1 deletion src/modules/extra/m_mysql.cpp
Expand Up @@ -826,7 +826,7 @@ class ModuleSQL : public Module
return NULL;
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
/* TODO: set rehash bool here, which makes the dispatcher thread rehash at next opportunity */
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/extra/m_pgsql.cpp
Expand Up @@ -1079,7 +1079,7 @@ class ModulePgSQL : public Module
List[I_OnUnloadModule] = List[I_OnRequest] = List[I_OnRehash] = List[I_OnUserRegister] = List[I_OnCheckReady] = List[I_OnUserDisconnect] = 1;
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
ReadConf();
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/extra/m_sqlauth.cpp
Expand Up @@ -50,7 +50,7 @@ class ModuleSQLAuth : public Module
if (!SQLutils)
throw ModuleException("Can't find m_sqlutils.so. Please load m_sqlutils.so before m_sqlauth.so.");

OnRehash("");
OnRehash(NULL,"");
}

virtual ~ModuleSQLAuth()
Expand All @@ -64,7 +64,7 @@ class ModuleSQLAuth : public Module
List[I_OnUserDisconnect] = List[I_OnCheckReady] = List[I_OnRequest] = List[I_OnRehash] = List[I_OnUserRegister] = 1;
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
ConfigReader Conf(Srv);

Expand Down
4 changes: 2 additions & 2 deletions src/modules/extra/m_sqllog.cpp
Expand Up @@ -194,7 +194,7 @@ class ModuleSQLLog : public Module

SQLModule = Srv->FindFeature("SQL");

OnRehash("");
OnRehash(NULL,"");
MyMod = this;
active_queries.clear();
}
Expand All @@ -218,7 +218,7 @@ class ModuleSQLLog : public Module
dbid = Conf.ReadValue("sqllog","dbid",0); // database id of a database configured in sql module
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
ReadConfig();
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/extra/m_sqloper.cpp
Expand Up @@ -42,7 +42,7 @@ class ModuleSQLOper : public Module
if (!SQLutils)
throw ModuleException("Can't find m_sqlutils.so. Please load m_sqlutils.so before m_sqloper.so.");

OnRehash("");
OnRehash(NULL,"");
}

virtual ~ModuleSQLOper()
Expand All @@ -56,7 +56,7 @@ class ModuleSQLOper : public Module
List[I_OnRequest] = List[I_OnRehash] = List[I_OnPreCommand] = 1;
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
ConfigReader Conf(Srv);

Expand Down
4 changes: 2 additions & 2 deletions src/modules/extra/m_ssl_gnutls.cpp
Expand Up @@ -106,13 +106,13 @@ class ModuleSSLGnuTLS : public Module
ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Failed to initialise DH parameters");

// Needs the flag as it ignores a plain /rehash
OnRehash("ssl");
OnRehash(NULL,"ssl");

// Void return, guess we assume success
gnutls_certificate_set_dh_params(x509_cred, dh_params);
}

virtual void OnRehash(const std::string &param)
virtual void OnRehash(userrec* user, const std::string &param)
{
if(param != "ssl")
return;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/extra/m_ssl_openssl.cpp
Expand Up @@ -133,10 +133,10 @@ class ModuleSSLOpenSSL : public Module
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, OnVerify);

// Needs the flag as it ignores a plain /rehash
OnRehash("ssl");
OnRehash(NULL,"ssl");
}

virtual void OnRehash(const std::string &param)
virtual void OnRehash(userrec* user, const std::string &param)
{
if (param != "ssl")
return;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/m_alias.cpp
Expand Up @@ -270,7 +270,7 @@ class ModuleAlias : public Module
}
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
ReadAliases();
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/m_banexception.cpp
Expand Up @@ -108,7 +108,7 @@ class ModuleBanException : public Module
be->DoChannelDelete(chan);
}

virtual void OnRehash(const std::string &param)
virtual void OnRehash(userrec* user, const std::string &param)
{
be->DoRehash();
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/m_blockamsg.cpp
Expand Up @@ -48,7 +48,7 @@ class ModuleBlockAmsg : public Module
ModuleBlockAmsg(InspIRCd* Me) : Module::Module(Me)
{

this->OnRehash("");
this->OnRehash(NULL,"");
}

void Implements(char* List)
Expand All @@ -65,7 +65,7 @@ class ModuleBlockAmsg : public Module
return Version(1,1,0,0,VF_VENDOR,API_VERSION);
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
ConfigReader* Conf = new ConfigReader(ServerInstance);

Expand Down
4 changes: 2 additions & 2 deletions src/modules/m_blockcaps.cpp
Expand Up @@ -59,7 +59,7 @@ class ModuleBlockCAPS : public Module

ModuleBlockCAPS(InspIRCd* Me) : Module::Module(Me)
{
OnRehash("");
OnRehash(NULL,"");
bc = new BlockCaps(ServerInstance);
if (!ServerInstance->AddMode(bc, 'P'))
throw ModuleException("Could not add new modes!");
Expand All @@ -70,7 +70,7 @@ class ModuleBlockCAPS : public Module
List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnRehash] = 1;
}

virtual void OnRehash(const std::string &param)
virtual void OnRehash(userrec* user, const std::string &param)
{
ReadConf();
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/m_censor.cpp
Expand Up @@ -96,7 +96,7 @@ class ModuleCensor : public Module
{
/* Read the configuration file on startup.
*/
OnRehash("");
OnRehash(NULL,"");
cu = new CensorUser(ServerInstance);
cc = new CensorChannel(ServerInstance);
if (!ServerInstance->AddMode(cu, 'G') || !ServerInstance->AddMode(cc, 'G'))
Expand Down Expand Up @@ -159,7 +159,7 @@ class ModuleCensor : public Module
return OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
/*
* reload our config file on rehash - we must destroy and re-allocate the classes
Expand Down
4 changes: 2 additions & 2 deletions src/modules/m_cgiirc.cpp
Expand Up @@ -91,7 +91,7 @@ class ModuleCgiIRC : public Module
ModuleCgiIRC(InspIRCd* Me) : Module::Module(Me)
{

OnRehash("");
OnRehash(NULL,"");
}

void Implements(char* List)
Expand All @@ -105,7 +105,7 @@ class ModuleCgiIRC : public Module
return PRIORITY_FIRST;
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
ConfigReader Conf(ServerInstance);

Expand Down
2 changes: 1 addition & 1 deletion src/modules/m_chanfilter.cpp
Expand Up @@ -85,7 +85,7 @@ class ModuleChanFilter : public Module
cf->DoChannelDelete(chan);
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
cf->DoRehash();
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/m_chanprotect.cpp
Expand Up @@ -290,7 +290,7 @@ class ModuleChanProtect : public Module
: Module::Module(Me), FirstInGetsFounder(false), QAPrefixes(false), DeprivSelf(false), booting(true)
{
/* Load config stuff */
OnRehash("");
OnRehash(NULL,"");
booting = false;

/* Initialise module variables */
Expand Down Expand Up @@ -321,7 +321,7 @@ class ModuleChanProtect : public Module
user->Shrink("cm_protect_"+std::string(channel->name));
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
/* Create a configreader class and read our flag,
* in old versions this was heap-allocated and the
Expand Down
4 changes: 2 additions & 2 deletions src/modules/m_chghost.cpp
Expand Up @@ -75,7 +75,7 @@ class ModuleChgHost : public Module
ModuleChgHost(InspIRCd* Me)
: Module::Module(Me)
{
OnRehash("");
OnRehash(NULL,"");
mycommand = new cmd_chghost(ServerInstance, hostmap);
ServerInstance->AddCommand(mycommand);
}
Expand All @@ -85,7 +85,7 @@ class ModuleChgHost : public Module
List[I_OnRehash] = 1;
}

void OnRehash(const std::string &parameter)
void OnRehash(userrec* user, const std::string &parameter)
{
ConfigReader Conf(ServerInstance);
std::string hmap = Conf.ReadValue("hostname", "charmap", 0);
Expand Down
4 changes: 2 additions & 2 deletions src/modules/m_cloaking.cpp
Expand Up @@ -241,7 +241,7 @@ class ModuleCloaking : public Module
if (!ServerInstance->AddMode(cu, 'x'))
throw ModuleException("Could not add new modes!");

OnRehash("");
OnRehash(NULL,"");
}

virtual ~ModuleCloaking()
Expand All @@ -258,7 +258,7 @@ class ModuleCloaking : public Module
return Version(1,1,0,2,VF_COMMON|VF_VENDOR,API_VERSION);
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
cu->DoRehash();
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/m_conn_umodes.cpp
Expand Up @@ -40,7 +40,7 @@ class ModuleModesOnConnect : public Module
List[I_OnPostConnect] = List[I_OnRehash] = 1;
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
DELETE(Conf);
Conf = new ConfigReader(ServerInstance);
Expand Down
5 changes: 2 additions & 3 deletions src/modules/m_conn_waitpong.cpp
Expand Up @@ -45,11 +45,10 @@ class ModuleWaitPong : public Module
ModuleWaitPong(InspIRCd* Me)
: Module::Module(Me)
{

OnRehash("");
OnRehash(NULL,"");
}

virtual void OnRehash(const std::string &param)
virtual void OnRehash(userrec* user, const std::string &param)
{
Conf = new ConfigReader(ServerInstance);

Expand Down
2 changes: 1 addition & 1 deletion src/modules/m_connflood.cpp
Expand Up @@ -110,7 +110,7 @@ class ModuleConnFlood : public Module
return 0;
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
InitConf();
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/m_dccallow.cpp
Expand Up @@ -267,7 +267,7 @@ class ModuleDCCAllow : public Module
List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnUserQuit] = List[I_OnUserPreNick] = List[I_OnRehash] = 1;
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
delete Conf;
Conf = new ConfigReader(ServerInstance);
Expand Down
4 changes: 2 additions & 2 deletions src/modules/m_denychans.cpp
Expand Up @@ -34,12 +34,12 @@ class ModuleDenyChannels : public Module
Conf = new ConfigReader(ServerInstance);
}

virtual void OnRehash(const std::string &param)
virtual void OnRehash(userrec* user, const std::string &param)
{
DELETE(Conf);
Conf = new ConfigReader(ServerInstance);
}

virtual ~ModuleDenyChannels()
{
DELETE(Conf);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/m_dnsbl.cpp
Expand Up @@ -266,7 +266,7 @@ class ModuleDNSBL : public Module
delete MyConf;
}

virtual void OnRehash(const std::string &parameter)
virtual void OnRehash(userrec* user, const std::string &parameter)
{
ReadConf();
}
Expand Down

0 comments on commit 42d5b95

Please sign in to comment.