summaryrefslogtreecommitdiff
path: root/src/modules/extra
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-05-24 02:53:45 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-05-24 02:53:45 +0000
commit0da6b3a13def40e8fd002b9fc60f955467f6372d (patch)
treed4aa39ece30255afe7447fb46f39c45c39d679a3 /src/modules/extra
parent5f309503fa985faa5b255246fc0415455c1c65ee (diff)
OnRehash changes: split to multiple hooks to clarify use and prevent explosion of rehashes on a /REHASH *
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11388 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/extra')
-rw-r--r--src/modules/extra/m_geoip.cpp4
-rw-r--r--src/modules/extra/m_ldapauth.cpp4
-rw-r--r--src/modules/extra/m_ldapoper.cpp4
-rw-r--r--src/modules/extra/m_mssql.cpp2
-rw-r--r--src/modules/extra/m_mysql.cpp4
-rw-r--r--src/modules/extra/m_pgsql.cpp2
-rw-r--r--src/modules/extra/m_regex_posix.cpp4
-rw-r--r--src/modules/extra/m_sqlauth.cpp4
-rw-r--r--src/modules/extra/m_sqlite3.cpp2
-rw-r--r--src/modules/extra/m_sqllog.cpp4
-rw-r--r--src/modules/extra/m_sqloper.cpp4
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp60
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp22
-rw-r--r--src/modules/extra/m_ssl_oper_cert.cpp2
14 files changed, 64 insertions, 58 deletions
diff --git a/src/modules/extra/m_geoip.cpp b/src/modules/extra/m_geoip.cpp
index d14bacb16..21a57a283 100644
--- a/src/modules/extra/m_geoip.cpp
+++ b/src/modules/extra/m_geoip.cpp
@@ -31,7 +31,7 @@ class ModuleGeoIP : public Module
public:
ModuleGeoIP(InspIRCd *Me) : Module(Me)
{
- OnRehash(NULL, "");
+ OnRehash(NULL);
Implementation eventlist[] = { I_OnRehash, I_OnUserRegister };
ServerInstance->Modules->Attach(eventlist, this, 2);
@@ -47,7 +47,7 @@ class ModuleGeoIP : public Module
return Version("$Id$", VF_VENDOR, API_VERSION);
}
- virtual void OnRehash(User* user, const std::string &parameter)
+ virtual void OnRehash(User* user)
{
GeoBans.clear();
diff --git a/src/modules/extra/m_ldapauth.cpp b/src/modules/extra/m_ldapauth.cpp
index c4f04ee4a..b95d32b18 100644
--- a/src/modules/extra/m_ldapauth.cpp
+++ b/src/modules/extra/m_ldapauth.cpp
@@ -52,7 +52,7 @@ public:
conn = NULL;
Implementation eventlist[] = { I_OnUserDisconnect, I_OnCheckReady, I_OnRehash, I_OnUserRegister };
ServerInstance->Modules->Attach(eventlist, this, 4);
- OnRehash(NULL,"");
+ OnRehash(NULL);
}
virtual ~ModuleLDAPAuth()
@@ -61,7 +61,7 @@ public:
ldap_unbind_ext(conn, NULL, NULL);
}
- virtual void OnRehash(User* user, const std::string &parameter)
+ virtual void OnRehash(User* user)
{
ConfigReader Conf(ServerInstance);
diff --git a/src/modules/extra/m_ldapoper.cpp b/src/modules/extra/m_ldapoper.cpp
index 68e7ffc28..43525aa4d 100644
--- a/src/modules/extra/m_ldapoper.cpp
+++ b/src/modules/extra/m_ldapoper.cpp
@@ -47,7 +47,7 @@ public:
conn = NULL;
Implementation eventlist[] = { I_OnRehash, I_OnPassCompare };
ServerInstance->Modules->Attach(eventlist, this, 2);
- OnRehash(NULL,"");
+ OnRehash(NULL);
}
virtual ~ModuleLDAPAuth()
@@ -56,7 +56,7 @@ public:
ldap_unbind_ext(conn, NULL, NULL);
}
- virtual void OnRehash(User* user, const std::string &parameter)
+ virtual void OnRehash(User* user)
{
ConfigReader Conf(ServerInstance);
diff --git a/src/modules/extra/m_mssql.cpp b/src/modules/extra/m_mssql.cpp
index 39c6daa81..5fd62f55e 100644
--- a/src/modules/extra/m_mssql.cpp
+++ b/src/modules/extra/m_mssql.cpp
@@ -789,7 +789,7 @@ class ModuleMsSQL : public Module
}
}
- virtual void OnRehash(User* user, const std::string &parameter)
+ virtual void OnRehash(User* user)
{
queryDispatcher->LockQueue();
ReadConf();
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp
index 824a75e46..465992d30 100644
--- a/src/modules/extra/m_mysql.cpp
+++ b/src/modules/extra/m_mysql.cpp
@@ -101,7 +101,7 @@ class ModuleSQL : public Module
~ModuleSQL();
unsigned long NewID();
const char* OnRequest(Request* request);
- void OnRehash(User* user, const std::string &parameter);
+ void OnRehash(User* user);
Version GetVersion();
};
@@ -746,7 +746,7 @@ const char* ModuleSQL::OnRequest(Request* request)
return NULL;
}
-void ModuleSQL::OnRehash(User* user, const std::string &parameter)
+void ModuleSQL::OnRehash(User* user)
{
Dispatcher->LockQueue();
rehashing = true;
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index f353f7575..b417fc019 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -796,7 +796,7 @@ class ModulePgSQL : public Module
}
- virtual void OnRehash(User* user, const std::string &parameter)
+ virtual void OnRehash(User* user)
{
ReadConf();
}
diff --git a/src/modules/extra/m_regex_posix.cpp b/src/modules/extra/m_regex_posix.cpp
index ba653247a..6cf7ec44d 100644
--- a/src/modules/extra/m_regex_posix.cpp
+++ b/src/modules/extra/m_regex_posix.cpp
@@ -81,7 +81,7 @@ public:
Me->Modules->PublishInterface("RegularExpression", this);
Implementation eventlist[] = { I_OnRequest, I_OnRehash };
Me->Modules->Attach(eventlist, this, 2);
- OnRehash(NULL, "");
+ OnRehash(NULL);
}
virtual Version GetVersion()
@@ -94,7 +94,7 @@ public:
ServerInstance->Modules->UnpublishInterface("RegularExpression", this);
}
- virtual void OnRehash(User* u, const std::string& parameter)
+ virtual void OnRehash(User* u)
{
ConfigReader Conf(ServerInstance);
extended = Conf.ReadFlag("posix", "extended", 0);
diff --git a/src/modules/extra/m_sqlauth.cpp b/src/modules/extra/m_sqlauth.cpp
index 8e9d33d58..6dc01a5f8 100644
--- a/src/modules/extra/m_sqlauth.cpp
+++ b/src/modules/extra/m_sqlauth.cpp
@@ -46,7 +46,7 @@ public:
if (!SQLprovider)
throw ModuleException("Can't find an SQL provider module. Please load one before attempting to load m_sqlauth.");
- OnRehash(NULL,"");
+ OnRehash(NULL);
Implementation eventlist[] = { I_OnUserDisconnect, I_OnCheckReady, I_OnRequest, I_OnRehash, I_OnUserRegister };
ServerInstance->Modules->Attach(eventlist, this, 5);
}
@@ -58,7 +58,7 @@ public:
}
- virtual void OnRehash(User* user, const std::string &parameter)
+ virtual void OnRehash(User* user)
{
ConfigReader Conf(ServerInstance);
diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp
index 354f95a5b..548af82cc 100644
--- a/src/modules/extra/m_sqlite3.cpp
+++ b/src/modules/extra/m_sqlite3.cpp
@@ -711,7 +711,7 @@ class ModuleSQLite3 : public Module
}
}
- virtual void OnRehash(User* user, const std::string &parameter)
+ virtual void OnRehash(User* user)
{
ReadConf();
}
diff --git a/src/modules/extra/m_sqllog.cpp b/src/modules/extra/m_sqllog.cpp
index ce67651f7..c952d495e 100644
--- a/src/modules/extra/m_sqllog.cpp
+++ b/src/modules/extra/m_sqllog.cpp
@@ -195,7 +195,7 @@ class ModuleSQLLog : public Module
SQLModule = ServerInstance->Modules->FindFeature("SQL");
- OnRehash(NULL,"");
+ OnRehash(NULL);
MyMod = this;
active_queries.clear();
@@ -217,7 +217,7 @@ class ModuleSQLLog : public Module
dbid = Conf.ReadValue("sqllog","dbid",0); // database id of a database configured in sql module
}
- virtual void OnRehash(User* user, const std::string &parameter)
+ virtual void OnRehash(User* user)
{
ReadConfig();
}
diff --git a/src/modules/extra/m_sqloper.cpp b/src/modules/extra/m_sqloper.cpp
index 56e0a678f..e898165a0 100644
--- a/src/modules/extra/m_sqloper.cpp
+++ b/src/modules/extra/m_sqloper.cpp
@@ -39,7 +39,7 @@ public:
ServerInstance->Modules->UseInterface("SQL");
ServerInstance->Modules->UseInterface("HashRequest");
- OnRehash(NULL, "");
+ OnRehash(NULL);
diduseiface = false;
@@ -112,7 +112,7 @@ public:
}
- virtual void OnRehash(User* user, const std::string &parameter)
+ virtual void OnRehash(User* user)
{
ConfigReader Conf(ServerInstance);
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index c284142a5..88c70f5cc 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -93,11 +93,6 @@ class CommandStartTLS : public Command
class ModuleSSLGnuTLS : public Module
{
-
- ConfigReader* Conf;
-
- char* dummy;
-
std::vector<std::string> listenports;
issl_session* sessions;
@@ -130,35 +125,36 @@ class ModuleSSLGnuTLS : public Module
cred_alloc = false;
// Needs the flag as it ignores a plain /rehash
- OnRehash(NULL,"ssl");
+ OnModuleRehash(NULL,"ssl");
// Void return, guess we assume success
gnutls_certificate_set_dh_params(x509_cred, dh_params);
Implementation eventlist[] = { I_On005Numeric, I_OnRawSocketConnect, I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketRead, I_OnRawSocketWrite, I_OnCleanup,
- I_OnBufferFlushed, I_OnRequest, I_OnSyncUserMetaData, I_OnDecodeMetaData, I_OnUnloadModule, I_OnRehash, I_OnWhois, I_OnPostConnect, I_OnEvent, I_OnHookUserIO };
- ServerInstance->Modules->Attach(eventlist, this, 17);
+ I_OnBufferFlushed, I_OnRequest, I_OnSyncUserMetaData, I_OnDecodeMetaData,
+ I_OnUnloadModule, I_OnRehash, I_OnModuleRehash, I_OnWhois, I_OnPostConnect, I_OnEvent, I_OnHookUserIO };
+ ServerInstance->Modules->Attach(eventlist, this, 18);
starttls = new CommandStartTLS(ServerInstance, this);
ServerInstance->AddCommand(starttls);
}
- virtual void OnRehash(User* user, const std::string &param)
+ virtual void OnRehash(User* user)
{
- Conf = new ConfigReader(ServerInstance);
+ ConfigReader Conf(ServerInstance);
listenports.clear();
clientactive = 0;
sslports.clear();
- for(int index = 0; index < Conf->Enumerate("bind"); index++)
+ for(int index = 0; index < Conf.Enumerate("bind"); index++)
{
// For each <bind> tag
- std::string x = Conf->ReadValue("bind", "type", index);
- if(((x.empty()) || (x == "clients")) && (Conf->ReadValue("bind", "ssl", index) == "gnutls"))
+ std::string x = Conf.ReadValue("bind", "type", index);
+ if(((x.empty()) || (x == "clients")) && (Conf.ReadValue("bind", "ssl", index) == "gnutls"))
{
// Get the port we're meant to be listening on with SSL
- std::string port = Conf->ReadValue("bind", "port", index);
- std::string addr = Conf->ReadValue("bind", "address", index);
+ std::string port = Conf.ReadValue("bind", "port", index);
+ std::string addr = Conf.ReadValue("bind", "address", index);
if (!addr.empty())
{
@@ -195,22 +191,26 @@ class ModuleSSLGnuTLS : public Module
if (!sslports.empty())
sslports.erase(sslports.end() - 1);
+ }
+ virtual void OnModuleRehash(User* user, const std::string &param)
+ {
if(param != "ssl")
- {
- delete Conf;
return;
- }
+
+ OnRehash(user);
+
+ ConfigReader Conf(ServerInstance);
std::string confdir(ServerInstance->ConfigFileName);
// +1 so we the path ends with a /
confdir = confdir.substr(0, confdir.find_last_of('/') + 1);
- cafile = Conf->ReadValue("gnutls", "cafile", 0);
- crlfile = Conf->ReadValue("gnutls", "crlfile", 0);
- certfile = Conf->ReadValue("gnutls", "certfile", 0);
- keyfile = Conf->ReadValue("gnutls", "keyfile", 0);
- dh_bits = Conf->ReadInteger("gnutls", "dhbits", 0, false);
+ cafile = Conf.ReadValue("gnutls", "cafile", 0);
+ crlfile = Conf.ReadValue("gnutls", "crlfile", 0);
+ certfile = Conf.ReadValue("gnutls", "certfile", 0);
+ keyfile = Conf.ReadValue("gnutls", "keyfile", 0);
+ dh_bits = Conf.ReadInteger("gnutls", "dhbits", 0, false);
// Set all the default values needed.
if (cafile.empty())
@@ -272,8 +272,6 @@ class ModuleSSLGnuTLS : public Module
// This may be on a large (once a day or week) timer eventually.
GenerateDHParams();
-
- delete Conf;
}
void GenerateDHParams()
@@ -311,7 +309,7 @@ class ModuleSSLGnuTLS : public Module
ServerInstance->Users->QuitUser(user, "SSL module unloading");
user->DelIOHook();
}
- if (user->GetExt("ssl_cert", dummy))
+ if (user->GetExt("ssl_cert"))
{
ssl_cert* tofree;
user->GetExt("ssl_cert", tofree);
@@ -460,7 +458,7 @@ class ModuleSSLGnuTLS : public Module
EventHandler* user = ServerInstance->SE->GetRef(fd);
- if ((user) && (user->GetExt("ssl_cert", dummy)))
+ if ((user) && (user->GetExt("ssl_cert")))
{
ssl_cert* tofree;
user->GetExt("ssl_cert", tofree);
@@ -611,7 +609,7 @@ class ModuleSSLGnuTLS : public Module
return;
// Bugfix, only send this numeric for *our* SSL users
- if (dest->GetExt("ssl", dummy))
+ if (dest->GetExt("ssl"))
{
ServerInstance->SendWhoisLine(source, dest, 320, "%s %s :is using a secure connection", source->nick.c_str(), dest->nick.c_str());
}
@@ -623,7 +621,7 @@ class ModuleSSLGnuTLS : public Module
if(extname == "ssl")
{
// check if this user has an swhois field to send
- if(user->GetExt(extname, dummy))
+ if(user->GetExt(extname))
{
// call this function in the linking module, let it format the data how it
// sees fit, and send it on its way. We dont need or want to know how.
@@ -639,7 +637,7 @@ class ModuleSSLGnuTLS : public Module
{
User* dest = (User*)target;
// if they dont already have an ssl flag, accept the remote server's
- if (!dest->GetExt(extname, dummy))
+ if (!dest->GetExt(extname))
{
dest->Extend(extname, "ON");
}
@@ -687,7 +685,7 @@ class ModuleSSLGnuTLS : public Module
EventHandler *extendme = ServerInstance->SE->GetRef(fd);
if (extendme)
{
- if (!extendme->GetExt("ssl", dummy))
+ if (!extendme->GetExt("ssl"))
extendme->Extend("ssl", "ON");
}
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index b49d6b0b2..b1172e179 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -149,10 +149,13 @@ class ModuleSSLOpenSSL : public Module
SSL_CTX_set_verify(clictx, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, OnVerify);
// Needs the flag as it ignores a plain /rehash
- OnRehash(NULL,"ssl");
- Implementation eventlist[] = { I_OnRawSocketConnect, I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketRead, I_OnRawSocketWrite, I_OnCleanup, I_On005Numeric,
- I_OnBufferFlushed, I_OnRequest, I_OnSyncUserMetaData, I_OnDecodeMetaData, I_OnUnloadModule, I_OnRehash, I_OnWhois, I_OnPostConnect, I_OnHookUserIO };
- ServerInstance->Modules->Attach(eventlist, this, 16);
+ OnModuleRehash(NULL,"ssl");
+ Implementation eventlist[] = { I_OnRawSocketConnect, I_OnRawSocketAccept,
+ I_OnRawSocketClose, I_OnRawSocketRead, I_OnRawSocketWrite, I_OnCleanup, I_On005Numeric,
+ I_OnBufferFlushed, I_OnRequest, I_OnSyncUserMetaData, I_OnDecodeMetaData,
+ I_OnUnloadModule, I_OnRehash, I_OnModuleRehash, I_OnWhois, I_OnPostConnect,
+ I_OnHookUserIO };
+ ServerInstance->Modules->Attach(eventlist, this, 17);
}
virtual void OnHookUserIO(User* user, const std::string &targetip)
@@ -164,7 +167,7 @@ class ModuleSSLOpenSSL : public Module
}
}
- virtual void OnRehash(User* user, const std::string &param)
+ virtual void OnRehash(User* user)
{
ConfigReader Conf(ServerInstance);
@@ -217,11 +220,16 @@ class ModuleSSLOpenSSL : public Module
if (!sslports.empty())
sslports.erase(sslports.end() - 1);
+ }
+ virtual void OnModuleRehash(User* user, const std::string &param)
+ {
if (param != "ssl")
- {
return;
- }
+
+ OnRehash(user);
+
+ ConfigReader Conf(ServerInstance);
std::string confdir(ServerInstance->ConfigFileName);
// +1 so we the path ends with a /
diff --git a/src/modules/extra/m_ssl_oper_cert.cpp b/src/modules/extra/m_ssl_oper_cert.cpp
index 08977f159..d11ec200d 100644
--- a/src/modules/extra/m_ssl_oper_cert.cpp
+++ b/src/modules/extra/m_ssl_oper_cert.cpp
@@ -87,7 +87,7 @@ class ModuleOperSSLCert : public Module
}
- virtual void OnRehash(User* user, const std::string &parameter)
+ virtual void OnRehash(User* user)
{
delete cf;
cf = new ConfigReader(ServerInstance);