summaryrefslogtreecommitdiff
path: root/src/modules/extra
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/extra')
-rw-r--r--src/modules/extra/m_mssql.cpp16
-rw-r--r--src/modules/extra/m_mysql.cpp19
-rw-r--r--src/modules/extra/m_pgsql.cpp16
-rw-r--r--src/modules/extra/m_regex_pcre.cpp36
-rw-r--r--src/modules/extra/m_regex_posix.cpp43
-rw-r--r--src/modules/extra/m_regex_tre.cpp33
-rw-r--r--src/modules/extra/m_sqlite3.cpp14
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp7
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp6
-rw-r--r--src/modules/extra/m_ziplink.cpp3
10 files changed, 61 insertions, 132 deletions
diff --git a/src/modules/extra/m_mssql.cpp b/src/modules/extra/m_mssql.cpp
index 455a4fa47..13f25d4fc 100644
--- a/src/modules/extra/m_mssql.cpp
+++ b/src/modules/extra/m_mssql.cpp
@@ -636,29 +636,23 @@ class ModuleMsSQL : public Module
private:
unsigned long currid;
QueryThread* queryDispatcher;
+ ServiceProvider sqlserv;
public:
ModuleMsSQL()
- : currid(0)
+ : currid(0), sqlserv(this, "SQL/mssql", SERVICE_DATA)
{
LoggingMutex = new Mutex();
ResultsMutex = new Mutex();
- ServerInstance->Modules->UseInterface("SQLutils");
-
- if (!ServerInstance->Modules->PublishFeature("SQL", this))
- {
- throw ModuleException("m_mssql: Unable to publish feature 'SQL'");
- }
-
ReadConf();
queryDispatcher = new QueryThread(this);
ServerInstance->Threads->Start(queryDispatcher);
- ServerInstance->Modules->PublishInterface("SQL", this);
Implementation eventlist[] = { I_OnRehash };
ServerInstance->Modules->Attach(eventlist, this, 1);
+ ServerInstance->Modules->AddService(sqlserv);
}
virtual ~ModuleMsSQL()
@@ -668,10 +662,6 @@ class ModuleMsSQL : public Module
ClearQueue();
ClearAllConnections();
- ServerInstance->Modules->UnpublishInterface("SQL", this);
- ServerInstance->Modules->UnpublishFeature("SQL");
- ServerInstance->Modules->DoneWithInterface("SQLutils");
-
delete LoggingMutex;
delete ResultsMutex;
}
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp
index 358f5e992..c294befdc 100644
--- a/src/modules/extra/m_mysql.cpp
+++ b/src/modules/extra/m_mysql.cpp
@@ -93,6 +93,7 @@ class ModuleSQL : public Module
Mutex ResultsMutex;
Mutex LoggingMutex;
Mutex ConnMutex;
+ ServiceProvider sqlserv;
ModuleSQL();
~ModuleSQL();
@@ -666,8 +667,6 @@ ConnMap::iterator GetCharId(char id)
return Connections.end();
}
-class ModuleSQL;
-
class DispatcherThread : public SocketThread
{
private:
@@ -679,24 +678,13 @@ class DispatcherThread : public SocketThread
virtual void OnNotify();
};
-ModuleSQL::ModuleSQL() : rehashing(false)
+ModuleSQL::ModuleSQL() : rehashing(false), sqlserv(this, "SQL/mysql", SERVICE_DATA)
{
- ServerInstance->Modules->UseInterface("SQLutils");
-
currid = 0;
Dispatcher = new DispatcherThread(this);
ServerInstance->Threads->Start(Dispatcher);
- if (!ServerInstance->Modules->PublishFeature("SQL", this))
- {
- Dispatcher->join();
- delete Dispatcher;
- ServerInstance->Modules->DoneWithInterface("SQLutils");
- throw ModuleException("m_mysql: Unable to publish feature 'SQL'");
- }
-
- ServerInstance->Modules->PublishInterface("SQL", this);
Implementation eventlist[] = { I_OnRehash };
ServerInstance->Modules->Attach(eventlist, this, 1);
}
@@ -705,9 +693,6 @@ ModuleSQL::~ModuleSQL()
{
delete Dispatcher;
ClearAllConnections();
- ServerInstance->Modules->UnpublishInterface("SQL", this);
- ServerInstance->Modules->UnpublishFeature("SQL");
- ServerInstance->Modules->DoneWithInterface("SQLutils");
}
unsigned long ModuleSQL::NewID()
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index f362125cb..4fb3d3ab6 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -763,25 +763,18 @@ class ModulePgSQL : public Module
unsigned long currid;
char* sqlsuccess;
ReconnectTimer* retimer;
-
+ ServiceProvider sqlserv;
public:
ModulePgSQL()
- : currid(0)
+ : currid(0), sqlserv(this, "SQL/pgsql", SERVICE_DATA)
{
- ServerInstance->Modules->UseInterface("SQLutils");
-
sqlsuccess = new char[strlen(SQLSUCCESS)+1];
strlcpy(sqlsuccess, SQLSUCCESS, strlen(SQLSUCCESS));
- if (!ServerInstance->Modules->PublishFeature("SQL", this))
- {
- throw ModuleException("BUG: PgSQL Unable to publish feature 'SQL'");
- }
-
ReadConf();
- ServerInstance->Modules->PublishInterface("SQL", this);
+ ServerInstance->Modules->AddService(sqlserv);
Implementation eventlist[] = { I_OnUnloadModule, I_OnRehash };
ServerInstance->Modules->Attach(eventlist, this, 2);
}
@@ -792,9 +785,6 @@ class ModulePgSQL : public Module
ServerInstance->Timers->DelTimer(retimer);
ClearAllConnections();
delete[] sqlsuccess;
- ServerInstance->Modules->UnpublishInterface("SQL", this);
- ServerInstance->Modules->UnpublishFeature("SQL");
- ServerInstance->Modules->DoneWithInterface("SQLutils");
}
diff --git a/src/modules/extra/m_regex_pcre.cpp b/src/modules/extra/m_regex_pcre.cpp
index 9e8aff159..c286162e8 100644
--- a/src/modules/extra/m_regex_pcre.cpp
+++ b/src/modules/extra/m_regex_pcre.cpp
@@ -67,35 +67,27 @@ public:
}
};
-class ModuleRegexPCRE : public Module
+class PCREFactory : public RegexFactory
{
-public:
- ModuleRegexPCRE() {
- ServerInstance->Modules->PublishInterface("RegularExpression", this);
- }
-
- virtual Version GetVersion()
+ public:
+ PCREFactory(Module* m) : RegexFactory(m, "regex/pcre") {}
+ Regex* Create(const std::string& expr)
{
- return Version("Regex Provider Module for PCRE", VF_COMMON | VF_VENDOR);
+ return new PCRERegex(expr);
}
+};
- virtual ~ModuleRegexPCRE()
- {
- ServerInstance->Modules->UnpublishInterface("RegularExpression", this);
+class ModuleRegexPCRE : public Module
+{
+public:
+ PCREFactory ref;
+ ModuleRegexPCRE() : ref(this) {
+ ServerInstance->Modules->AddService(ref);
}
- void OnRequest(Request& request)
+ Version GetVersion()
{
- if (strcmp("REGEX-NAME", request.id) == 0)
- {
- static_cast<RegexNameRequest&>(request).result = "pcre";
- }
- else if (strcmp("REGEX", request.id) == 0)
- {
- RegexFactoryRequest& rfr = (RegexFactoryRequest&)request;
- std::string rx = rfr.GetRegex();
- rfr.result = new PCRERegex(rx);
- }
+ return Version("Regex Provider Module for PCRE", VF_OPTCOMMON | VF_VENDOR);
}
};
diff --git a/src/modules/extra/m_regex_posix.cpp b/src/modules/extra/m_regex_posix.cpp
index ea016ae64..837f2ac1f 100644
--- a/src/modules/extra/m_regex_posix.cpp
+++ b/src/modules/extra/m_regex_posix.cpp
@@ -71,46 +71,37 @@ public:
}
};
-class ModuleRegexPOSIX : public Module
+class PosixFactory : public RegexFactory
{
-private:
+ public:
bool extended;
+ PosixFactory(Module* m) : RegexFactory(m, "regex/posix") {}
+ Regex* Create(const std::string& expr)
+ {
+ return new POSIXRegex(expr, extended);
+ }
+};
+
+class ModuleRegexPOSIX : public Module
+{
+ PosixFactory ref;
public:
- ModuleRegexPOSIX() {
- ServerInstance->Modules->PublishInterface("RegularExpression", this);
+ ModuleRegexPOSIX() : ref(this) {
+ ServerInstance->Modules->AddService(ref);
Implementation eventlist[] = { I_OnRehash };
ServerInstance->Modules->Attach(eventlist, this, 1);
OnRehash(NULL);
}
- virtual Version GetVersion()
+ Version GetVersion()
{
return Version("Regex Provider Module for POSIX Regular Expressions", VF_COMMON | VF_VENDOR);
}
- virtual ~ModuleRegexPOSIX()
- {
- ServerInstance->Modules->UnpublishInterface("RegularExpression", this);
- }
-
- virtual void OnRehash(User* u)
+ void OnRehash(User* u)
{
ConfigReader Conf;
- extended = Conf.ReadFlag("posix", "extended", 0);
- }
-
- void OnRequest(Request& request)
- {
- if (strcmp("REGEX-NAME", request.id) == 0)
- {
- static_cast<RegexNameRequest&>(request).result = "posix";
- }
- else if (strcmp("REGEX", request.id) == 0)
- {
- RegexFactoryRequest& rfr = (RegexFactoryRequest&)request;
- std::string rx = rfr.GetRegex();
- rfr.result = new POSIXRegex(rx, extended);
- }
+ ref.extended = Conf.ReadFlag("posix", "extended", 0);
}
};
diff --git a/src/modules/extra/m_regex_tre.cpp b/src/modules/extra/m_regex_tre.cpp
index 01c6ebf4a..5a208ec8a 100644
--- a/src/modules/extra/m_regex_tre.cpp
+++ b/src/modules/extra/m_regex_tre.cpp
@@ -73,35 +73,30 @@ public:
}
};
+class TREFactory : public RegexFactory {
+ public:
+ TREFactory(Module* m) : RegexFactory(m, "regex/tre") {}
+ Regex* Create(const std::string& expr)
+ {
+ return new TRERegex(expr);
+ }
+};
+
class ModuleRegexTRE : public Module
{
+ TREFactory trf;
public:
- ModuleRegexTRE() {
- ServerInstance->Modules->PublishInterface("RegularExpression", this);
+ ModuleRegexTRE() : trf(this) {
+ ServerInstance->Modules->AddService(trf);
}
- virtual Version GetVersion()
+ Version GetVersion()
{
return Version("Regex Provider Module for TRE Regular Expressions", VF_COMMON | VF_VENDOR);
}
- virtual ~ModuleRegexTRE()
+ ~ModuleRegexTRE()
{
- ServerInstance->Modules->UnpublishInterface("RegularExpression", this);
- }
-
- void OnRequest(Request& request)
- {
- if (strcmp("REGEX-NAME", request.id) == 0)
- {
- static_cast<RegexNameRequest&>(request).result = "tre";
- }
- else if (strcmp("REGEX", request.id) == 0)
- {
- RegexFactoryRequest& rfr = (RegexFactoryRequest&)request;
- std::string rx = rfr.GetRegex();
- rfr.result = new TRERegex(rx);
- }
}
};
diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp
index e5693b61f..58a33c510 100644
--- a/src/modules/extra/m_sqlite3.cpp
+++ b/src/modules/extra/m_sqlite3.cpp
@@ -446,21 +446,15 @@ class ModuleSQLite3 : public Module
private:
ConnMap connections;
unsigned long currid;
+ ServiceProvider sqlserv;
public:
ModuleSQLite3()
- : currid(0)
+ : currid(0), sqlserv(this, "SQL/sqlite", SERVICE_DATA)
{
- ServerInstance->Modules->UseInterface("SQLutils");
-
- if (!ServerInstance->Modules->PublishFeature("SQL", this))
- {
- throw ModuleException("m_sqlite3: Unable to publish feature 'SQL'");
- }
ReadConf();
- ServerInstance->Modules->PublishInterface("SQL", this);
Implementation eventlist[] = { I_OnRehash };
ServerInstance->Modules->Attach(eventlist, this, 1);
}
@@ -469,10 +463,6 @@ class ModuleSQLite3 : public Module
{
ClearQueue();
ClearAllConnections();
-
- ServerInstance->Modules->UnpublishInterface("SQL", this);
- ServerInstance->Modules->UnpublishFeature("SQL");
- ServerInstance->Modules->DoneWithInterface("SQLutils");
}
void ClearQueue()
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 8ec787465..7ba611547 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -137,13 +137,12 @@ class ModuleSSLGnuTLS : public Module
CommandStartTLS starttls;
GenericCap capHandler;
+ ServiceProvider iohook;
public:
ModuleSSLGnuTLS()
- : starttls(this), capHandler(this, "tls")
+ : starttls(this), capHandler(this, "tls"), iohook(this, "ssl/gnutls", SERVICE_IOHOOK)
{
- ServerInstance->Modules->PublishInterface("BufferedSocketHook", this);
-
sessions = new issl_session[ServerInstance->SE->GetMaxFds()];
gnutls_global_init(); // This must be called once in the program
@@ -160,6 +159,7 @@ class ModuleSSLGnuTLS : public Module
I_OnEvent, I_OnHookIO };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
+ ServerInstance->Modules->AddService(iohook);
ServerInstance->AddCommand(&starttls);
}
@@ -286,7 +286,6 @@ class ModuleSSLGnuTLS : public Module
gnutls_dh_params_deinit(dh_params);
gnutls_certificate_free_credentials(x509_cred);
gnutls_global_deinit();
- ServerInstance->Modules->UnpublishInterface("BufferedSocketHook", this);
delete[] sessions;
}
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 03c460be2..7524c0d07 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -97,11 +97,11 @@ class ModuleSSLOpenSSL : public Module
std::string dhfile;
std::string sslports;
+ ServiceProvider iohook;
public:
- ModuleSSLOpenSSL()
+ ModuleSSLOpenSSL() : iohook(this, "ssl/openssl", SERVICE_IOHOOK)
{
- ServerInstance->Modules->PublishInterface("BufferedSocketHook", this);
sessions = new issl_session[ServerInstance->SE->GetMaxFds()];
@@ -128,6 +128,7 @@ class ModuleSSLOpenSSL : public Module
OnModuleRehash(NULL,"ssl");
Implementation eventlist[] = { I_On005Numeric, I_OnRehash, I_OnModuleRehash, I_OnHookIO, I_OnUserConnect };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
+ ServerInstance->Modules->AddService(iohook);
}
void OnHookIO(StreamSocket* user, ListenSocket* lsb)
@@ -241,7 +242,6 @@ class ModuleSSLOpenSSL : public Module
{
SSL_CTX_free(ctx);
SSL_CTX_free(clictx);
- ServerInstance->Modules->UnpublishInterface("BufferedSocketHook", this);
delete[] sessions;
}
diff --git a/src/modules/extra/m_ziplink.cpp b/src/modules/extra/m_ziplink.cpp
index 2aeb4b9e6..2ac358769 100644
--- a/src/modules/extra/m_ziplink.cpp
+++ b/src/modules/extra/m_ziplink.cpp
@@ -56,8 +56,6 @@ class ModuleZLib : public Module
ModuleZLib()
{
- ServerInstance->Modules->PublishInterface("BufferedSocketHook", this);
-
sessions = new izip_session[ServerInstance->SE->GetMaxFds()];
for (int i = 0; i < ServerInstance->SE->GetMaxFds(); i++)
sessions[i].status = IZIP_CLOSED;
@@ -74,7 +72,6 @@ class ModuleZLib : public Module
~ModuleZLib()
{
- ServerInstance->Modules->UnpublishInterface("BufferedSocketHook", this);
delete[] sessions;
delete[] net_buffer;
}