summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-08 23:29:21 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-08 23:29:21 +0000
commit7e843c22e16c81054bad18073d24fe1a07026431 (patch)
tree44ca0213c7d7a80270b993fec1fbed275ec56424 /src/modules
parentc440038736f749a56dbac1badee5b2f099286117 (diff)
Update Event and Request APIs
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11808 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/account.h10
-rw-r--r--src/modules/extra/m_mysql.cpp59
-rw-r--r--src/modules/extra/m_pgsql.cpp32
-rw-r--r--src/modules/extra/m_regex_pcre.cpp18
-rw-r--r--src/modules/extra/m_regex_posix.cpp20
-rw-r--r--src/modules/extra/m_regex_tre.cpp18
-rw-r--r--src/modules/extra/m_sqlite3.cpp17
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp57
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp51
-rw-r--r--src/modules/extra/m_ziplink.cpp47
-rw-r--r--src/modules/httpd.h53
-rw-r--r--src/modules/m_banexception.cpp9
-rw-r--r--src/modules/m_banredirect.cpp14
-rw-r--r--src/modules/m_cap.cpp15
-rw-r--r--src/modules/m_cap.h20
-rw-r--r--src/modules/m_cgiirc.cpp4
-rw-r--r--src/modules/m_chanfilter.cpp9
-rw-r--r--src/modules/m_cloaking.cpp32
-rw-r--r--src/modules/m_filter.cpp4
-rw-r--r--src/modules/m_hash.h164
-rw-r--r--src/modules/m_httpd.cpp21
-rw-r--r--src/modules/m_httpd_acl.cpp34
-rw-r--r--src/modules/m_httpd_config.cpp21
-rw-r--r--src/modules/m_httpd_stats.cpp21
-rw-r--r--src/modules/m_ident.cpp4
-rw-r--r--src/modules/m_inviteexception.cpp9
-rw-r--r--src/modules/m_md5.cpp42
-rw-r--r--src/modules/m_namesx.cpp2
-rw-r--r--src/modules/m_override.cpp20
-rwxr-xr-xsrc/modules/m_override.h13
-rw-r--r--src/modules/m_password_hash.cpp15
-rw-r--r--src/modules/m_regex.h2
-rw-r--r--src/modules/m_regex_glob.cpp21
-rw-r--r--src/modules/m_ripemd160.cpp47
-rw-r--r--src/modules/m_rline.cpp4
-rw-r--r--src/modules/m_rpc_json.cpp368
-rw-r--r--src/modules/m_rpctest.cpp62
-rw-r--r--src/modules/m_sasl.cpp6
-rw-r--r--src/modules/m_services_account.cpp8
-rw-r--r--src/modules/m_sha256.cpp53
-rw-r--r--src/modules/m_spanningtree/cachetimer.cpp1
-rw-r--r--src/modules/m_spanningtree/handshaketimer.cpp54
-rw-r--r--src/modules/m_spanningtree/handshaketimer.h37
-rw-r--r--src/modules/m_spanningtree/hmac.cpp14
-rw-r--r--src/modules/m_spanningtree/main.cpp19
-rw-r--r--src/modules/m_spanningtree/main.h1
-rw-r--r--src/modules/m_spanningtree/override_admin.cpp1
-rw-r--r--src/modules/m_spanningtree/override_motd.cpp1
-rw-r--r--src/modules/m_spanningtree/override_squit.cpp1
-rw-r--r--src/modules/m_spanningtree/override_stats.cpp7
-rw-r--r--src/modules/m_spanningtree/override_time.cpp1
-rw-r--r--src/modules/m_spanningtree/override_whois.cpp1
-rw-r--r--src/modules/m_spanningtree/ping.cpp1
-rw-r--r--src/modules/m_spanningtree/pong.cpp1
-rw-r--r--src/modules/m_spanningtree/postcommand.cpp1
-rw-r--r--src/modules/m_spanningtree/precommand.cpp1
-rw-r--r--src/modules/m_spanningtree/push.cpp1
-rw-r--r--src/modules/m_spanningtree/rconnect.cpp1
-rw-r--r--src/modules/m_spanningtree/resolvers.cpp16
-rw-r--r--src/modules/m_spanningtree/resolvers.h8
-rw-r--r--src/modules/m_spanningtree/rsquit.cpp1
-rw-r--r--src/modules/m_spanningtree/save.cpp1
-rw-r--r--src/modules/m_spanningtree/server.cpp6
-rw-r--r--src/modules/m_spanningtree/stats.cpp1
-rw-r--r--src/modules/m_spanningtree/svsjoin.cpp1
-rw-r--r--src/modules/m_spanningtree/svsnick.cpp1
-rw-r--r--src/modules/m_spanningtree/svspart.cpp1
-rw-r--r--src/modules/m_spanningtree/time.cpp1
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp6
-rw-r--r--src/modules/m_spanningtree/treesocket.h7
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp48
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp4
-rw-r--r--src/modules/m_spanningtree/uid.cpp1
-rw-r--r--src/modules/m_spanningtree/utils.cpp57
-rw-r--r--src/modules/m_spanningtree/utils.h20
-rw-r--r--src/modules/m_spanningtree/version.cpp1
-rw-r--r--src/modules/m_spanningtree/whois.cpp1
-rw-r--r--src/modules/m_sqlauth.cpp50
-rw-r--r--src/modules/m_sqllog.cpp140
-rw-r--r--src/modules/m_sqloper.cpp50
-rw-r--r--src/modules/m_sqlutils.cpp28
-rw-r--r--src/modules/m_sqlv2.h37
-rw-r--r--src/modules/m_sslinfo.cpp21
-rw-r--r--src/modules/m_sslmodes.cpp8
-rw-r--r--src/modules/m_testclient.cpp30
-rw-r--r--src/modules/m_uhnames.cpp2
-rw-r--r--src/modules/m_watch.cpp4
-rw-r--r--src/modules/rpc.h296
-rw-r--r--src/modules/ssl.h (renamed from src/modules/transport.h)86
89 files changed, 506 insertions, 1998 deletions
diff --git a/src/modules/account.h b/src/modules/account.h
index 8b86a178b..9182d7ca6 100644
--- a/src/modules/account.h
+++ b/src/modules/account.h
@@ -17,11 +17,15 @@
#include <map>
#include <string>
-class AccountData : public classbase
+class AccountEvent : public Event
{
public:
- User* user;
- std::string account;
+ User* const user;
+ const std::string account;
+ AccountEvent(Module* me, User* u, const std::string& name)
+ : Event(me, "account_login"), user(u), account(name)
+ {
+ }
};
#endif
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp
index a0ac9ffac..a921dea8e 100644
--- a/src/modules/extra/m_mysql.cpp
+++ b/src/modules/extra/m_mysql.cpp
@@ -99,7 +99,7 @@ class ModuleSQL : public Module
ModuleSQL();
~ModuleSQL();
unsigned long NewID();
- const char* OnRequest(Request* request);
+ void OnRequest(Request& request);
void OnRehash(User* user);
Version GetVersion();
};
@@ -340,7 +340,7 @@ class SQLConnection : public classbase
mysql_query(connection,initquery.c_str());
/* Parse the command string and dispatch it to mysql */
- SQLrequest& req = queue.front();
+ SQLrequest* req = queue.front();
/* Pointer to the buffer we screw around with substitution in */
char* query;
@@ -354,17 +354,17 @@ class SQLConnection : public classbase
/* The length of the longest parameter */
maxparamlen = 0;
- for(ParamL::iterator i = req.query.p.begin(); i != req.query.p.end(); i++)
+ for(ParamL::iterator i = req->query.p.begin(); i != req->query.p.end(); i++)
{
if (i->size() > maxparamlen)
maxparamlen = i->size();
}
/* How many params are there in the query? */
- paramcount = count(req.query.q.c_str(), '?');
+ paramcount = count(req->query.q.c_str(), '?');
/* This stores copy of params to be inserted with using numbered params 1;3B*/
- ParamL paramscopy(req.query.p);
+ ParamL paramscopy(req->query.p);
/* To avoid a lot of allocations, allocate enough memory for the biggest the escaped query could possibly be.
* sizeofquery + (maxtotalparamlength*2) + 1
@@ -372,16 +372,16 @@ class SQLConnection : public classbase
* The +1 is for null-terminating the string for mysql_real_escape_string
*/
- query = new char[req.query.q.length() + (maxparamlen*paramcount*2) + 1];
+ query = new char[req->query.q.length() + (maxparamlen*paramcount*2) + 1];
queryend = query;
/* Okay, now we have a buffer large enough we need to start copying the query into it and escaping and substituting
* the parameters into it...
*/
- for(unsigned long i = 0; i < req.query.q.length(); i++)
+ for(unsigned long i = 0; i < req->query.q.length(); i++)
{
- if(req.query.q[i] == '?')
+ if(req->query.q[i] == '?')
{
/* We found a place to substitute..what fun.
* use mysql calls to escape and write the
@@ -404,11 +404,11 @@ class SQLConnection : public classbase
/* Let's check if it's a numbered param. And also calculate it's number.
*/
- while ((i < req.query.q.length() - 1) && (req.query.q[i+1] >= '0') && (req.query.q[i+1] <= '9'))
+ while ((i < req->query.q.length() - 1) && (req->query.q[i+1] >= '0') && (req->query.q[i+1] <= '9'))
{
numbered = true;
++i;
- paramnum = paramnum * 10 + req.query.q[i] - '0';
+ paramnum = paramnum * 10 + req->query.q[i] - '0';
}
if (paramnum > paramscopy.size() - 1)
@@ -424,35 +424,35 @@ class SQLConnection : public classbase
queryend += len;
}
- else if (req.query.p.size())
+ else if (req->query.p.size())
{
- unsigned long len = mysql_real_escape_string(connection, queryend, req.query.p.front().c_str(), req.query.p.front().length());
+ unsigned long len = mysql_real_escape_string(connection, queryend, req->query.p.front().c_str(), req->query.p.front().length());
queryend += len;
- req.query.p.pop_front();
+ req->query.p.pop_front();
}
else
break;
}
else
{
- *queryend = req.query.q[i];
+ *queryend = req->query.q[i];
queryend++;
}
}
*queryend = 0;
- req.query.q = query;
+ req->query.q = query;
- if (!mysql_real_query(connection, req.query.q.data(), req.query.q.length()))
+ if (!mysql_real_query(connection, req->query.q.data(), req->query.q.length()))
{
/* Successfull query */
res = mysql_use_result(connection);
unsigned long rows = mysql_affected_rows(connection);
- MySQLresult* r = new MySQLresult(Parent, req.GetSource(), res, rows, req.id);
+ MySQLresult* r = new MySQLresult(Parent, req->source, res, rows, req->id);
r->dbid = this->GetID();
- r->query = req.query.q;
+ r->query = req->query.q;
/* Put this new result onto the results queue.
* XXX: Remember to mutex the queue!
*/
@@ -465,9 +465,9 @@ class SQLConnection : public classbase
/* XXX: See /usr/include/mysql/mysqld_error.h for a list of
* possible error numbers and error messages */
SQLerror e(SQL_QREPLY_FAIL, ConvToStr(mysql_errno(connection)) + std::string(": ") + mysql_error(connection));
- MySQLresult* r = new MySQLresult(Parent, req.GetSource(), e, req.id);
+ MySQLresult* r = new MySQLresult(Parent, req->source, e, req->id);
r->dbid = this->GetID();
- r->query = req.query.q;
+ r->query = req->query.q;
Parent->ResultsMutex.Lock();
rq.push_back(r);
@@ -698,8 +698,8 @@ ModuleSQL::ModuleSQL() : rehashing(false)
}
ServerInstance->Modules->PublishInterface("SQL", this);
- Implementation eventlist[] = { I_OnRehash, I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 2);
+ Implementation eventlist[] = { I_OnRehash };
+ ServerInstance->Modules->Attach(eventlist, this, 1);
}
ModuleSQL::~ModuleSQL()
@@ -719,23 +719,20 @@ unsigned long ModuleSQL::NewID()
return ++currid;
}
-const char* ModuleSQL::OnRequest(Request* request)
+void ModuleSQL::OnRequest(Request& request)
{
- if(strcmp(SQLREQID, request->GetId()) == 0)
+ if(strcmp(SQLREQID, request.id) == 0)
{
- SQLrequest* req = (SQLrequest*)request;
+ SQLrequest* req = (SQLrequest*)&request;
ConnMap::iterator iter;
- const char* returnval = NULL;
-
Dispatcher->LockQueue();
ConnMutex.Lock();
if((iter = Connections.find(req->dbid)) != Connections.end())
{
req->id = NewID();
- iter->second->queue.push(*req);
- returnval = SQLSUCCESS;
+ iter->second->queue.push(new SQLrequest(*req));
}
else
{
@@ -747,11 +744,7 @@ const char* ModuleSQL::OnRequest(Request* request)
/* Yes, it's possible this will generate a spurious wakeup.
* That's fine, it'll just get ignored.
*/
-
- return returnval;
}
-
- return NULL;
}
void ModuleSQL::OnRehash(User* user)
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index c0b2bbac8..df0ca7f42 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -403,8 +403,8 @@ class SQLConn : public EventHandler
if(!qinprog && queue.totalsize())
{
/* There's no query currently in progress, and there's queries in the queue. */
- SQLrequest& query = queue.front();
- DoQuery(query);
+ SQLrequest* query = queue.front();
+ DoQuery(*query);
}
if(PQconsumeInput(sql))
@@ -421,10 +421,10 @@ class SQLConn : public EventHandler
else if (qinprog)
{
/* Grab the request we're processing */
- SQLrequest& query = queue.front();
+ SQLrequest* query = queue.front();
/* Get a pointer to the module we're about to return the result to */
- Module* to = query.GetSource();
+ Module* to = query->source;
/* Fetch the result.. */
PGresult* result = PQgetResult(sql);
@@ -444,10 +444,10 @@ class SQLConn : public EventHandler
if(to)
{
/* ..and the result */
- PgSQLresult reply(us, to, query.id, result);
+ PgSQLresult reply(us, to, query->id, result);
/* Fix by brain, make sure the original query gets sent back in the reply */
- reply.query = query.query.q;
+ reply.query = query->query.q;
switch(PQresultStatus(result))
{
@@ -709,13 +709,13 @@ class SQLConn : public EventHandler
SQLerror Query(const SQLrequest &req)
{
- queue.push(req);
+ queue.push(new SQLrequest(req));
if(!qinprog && queue.totalsize())
{
/* There's no query currently in progress, and there's queries in the queue. */
- SQLrequest& query = queue.front();
- return DoQuery(query);
+ SQLrequest* query = queue.front();
+ return DoQuery(*query);
}
else
{
@@ -782,8 +782,8 @@ class ModulePgSQL : public Module
ReadConf();
ServerInstance->Modules->PublishInterface("SQL", this);
- Implementation eventlist[] = { I_OnUnloadModule, I_OnRequest, I_OnRehash };
- ServerInstance->Modules->Attach(eventlist, this, 3);
+ Implementation eventlist[] = { I_OnUnloadModule, I_OnRehash };
+ ServerInstance->Modules->Attach(eventlist, this, 2);
}
virtual ~ModulePgSQL()
@@ -911,27 +911,23 @@ class ModulePgSQL : public Module
ServerInstance->Timers->AddTimer(retimer);
}
- virtual const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- if(strcmp(SQLREQID, request->GetId()) == 0)
+ if(strcmp(SQLREQID, request.id) == 0)
{
- SQLrequest* req = (SQLrequest*)request;
+ SQLrequest* req = (SQLrequest*)&request;
ConnMap::iterator iter;
if((iter = connections.find(req->dbid)) != connections.end())
{
/* Execute query */
req->id = NewID();
req->error = iter->second->Query(*req);
-
- return (req->error.Id() == SQL_NO_ERROR) ? sqlsuccess : NULL;
}
else
{
req->error.Id(SQL_BAD_DBID);
- return NULL;
}
}
- return NULL;
}
virtual void OnUnloadModule(Module* mod, const std::string& name)
diff --git a/src/modules/extra/m_regex_pcre.cpp b/src/modules/extra/m_regex_pcre.cpp
index 782847736..16d0cfe15 100644
--- a/src/modules/extra/m_regex_pcre.cpp
+++ b/src/modules/extra/m_regex_pcre.cpp
@@ -72,8 +72,6 @@ class ModuleRegexPCRE : public Module
public:
ModuleRegexPCRE() {
ServerInstance->Modules->PublishInterface("RegularExpression", this);
- Implementation eventlist[] = { I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 1);
}
virtual Version GetVersion()
@@ -86,20 +84,18 @@ public:
ServerInstance->Modules->UnpublishInterface("RegularExpression", this);
}
- virtual const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- if (strcmp("REGEX-NAME", request->GetId()) == 0)
+ if (strcmp("REGEX-NAME", request.id) == 0)
{
- return "pcre";
+ static_cast<RegexNameRequest&>(request).result = "pcre";
}
- else if (strcmp("REGEX", request->GetId()) == 0)
+ else if (strcmp("REGEX", request.id) == 0)
{
- RegexFactoryRequest* rfr = (RegexFactoryRequest*)request;
- std::string rx = rfr->GetRegex();
- rfr->result = new PCRERegex(rx);
- return "OK";
+ RegexFactoryRequest& rfr = (RegexFactoryRequest&)request;
+ std::string rx = rfr.GetRegex();
+ rfr.result = new PCRERegex(rx);
}
- return NULL;
}
};
diff --git a/src/modules/extra/m_regex_posix.cpp b/src/modules/extra/m_regex_posix.cpp
index 7afaad076..62b44e0e4 100644
--- a/src/modules/extra/m_regex_posix.cpp
+++ b/src/modules/extra/m_regex_posix.cpp
@@ -78,8 +78,8 @@ private:
public:
ModuleRegexPOSIX() {
ServerInstance->Modules->PublishInterface("RegularExpression", this);
- Implementation eventlist[] = { I_OnRequest, I_OnRehash };
- ServerInstance->Modules->Attach(eventlist, this, 2);
+ Implementation eventlist[] = { I_OnRehash };
+ ServerInstance->Modules->Attach(eventlist, this, 1);
OnRehash(NULL);
}
@@ -99,20 +99,18 @@ public:
extended = Conf.ReadFlag("posix", "extended", 0);
}
- virtual const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- if (strcmp("REGEX-NAME", request->GetId()) == 0)
+ if (strcmp("REGEX-NAME", request.id) == 0)
{
- return "posix";
+ static_cast<RegexNameRequest&>(request).result = "posix";
}
- else if (strcmp("REGEX", request->GetId()) == 0)
+ else if (strcmp("REGEX", request.id) == 0)
{
- RegexFactoryRequest* rfr = (RegexFactoryRequest*)request;
- std::string rx = rfr->GetRegex();
- rfr->result = new POSIXRegex(rx, extended);
- return "OK";
+ RegexFactoryRequest& rfr = (RegexFactoryRequest&)request;
+ std::string rx = rfr.GetRegex();
+ rfr.result = new POSIXRegex(rx, extended);
}
- return NULL;
}
};
diff --git a/src/modules/extra/m_regex_tre.cpp b/src/modules/extra/m_regex_tre.cpp
index 41aaec31c..f2a9004bd 100644
--- a/src/modules/extra/m_regex_tre.cpp
+++ b/src/modules/extra/m_regex_tre.cpp
@@ -78,8 +78,6 @@ class ModuleRegexTRE : public Module
public:
ModuleRegexTRE() {
ServerInstance->Modules->PublishInterface("RegularExpression", this);
- Implementation eventlist[] = { I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 1);
}
virtual Version GetVersion()
@@ -92,20 +90,18 @@ public:
ServerInstance->Modules->UnpublishInterface("RegularExpression", this);
}
- virtual const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- if (strcmp("REGEX-NAME", request->GetId()) == 0)
+ if (strcmp("REGEX-NAME", request.id) == 0)
{
- return "tre";
+ static_cast<RegexNameRequest&>(request).result = "tre";
}
- else if (strcmp("REGEX", request->GetId()) == 0)
+ else if (strcmp("REGEX", request.id) == 0)
{
- RegexFactoryRequest* rfr = (RegexFactoryRequest*)request;
- std::string rx = rfr->GetRegex();
- rfr->result = new TRERegex(rx);
- return "OK";
+ RegexFactoryRequest& rfr = (RegexFactoryRequest&)request;
+ std::string rx = rfr.GetRegex();
+ rfr.result = new TRERegex(rx);
}
- return NULL;
}
};
diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp
index 806cbce72..680053bf1 100644
--- a/src/modules/extra/m_sqlite3.cpp
+++ b/src/modules/extra/m_sqlite3.cpp
@@ -399,7 +399,7 @@ class SQLConn : public classbase
*queryend = 0;
req.query.q = query;
- SQLite3Result* res = new SQLite3Result(mod, req.GetSource(), req.id);
+ SQLite3Result* res = new SQLite3Result(mod, req.source, req.id);
res->dbid = host.id;
res->query = req.query.q;
paramlist params;
@@ -467,7 +467,7 @@ class SQLConn : public classbase
while (results.size())
{
SQLite3Result* res = results[0];
- if (res->GetDest())
+ if (res->dest)
{
res->Send();
}
@@ -552,8 +552,8 @@ class ModuleSQLite3 : public Module
ReadConf();
ServerInstance->Modules->PublishInterface("SQL", this);
- Implementation eventlist[] = { I_OnRequest, I_OnRehash };
- ServerInstance->Modules->Attach(eventlist, this, 2);
+ Implementation eventlist[] = { I_OnRehash };
+ ServerInstance->Modules->Attach(eventlist, this, 1);
}
virtual ~ModuleSQLite3()
@@ -695,25 +695,22 @@ class ModuleSQLite3 : public Module
ReadConf();
}
- virtual const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- if(strcmp(SQLREQID, request->GetId()) == 0)
+ if(strcmp(SQLREQID, request.id) == 0)
{
- SQLrequest* req = (SQLrequest*)request;
+ SQLrequest* req = (SQLrequest*)&request;
ConnMap::iterator iter;
if((iter = connections.find(req->dbid)) != connections.end())
{
req->id = NewID();
req->error = iter->second->Query(*req);
- return SQLSUCCESS;
}
else
{
req->error.Id(SQL_BAD_DBID);
- return NULL;
}
}
- return NULL;
}
unsigned long NewID()
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 813ae9e9b..3530b0e1f 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -14,7 +14,7 @@
#include "inspircd.h"
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
-#include "transport.h"
+#include "ssl.h"
#include "m_cap.h"
#ifdef WINDOWS
@@ -160,7 +160,7 @@ class ModuleSSLGnuTLS : public Module
// Void return, guess we assume success
gnutls_certificate_set_dh_params(x509_cred, dh_params);
- Implementation eventlist[] = { I_On005Numeric, I_OnRequest, I_OnRehash, I_OnModuleRehash, I_OnPostConnect,
+ Implementation eventlist[] = { I_On005Numeric, I_OnRehash, I_OnModuleRehash, I_OnPostConnect,
I_OnEvent, I_OnHookIO };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
@@ -352,52 +352,11 @@ class ModuleSSLGnuTLS : public Module
}
}
- const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- ISHRequest* ISR = static_cast<ISHRequest*>(request);
- if (strcmp("IS_NAME", request->GetId()) == 0)
- {
- return "gnutls";
- }
- else if (strcmp("IS_HOOK", request->GetId()) == 0)
- {
- ISR->Sock->AddIOHook(this);
- return "OK";
- }
- else if (strcmp("IS_UNHOOK", request->GetId()) == 0)
- {
- ISR->Sock->DelIOHook();
- return "OK";
- }
- else if (strcmp("IS_HSDONE", request->GetId()) == 0)
- {
- if (ISR->Sock->GetFd() < 0)
- return "OK";
-
- issl_session* session = &sessions[ISR->Sock->GetFd()];
- return (session->status == ISSL_HANDSHAKING_READ || session->status == ISSL_HANDSHAKING_WRITE) ? NULL : "OK";
- }
- else if (strcmp("IS_ATTACH", request->GetId()) == 0)
- {
- if (ISR->Sock->GetFd() > -1)
- {
- issl_session* session = &sessions[ISR->Sock->GetFd()];
- if (session->sess)
- {
- if (static_cast<Extensible*>(ServerInstance->SE->GetRef(ISR->Sock->GetFd())) == static_cast<Extensible*>(ISR->Sock))
- {
- return "OK";
- }
- }
- }
- }
- else if (strcmp("GET_CERT", request->GetId()) == 0)
- {
- Module* sslinfo = ServerInstance->Modules->Find("m_sslinfo.so");
- if (sslinfo)
- return sslinfo->OnRequest(request);
- }
- return NULL;
+ Module* sslinfo = ServerInstance->Modules->Find("m_sslinfo.so");
+ if (sslinfo)
+ sslinfo->OnRequest(request);
}
@@ -735,10 +694,10 @@ class ModuleSSLGnuTLS : public Module
info_done_dealloc:
gnutls_x509_crt_deinit(cert);
info_done:
- BufferedSocketFingerprintSubmission(user, this, sslinfo, certinfo).Send();
+ SSLCertSubmission(user, this, sslinfo, certinfo);
}
- void OnEvent(Event* ev)
+ void OnEvent(Event& ev)
{
capHandler.HandleEvent(ev);
}
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index f566b326b..8af930aa9 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -14,7 +14,7 @@
#include "inspircd.h"
#include <openssl/ssl.h>
#include <openssl/err.h>
-#include "transport.h"
+#include "ssl.h"
#ifdef WINDOWS
#pragma comment(lib, "libeay32MTd")
@@ -128,7 +128,7 @@ class ModuleSSLOpenSSL : public Module
// Needs the flag as it ignores a plain /rehash
OnModuleRehash(NULL,"ssl");
Implementation eventlist[] = {
- I_On005Numeric, I_OnRequest, I_OnRehash, I_OnModuleRehash, I_OnPostConnect,
+ I_On005Numeric, I_OnRehash, I_OnModuleRehash, I_OnPostConnect,
I_OnHookIO };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
@@ -291,46 +291,11 @@ class ModuleSSLOpenSSL : public Module
}
- const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- ISHRequest* ISR = (ISHRequest*)request;
- if (strcmp("IS_NAME", request->GetId()) == 0)
- {
- return "openssl";
- }
- else if (strcmp("IS_HOOK", request->GetId()) == 0)
- {
- ISR->Sock->AddIOHook(this);
- return "OK";
- }
- else if (strcmp("IS_UNHOOK", request->GetId()) == 0)
- {
- ISR->Sock->DelIOHook();
- return "OK";
- }
- else if (strcmp("IS_HSDONE", request->GetId()) == 0)
- {
- if (ISR->Sock->GetFd() < 0)
- return "OK";
-
- issl_session* session = &sessions[ISR->Sock->GetFd()];
- return (session->status == ISSL_HANDSHAKING) ? NULL : "OK";
- }
- else if (strcmp("IS_ATTACH", request->GetId()) == 0)
- {
- issl_session* session = &sessions[ISR->Sock->GetFd()];
- if (session->sess)
- {
- return "OK";
- }
- }
- else if (strcmp("GET_CERT", request->GetId()) == 0)
- {
- Module* sslinfo = ServerInstance->Modules->Find("m_sslinfo.so");
- if (sslinfo)
- return sslinfo->OnRequest(request);
- }
- return NULL;
+ Module* sslinfo = ServerInstance->Modules->Find("m_sslinfo.so");
+ if (sslinfo)
+ sslinfo->OnRequest(request);
}
@@ -618,7 +583,7 @@ class ModuleSSLOpenSSL : public Module
if (!cert)
{
certinfo->error = "Could not get peer certificate: "+std::string(get_error());
- BufferedSocketFingerprintSubmission(user, this, sslinfo, certinfo).Send();
+ SSLCertSubmission(user, this, sslinfo, certinfo);
return;
}
@@ -653,7 +618,7 @@ class ModuleSSLOpenSSL : public Module
}
X509_free(cert);
- BufferedSocketFingerprintSubmission(user, this, sslinfo, certinfo).Send();
+ SSLCertSubmission(user, this, sslinfo, certinfo);
}
void Prioritize()
diff --git a/src/modules/extra/m_ziplink.cpp b/src/modules/extra/m_ziplink.cpp
index 976a27b5c..4b53cf389 100644
--- a/src/modules/extra/m_ziplink.cpp
+++ b/src/modules/extra/m_ziplink.cpp
@@ -13,12 +13,10 @@
#include "inspircd.h"
#include <zlib.h>
-#include "transport.h"
#include <iostream>
/* $ModDesc: Provides zlib link support for servers */
/* $LinkerFlags: -lz */
-/* $ModDep: transport.h */
/*
* ZLIB_BEST_COMPRESSION (9) is used for all sending of data with
@@ -57,7 +55,7 @@ class ModuleZLib : public Module
public:
ModuleZLib()
- {
+ {
ServerInstance->Modules->PublishInterface("BufferedSocketHook", this);
sessions = new izip_session[ServerInstance->SE->GetMaxFds()];
@@ -66,8 +64,8 @@ class ModuleZLib : public Module
total_out_compressed = total_in_compressed = 0;
total_out_uncompressed = total_in_uncompressed = 0;
- Implementation eventlist[] = { I_OnStats, I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 2);
+ Implementation eventlist[] = { I_OnStats };
+ ServerInstance->Modules->Attach(eventlist, this, 1);
// Allocate a buffer which is used for reading and writing data
net_buffer_size = ServerInstance->Config->NetBufferSize;
@@ -83,44 +81,7 @@ class ModuleZLib : public Module
Version GetVersion()
{
- return Version("Provides zlib link support for servers", VF_VENDOR, API_VERSION);
- }
-
-
- /* Handle BufferedSocketHook API requests */
- const char* OnRequest(Request* request)
- {
- ISHRequest* ISR = (ISHRequest*)request;
- if (strcmp("IS_NAME", request->GetId()) == 0)
- {
- /* Return name */
- return "zip";
- }
- else if (strcmp("IS_HOOK", request->GetId()) == 0)
- {
- ISR->Sock->AddIOHook(this);
- return "OK";
- }
- else if (strcmp("IS_UNHOOK", request->GetId()) == 0)
- {
- ISR->Sock->DelIOHook();
- return "OK";
- }
- else if (strcmp("IS_HSDONE", request->GetId()) == 0)
- {
- /* Check for completion of handshake
- * (actually, this module doesnt handshake)
- */
- return "OK";
- }
- else if (strcmp("IS_ATTACH", request->GetId()) == 0)
- {
- /* Attach certificate data to the inspsocket
- * (this module doesnt do that, either)
- */
- return NULL;
- }
- return NULL;
+ return Version("Provides zlib link support for servers", VF_VENDOR);
}
/* Handle stats z (misc stats) */
diff --git a/src/modules/httpd.h b/src/modules/httpd.h
index f40050e36..483009095 100644
--- a/src/modules/httpd.h
+++ b/src/modules/httpd.h
@@ -94,11 +94,11 @@ class HTTPHeaders : public classbase
}
};
+class HttpServerSocket;
+
/** This class represents a HTTP request.
- * It will be sent to all modules as the data section of
- * an Event.
*/
-class HTTPRequest : public classbase
+class HTTPRequest : public Event
{
protected:
std::string type;
@@ -114,7 +114,7 @@ class HTTPRequest : public classbase
/** A socket pointer, which you must return in your HTTPDocument class
* if you reply to this request.
*/
- void* sock;
+ HttpServerSocket* sock;
/** Initialize HTTPRequest.
* This constructor is called by m_httpd.so to initialize the class.
@@ -125,8 +125,9 @@ class HTTPRequest : public classbase
* @param ip The IP address making the web request.
* @param pdata The post data (content after headers) received with the request, up to Content-Length in size
*/
- HTTPRequest(const std::string &request_type, const std::string &uri, HTTPHeaders* hdr, void* opaque, const std::string &ip, const std::string &pdata)
- : type(request_type), document(uri), ipaddr(ip), postdata(pdata), headers(hdr), sock(opaque)
+ HTTPRequest(Module* me, const std::string &eventid, const std::string &request_type, const std::string &uri,
+ HTTPHeaders* hdr, HttpServerSocket* socket, const std::string &ip, const std::string &pdata)
+ : Event(me, eventid), type(request_type), document(uri), ipaddr(ip), postdata(pdata), headers(hdr), sock(socket)
{
}
@@ -171,20 +172,13 @@ class HTTPRequest : public classbase
* When you initialize this class you may initialize it with all components required to
* form a valid HTTP response, including document data, headers, and a response code.
*/
-class HTTPDocument : public classbase
+class HTTPDocumentResponse : public Request
{
- protected:
-
+ public:
std::stringstream* document;
int responsecode;
-
- public:
-
HTTPHeaders headers;
-
- /** The socket pointer from an earlier HTTPRequest
- */
- void* sock;
+ HTTPRequest& src;
/** Initialize a HTTPRequest ready for sending to m_httpd.so.
* @param opaque The socket pointer you obtained from the HTTPRequest at an earlier time
@@ -193,32 +187,9 @@ class HTTPDocument : public classbase
* based upon the response code.
* @param extra Any extra headers to include with the defaults, seperated by carriage return and linefeed.
*/
- HTTPDocument(void* opaque, std::stringstream* doc, int response) : document(doc), responsecode(response), sock(opaque)
- {
- }
-
- /** Get the document text.
- * @return The document text
- */
- std::stringstream* GetDocument()
- {
- return this->document;
- }
-
- /** Get the document size.
- * @return the size of the document text in bytes
- */
- unsigned long GetDocumentSize()
- {
- return this->document->str().length();
- }
-
- /** Get the response code.
- * @return The response code
- */
- int GetResponseCode()
+ HTTPDocumentResponse(Module* me, HTTPRequest& req, std::stringstream* doc, int response)
+ : Request(me, req.source, "HTTP-DOC"), document(doc), responsecode(response), src(req)
{
- return this->responsecode;
}
};
diff --git a/src/modules/m_banexception.cpp b/src/modules/m_banexception.cpp
index 782f55b92..31e593fdf 100644
--- a/src/modules/m_banexception.cpp
+++ b/src/modules/m_banexception.cpp
@@ -47,8 +47,8 @@ public:
ServerInstance->Modules->PublishInterface("ChannelBanList", this);
be.DoImplements(this);
- Implementation list[] = { I_OnRehash, I_OnRequest, I_On005Numeric, I_OnExtBanCheck, I_OnCheckChannelBan };
- ServerInstance->Modules->Attach(list, this, 5);
+ Implementation list[] = { I_OnRehash, I_On005Numeric, I_OnExtBanCheck, I_OnCheckChannelBan };
+ ServerInstance->Modules->Attach(list, this, 4);
}
@@ -121,11 +121,6 @@ public:
be.DoRehash();
}
- const char* OnRequest(Request* request)
- {
- return be.DoOnRequest(request);
- }
-
Version GetVersion()
{
return Version("Provides support for the +e channel mode", VF_COMMON | VF_VENDOR, API_VERSION);
diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp
index 33cb4d874..540155b81 100644
--- a/src/modules/m_banredirect.cpp
+++ b/src/modules/m_banredirect.cpp
@@ -213,8 +213,8 @@ class ModuleBanRedirect : public Module
OnRehash(NULL);
Extensible::Register(&re.extItem);
- Implementation list[] = { I_OnRehash, I_OnUserPreJoin, I_OnChannelDelete, I_OnCleanup };
- ServerInstance->Modules->Attach(list, this, 4);
+ Implementation list[] = { I_OnRehash, I_OnUserPreJoin, I_OnChannelDelete };
+ ServerInstance->Modules->Attach(list, this, 3);
}
virtual void OnChannelDelete(Channel* chan)
@@ -283,12 +283,12 @@ class ModuleBanRedirect : public Module
* Maybe we should have a GetFullIPHost() or something to match GetFullHost() and GetFullRealHost?
*/
- if (ExceptionModule)
+ ModResult result;
+ FIRST_MOD_RESULT(OnCheckChannelBan, result, (user, chan));
+ if (result == MOD_RES_ALLOW)
{
- ListModeRequest n(this, ExceptionModule, user, chan);
- /* Users with ban exceptions are allowed to join without being redirected */
- if (n.Send())
- return MOD_RES_PASSTHRU;
+ // they have a ban exception
+ return MOD_RES_PASSTHRU;
}
std::string ipmask(user->nick);
diff --git a/src/modules/m_cap.cpp b/src/modules/m_cap.cpp
index dbd81ed53..3373f7c3f 100644
--- a/src/modules/m_cap.cpp
+++ b/src/modules/m_cap.cpp
@@ -48,7 +48,7 @@ class CommandCAP : public Command
if (subcommand == "REQ")
{
- CapData Data;
+ CapEvent Data(creator, "cap_req");
Data.type = subcommand;
Data.user = user;
@@ -68,8 +68,7 @@ class CommandCAP : public Command
}
reghold.set(user, 1);
- Event event((char*) &Data, this->creator, "cap_req");
- event.Send();
+ Data.Send();
if (Data.ack.size() > 0)
{
@@ -89,15 +88,14 @@ class CommandCAP : public Command
}
else if ((subcommand == "LS") || (subcommand == "LIST"))
{
- CapData Data;
+ CapEvent Data(creator, subcommand == "LS" ? "cap_ls" : "cap_list");
Data.type = subcommand;
Data.user = user;
Data.creator = this->creator;
reghold.set(user, 1);
- Event event((char*) &Data, this->creator, subcommand == "LS" ? "cap_ls" : "cap_list");
- event.Send();
+ Data.Send();
std::string Result;
if (Data.wanted.size() > 0)
@@ -109,15 +107,14 @@ class CommandCAP : public Command
}
else if (subcommand == "CLEAR")
{
- CapData Data;
+ CapEvent Data(creator, "cap_clear");
Data.type = subcommand;
Data.user = user;
Data.creator = this->creator;
reghold.set(user, 1);
- Event event((char*) &Data, this->creator, "cap_clear");
- event.Send();
+ Data.Send();
std::string Result = irc::stringjoiner(" ", Data.ack, 0, Data.ack.size() - 1).GetJoined();
user->WriteServ("CAP * ACK :%s", Result.c_str());
diff --git a/src/modules/m_cap.h b/src/modules/m_cap.h
index a37580126..809b0f4cf 100644
--- a/src/modules/m_cap.h
+++ b/src/modules/m_cap.h
@@ -17,7 +17,7 @@
#include <map>
#include <string>
-class CapData : public classbase
+class CapEvent : public Event
{
public:
irc::string type;
@@ -25,6 +25,7 @@ class CapData : public classbase
std::vector<std::string> ack;
User* user;
Module* creator;
+ CapEvent(Module* sender, const std::string& t) : Event(sender, t) {}
};
class GenericCap
@@ -37,12 +38,11 @@ class GenericCap
Extensible::Register(&ext);
}
- void HandleEvent(Event* ev)
+ void HandleEvent(Event& ev)
{
- if (ev->GetEventID() == "cap_req")
+ CapEvent *data = static_cast<CapEvent*>(&ev);
+ if (ev.id == "cap_req")
{
- CapData *data = (CapData *) ev->GetData();
-
std::vector<std::string>::iterator it;
if ((it = std::find(data->wanted.begin(), data->wanted.end(), cap)) != data->wanted.end())
{
@@ -53,23 +53,19 @@ class GenericCap
}
}
- if (ev->GetEventID() == "cap_ls")
+ if (ev.id == "cap_ls")
{
- CapData *data = (CapData *) ev->GetData();
data->wanted.push_back(cap);
}
- if (ev->GetEventID() == "cap_list")
+ if (ev.id == "cap_list")
{
- CapData *data = (CapData *) ev->GetData();
-
if (ext.get(data->user))
data->wanted.push_back(cap);
}
- if (ev->GetEventID() == "cap_clear")
+ if (ev.id == "cap_clear")
{
- CapData *data = (CapData *) ev->GetData();
data->ack.push_back("-" + cap);
ext.set(data->user, 0);
}
diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp
index 1300092c7..d36a1d92a 100644
--- a/src/modules/m_cgiirc.cpp
+++ b/src/modules/m_cgiirc.cpp
@@ -155,8 +155,8 @@ public:
Extensible::Register(&cmd.webirc_hostname);
Extensible::Register(&cmd.webirc_ip);
- Implementation eventlist[] = { I_OnRehash, I_OnUserRegister, I_OnCleanup, I_OnSyncUser, I_OnDecodeMetaData, I_OnUserDisconnect, I_OnUserConnect };
- ServerInstance->Modules->Attach(eventlist, this, 7);
+ Implementation eventlist[] = { I_OnRehash, I_OnUserRegister, I_OnSyncUser, I_OnDecodeMetaData, I_OnUserDisconnect, I_OnUserConnect };
+ ServerInstance->Modules->Attach(eventlist, this, 6);
}
diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp
index b517d363e..bae2143d7 100644
--- a/src/modules/m_chanfilter.cpp
+++ b/src/modules/m_chanfilter.cpp
@@ -69,8 +69,8 @@ class ModuleChanFilter : public Module
throw ModuleException("Could not add new modes!");
cf.DoImplements(this);
- Implementation eventlist[] = { I_OnCleanup, I_OnChannelDelete, I_OnRehash, I_OnUserPreMessage, I_OnUserPreNotice, I_OnSyncChannel };
- ServerInstance->Modules->Attach(eventlist, this, 6);
+ Implementation eventlist[] = { I_OnChannelDelete, I_OnRehash, I_OnUserPreMessage, I_OnUserPreNotice, I_OnSyncChannel };
+ ServerInstance->Modules->Attach(eventlist, this, 5);
OnRehash(NULL);
ServerInstance->Modules->PublishInterface("ChannelBanList", this);
@@ -122,11 +122,6 @@ class ModuleChanFilter : public Module
cf.DoCleanup(target_type, item);
}
- virtual const char* OnRequest(Request* request)
- {
- return cf.DoOnRequest(request);
- }
-
virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
return OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index f8743d94c..ade4339b8 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -133,7 +133,6 @@ class CloakUser : public ModeHandler
{
unsigned int iv[] = { key1, key2, key3, key4 };
irc::sepstream seps(ip, '.');
- std::string ra[4];;
std::string octet[4];
int i[4];
@@ -148,17 +147,19 @@ class CloakUser : public ModeHandler
octet[1] = octet[0] + "." + octet[1];
/* Reset the Hash module and send it our IV */
- HashResetRequest(creator, HashProvider).Send();
- HashKeyRequest(creator, HashProvider, iv).Send();
+
+ std::string rv;
/* Send the Hash module a different hex table for each octet group's Hash sum */
for (int k = 0; k < 4; k++)
{
- HashHexRequest(creator, HashProvider, xtab[(iv[k]+i[k]) % 4]).Send();
- ra[k] = std::string(HashSumRequest(creator, HashProvider, octet[k]).Send()).substr(0,6);
+ HashRequestIV hash(creator, HashProvider, iv, xtab[(iv[k]+i[k]) % 4], octet[k]);
+ rv.append(hash.result.substr(0,6));
+ if (k < 3)
+ rv.append(".");
}
/* Stick them all together */
- return std::string().append(ra[0]).append(".").append(ra[1]).append(".").append(ra[2]).append(".").append(ra[3]);
+ return rv;
}
std::string Cloak6(const char* ip)
@@ -169,27 +170,22 @@ class CloakUser : public ModeHandler
int rounds = 0;
/* Reset the Hash module and send it our IV */
- HashResetRequest(creator, HashProvider).Send();
- HashKeyRequest(creator, HashProvider, iv).Send();
for (const char* input = ip; *input; input++)
{
item += *input;
if (item.length() > 7)
{
- /* Send the Hash module a different hex table for each octet group's Hash sum */
- HashHexRequest(creator, HashProvider, xtab[(key1+rounds) % 4]).Send();
- hashies.push_back(std::string(HashSumRequest(creator, HashProvider, item).Send()).substr(0,8));
+ HashRequestIV hash(creator, HashProvider, iv, xtab[(key1+rounds) % 4], item);
+ hashies.push_back(hash.result.substr(0,8));
item.clear();
}
rounds++;
}
if (!item.empty())
{
- /* Send the Hash module a different hex table for each octet group's Hash sum */
- HashHexRequest(creator, HashProvider, xtab[(key1+rounds) % 4]).Send();
- hashies.push_back(std::string(HashSumRequest(creator, HashProvider, item).Send()).substr(0,8));
- item.clear();
+ HashRequestIV hash(creator, HashProvider, iv, xtab[(key1+rounds) % 4], item);
+ hashies.push_back(hash.result.substr(0,8));
}
/* Stick them all together */
return irc::stringjoiner(":", hashies, 0, hashies.size() - 1).GetJoined();
@@ -370,12 +366,10 @@ class ModuleCloaking : public Module
if (!cu->ipalways)
{
/** Reset the Hash module, and send it our IV and hex table */
- HashResetRequest(this, cu->HashProvider).Send();
- HashKeyRequest(this, cu->HashProvider, iv).Send();
- HashHexRequest(this, cu->HashProvider, cu->xtab[(dest->host[0]) % 4]);
+ HashRequestIV hash(this, cu->HashProvider, iv, cu->xtab[(dest->host[0]) % 4], dest->host);
/* Generate a cloak using specialized Hash */
- std::string hostcloak = cu->prefix + "-" + std::string(HashSumRequest(this, cu->HashProvider, dest->host.c_str()).Send()).substr(0,8) + a;
+ std::string hostcloak = cu->prefix + "-" + hash.result.substr(0,8) + a;
/* Fix by brain - if the cloaked host is > the max length of a host (64 bytes
* according to the DNS RFC) then tough titty, they get cloaked as an IP.
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index ebb5a0038..5beb46fc4 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -443,7 +443,7 @@ void FilterBase::OnRehash(User* user)
{
for (modulelist::iterator i = ml->begin(); i != ml->end(); ++i)
{
- if (RegexNameRequest(this, *i).Send() == newrxengine)
+ if (RegexNameRequest(this, *i).result == newrxengine)
{
ServerInstance->SNO->WriteGlobalSno('a', "Filter now using engine '%s'", RegexEngine.c_str());
rxengine = *i;
@@ -460,7 +460,7 @@ void FilterBase::OnLoadModule(Module* mod, const std::string& name)
{
if (ServerInstance->Modules->ModuleHasInterface(mod, "RegularExpression"))
{
- std::string rxname = RegexNameRequest(this, mod).Send();
+ std::string rxname = RegexNameRequest(this, mod).result;
if (rxname == RegexEngine)
{
rxengine = mod;
diff --git a/src/modules/m_hash.h b/src/modules/m_hash.h
index 88dcb5b6d..f39d0eee7 100644
--- a/src/modules/m_hash.h
+++ b/src/modules/m_hash.h
@@ -19,176 +19,70 @@
#define SHA256_DIGEST_SIZE (256 / 8)
#define SHA256_BLOCK_SIZE (512 / 8)
-/** HashRequest is the base class used to send Hash requests to hashing.so.
- * You should not instantiate classes of type HashRequest directly, instead
- * you should instantiate classes of type HashResetRequest, HashSumRequest,
- * HashKeyRequest and HashHexRequest, shown below.
- */
-class HashRequest : public Request
-{
- /** The keys (IV) to use */
- unsigned int* keys;
- /** The output characters (hex sequence) to use */
- const char* outputs;
- /** The string to hash */
- std::string tohash;
- public:
- /** Initialize HashRequest as an Hash_RESET message */
- HashRequest(const char* req, Module* Me, Module* Target) : Request(Me, Target, req)
- {
- }
-
- /** Initialize HashRequest as an Hash_SUM message */
- HashRequest(Module* Me, Module* Target, const std::string &hashable) : Request(Me, Target, "SUM"), keys(NULL), outputs(NULL), tohash(hashable)
- {
- }
-
- /** Initialize HashRequest as an Hash_KEY message */
- HashRequest(Module* Me, Module* Target, unsigned int* k) : Request(Me, Target, "KEY"), keys(k), outputs(NULL), tohash("")
- {
- }
-
- /** Initialize HashRequest as an Hash_HEX message */
- HashRequest(Module* Me, Module* Target, const char* out) : Request(Me, Target, "HEX"), keys(NULL), outputs(out), tohash("")
- {
- }
-
- /** Get data to be hashed */
- std::string& GetHashData()
- {
- return tohash;
- }
-
- /** Get keys (IVs) to be used */
- unsigned int* GetKeyData()
- {
- return keys;
- }
-
- /** Get output characters (hex sequence) to be used */
- const char* GetOutputs()
- {
- return outputs;
- }
-};
-
-/** Send this class to the hashing module to query for its name.
+/** Query a hash algorithm's name
*
* Example:
* \code
- * cout << "Using hash algorithm: " << HashNameRequest(this, HashModule).Send();
+ * cout << "Using hash algorithm: " << HashNameRequest(this, HashModule).response;
* \endcode
*/
-class HashNameRequest : public HashRequest
+struct HashNameRequest : public Request
{
- public:
- /** Initialize HashNameRequest for sending.
- * @param Me A pointer to the sending module
- * @param Target A pointer to the hashing module
- */
- HashNameRequest(Module* Me, Module* Target) : HashRequest("NAME", Me, Target)
- {
- }
-};
-
-/** Send this class to the hashing module to reset the Hash module to a known state.
- * This will reset the IV to the defaults specified by the Hash spec,
- * and reset the hex sequence to "0123456789abcdef". It should be sent before
- * ANY other Request types.
- *
- * Example:
- * \code
- * // Reset the Hash module.
- * HashResetRequest(this, HashModule).Send();
- * \endcode
- */
-class HashResetRequest : public HashRequest
-{
- public:
- /** Initialize HashResetRequest for sending.
- * @param Me A pointer to the sending module
- * @param Target A pointer to the hashing module
- */
- HashResetRequest(Module* Me, Module* Target) : HashRequest("RESET", Me, Target)
+ std::string response;
+ HashNameRequest(Module* Me, Module* Target) : Request(Me, Target, "NAME")
{
+ Send();
}
};
/** Send this class to the hashing module to HashSUM a std::string.
- * You should make sure you know the state of the module before you send this
- * class, e.g. by first sending an HashResetRequest class. The hash will be
- * returned when you call Send().
*
* Example:
* \code
- * // ALWAYS ALWAYS reset first, or set your own IV and hex chars.
- * HashResetRequest(this, HashModule).Send();
* // Get the Hash sum of the string 'doodads'.
- * std::string result = HashSumRequest(this, HashModule, "doodads").Send();
+ * std::string result = HashRequest(this, HashModule, "doodads").result;
* \endcode
*/
-class HashSumRequest : public HashRequest
+struct HashRequest : public Request
{
- public:
+ const std::string data;
+ std::string result;
/** Initialize HashSumRequest for sending.
* @param Me A pointer to the sending module
* @param Target A pointer to the hashing module
* @param data The data to be hashed
*/
- HashSumRequest(Module* Me, Module* Target, const std::string &sdata) : HashRequest(Me, Target, sdata)
+ HashRequest(Module* Me, Module* Target, const std::string &sdata)
+ : Request(Me, Target, "HASH"), data(sdata)
{
+ Send();
}
};
-/** Send this class to hashing module to change the IVs (keys) to use for hashing.
- * You should make sure you know the state of the module before you send this
- * class, e.g. by first sending an HashResetRequest class. The default values for
- * the IV's are those specified in the Hash specification. Only in very special
- * circumstances should you need to change the IV's (see for example m_cloaking.cpp)
+/** Allows the IVs for the hash to be specified. As the choice of initial IV is
+ * important for the security of a hash, this should not be used except to
+ * maintain backwards compatability. This also allows you to change the hex
+ * sequence from its default of "0123456789abcdef", which does not improve the
+ * strength of the output, but helps confuse those attempting to implement it.
*
- * Example:
- * \code
- * unsigned int iv[] = { 0xFFFFFFFF, 0x00000000, 0xAAAAAAAA, 0xCCCCCCCC };
- * HashKeyRequest(this, HashModule, iv);
- * \endcode
- */
-class HashKeyRequest : public HashRequest
-{
- public:
- /** Initialize HashKeyRequest for sending.
- * @param Me A pointer to the sending module
- * @param Target A pointer to the hashing module
- * @param data The new IV's. This should be an array of exactly four 32 bit values.
- * On 64-bit architectures, the upper 32 bits of the values will be discarded.
- */
- HashKeyRequest(Module* Me, Module* Target, unsigned int* sdata) : HashRequest(Me, Target, sdata)
- {
- }
-};
-
-/** Send this class to the hashing module to change the hex sequence to use for generating the returned value.
- * You should make sure you know the state of the module before you send this
- * class, e.g. by first sending an HashResetRequest class. The default value for
- * the hex sequence is "0123456789abcdef". Only in very special circumstances should
- * you need to change the hex sequence (see for example m_cloaking.cpp).
+ * Only m_md5 implements this request; only m_cloaking should use it.
*
* Example:
* \code
- * static const char tab[] = "fedcba9876543210";
- * HashHexRequest(this, HashModule, tab);
+ * unsigned int iv[] = { 0xFFFFFFFF, 0x00000000, 0xAAAAAAAA, 0xCCCCCCCC };
+ * std::string result = HashRequestIV(this, HashModule, iv, "0123456789abcdef", "data").result;
* \endcode
*/
-class HashHexRequest : public HashRequest
+struct HashRequestIV : public Request
{
- public:
- /** Initialize HashHexRequest for sending.
- * @param Me A pointer to the sending module
- * @param Target A pointer to the hashing module
- * @param data The hex sequence to use. This should contain exactly 16 ASCII characters,
- * terminated by a NULL char.
- */
- HashHexRequest(Module* Me, Module* Target, const char* sdata) : HashRequest(Me, Target, sdata)
+ unsigned int* iv;
+ const char* map;
+ std::string result;
+ const std::string data;
+ HashRequestIV(Module* Me, Module* Target, unsigned int* IV, const char* HexMap, const std::string &sdata)
+ : Request(Me, Target, "HASH-IV"), iv(IV), map(HexMap), data(sdata)
{
+ Send();
}
};
diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp
index e9d05d3e5..9d1acfbb9 100644
--- a/src/modules/m_httpd.cpp
+++ b/src/modules/m_httpd.cpp
@@ -313,13 +313,12 @@ class HttpServerSocket : public BufferedSocket
else
{
claimed = false;
- HTTPRequest httpr(request_type,uri,&headers,this,ip,postdata);
- Event acl((char*)&httpr, (Module*)HttpModule, "httpd_acl");
+ HTTPRequest acl((Module*)HttpModule, "httpd_acl", request_type, uri, &headers, this, ip, postdata);
acl.Send();
if (!claimed)
{
- Event e((char*)&httpr, (Module*)HttpModule, "httpd_url");
- e.Send();
+ HTTPRequest url((Module*)HttpModule, "httpd_url", request_type, uri, &headers, this, ip, postdata);
+ url.Send();
if (!claimed)
{
SendHTTPError(404);
@@ -384,7 +383,7 @@ class ModuleHttpServer : public Module
index = new FileReader(indexfile);
if (!index->Exists())
throw ModuleException("Can't read index file: "+indexfile);
- http = new HttpListener(index, port, (char *)bindip.c_str()); // XXX this cast SUCKS.
+ http = new HttpListener(index, port, bindip);
httplisteners.push_back(http);
}
}
@@ -392,17 +391,15 @@ class ModuleHttpServer : public Module
ModuleHttpServer() {
ReadConfig();
HttpModule = this;
- Implementation eventlist[] = { I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 1);
}
- virtual const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
+ if (strcmp(request.id, "HTTP-DOC") != 0)
+ return;
+ HTTPDocumentResponse& resp = static_cast<HTTPDocumentResponse&>(request);
claimed = true;
- HTTPDocument* doc = (HTTPDocument*)request->GetData();
- HttpServerSocket* sock = (HttpServerSocket*)doc->sock;
- sock->Page(doc->GetDocument(), doc->GetResponseCode(), &doc->headers);
- return NULL;
+ resp.src.sock->Page(resp.document, resp.responsecode, &resp.headers);
}
diff --git a/src/modules/m_httpd_acl.cpp b/src/modules/m_httpd_acl.cpp
index 8c682cfa9..dd68f3087 100644
--- a/src/modules/m_httpd_acl.cpp
+++ b/src/modules/m_httpd_acl.cpp
@@ -90,21 +90,20 @@ class ModuleHTTPAccessList : public Module
ModuleHTTPAccessList() {
ReadConfig();
- Implementation eventlist[] = { I_OnEvent, I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 2);
+ Implementation eventlist[] = { I_OnEvent };
+ ServerInstance->Modules->Attach(eventlist, this, 1);
}
- void BlockAccess(HTTPRequest* http, Event* event, int returnval, const std::string &extraheaderkey = "", const std::string &extraheaderval="")
+ void BlockAccess(HTTPRequest* http, int returnval, const std::string &extraheaderkey = "", const std::string &extraheaderval="")
{
ServerInstance->Logs->Log("m_httpd_acl", DEBUG, "BlockAccess (%d)", returnval);
std::stringstream data("Access to this resource is denied by an access control list. Please contact your IRC administrator.");
- HTTPDocument response(http->sock, &data, returnval);
+ HTTPDocumentResponse response(this, *http, &data, returnval);
response.headers.SetHeader("X-Powered-By", "m_httpd_acl.so");
if (!extraheaderkey.empty())
response.headers.SetHeader(extraheaderkey, extraheaderval);
- Request req((char*)&response, (Module*)this, event->GetSource());
- req.Send();
+ response.Send();
}
bool IsBase64(unsigned char c)
@@ -162,12 +161,12 @@ class ModuleHTTPAccessList : public Module
return retval;
}
- void OnEvent(Event* event)
+ void OnEvent(Event& event)
{
- if (event->GetEventID() == "httpd_acl")
+ if (event.id == "httpd_acl")
{
ServerInstance->Logs->Log("m_http_stats", DEBUG,"Handling httpd acl event");
- HTTPRequest* http = (HTTPRequest*)event->GetData();
+ HTTPRequest* http = (HTTPRequest*)&event;
for (std::vector<HTTPACL>::const_iterator this_acl = acl_list.begin(); this_acl != acl_list.end(); ++this_acl)
{
@@ -185,7 +184,7 @@ class ModuleHTTPAccessList : public Module
{
ServerInstance->Logs->Log("m_httpd_acl", DEBUG, "Denying access to blacklisted resource %s (matched by pattern %s) from ip %s (matched by entry %s)",
http->GetURI().c_str(), this_acl->path.c_str(), http->GetIP().c_str(), entry.c_str());
- BlockAccess(http, event, 403);
+ BlockAccess(http, 403);
return;
}
}
@@ -207,7 +206,7 @@ class ModuleHTTPAccessList : public Module
{
ServerInstance->Logs->Log("m_httpd_acl", DEBUG, "Denying access to whitelisted resource %s (matched by pattern %s) from ip %s (Not in whitelist)",
http->GetURI().c_str(), this_acl->path.c_str(), http->GetIP().c_str());
- BlockAccess(http, event, 403);
+ BlockAccess(http, 403);
return;
}
}
@@ -248,20 +247,20 @@ class ModuleHTTPAccessList : public Module
}
else
/* Invalid password */
- BlockAccess(http, event, 401, "WWW-Authenticate", "Basic realm=\"Restricted Object\"");
+ BlockAccess(http, 401, "WWW-Authenticate", "Basic realm=\"Restricted Object\"");
}
else
/* Malformed user:pass pair */
- BlockAccess(http, event, 401, "WWW-Authenticate", "Basic realm=\"Restricted Object\"");
+ BlockAccess(http, 401, "WWW-Authenticate", "Basic realm=\"Restricted Object\"");
}
else
/* Unsupported authentication type */
- BlockAccess(http, event, 401, "WWW-Authenticate", "Basic realm=\"Restricted Object\"");
+ BlockAccess(http, 401, "WWW-Authenticate", "Basic realm=\"Restricted Object\"");
}
else
{
/* No password given at all, access denied */
- BlockAccess(http, event, 401, "WWW-Authenticate", "Basic realm=\"Restricted Object\"");
+ BlockAccess(http, 401, "WWW-Authenticate", "Basic realm=\"Restricted Object\"");
}
}
@@ -272,11 +271,6 @@ class ModuleHTTPAccessList : public Module
}
}
- const char* OnRequest(Request* request)
- {
- return NULL;
- }
-
virtual ~ModuleHTTPAccessList()
{
}
diff --git a/src/modules/m_httpd_config.cpp b/src/modules/m_httpd_config.cpp
index 55f943d2c..988ba3977 100644
--- a/src/modules/m_httpd_config.cpp
+++ b/src/modules/m_httpd_config.cpp
@@ -35,8 +35,8 @@ class ModuleHttpStats : public Module
ModuleHttpStats() {
ReadConfig();
this->changed = true;
- Implementation eventlist[] = { I_OnEvent, I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 2);
+ Implementation eventlist[] = { I_OnEvent };
+ ServerInstance->Modules->Attach(eventlist, this, 1);
}
std::string Sanitize(const std::string &str)
@@ -73,14 +73,14 @@ class ModuleHttpStats : public Module
return ret;
}
- void OnEvent(Event* event)
+ void OnEvent(Event& event)
{
std::stringstream data("");
- if (event->GetEventID() == "httpd_url")
+ if (event.id == "httpd_url")
{
ServerInstance->Logs->Log("m_http_stats", DEBUG,"Handling httpd event");
- HTTPRequest* http = (HTTPRequest*)event->GetData();
+ HTTPRequest* http = (HTTPRequest*)&event;
if ((http->GetURI() == "/config") || (http->GetURI() == "/config/"))
{
@@ -99,21 +99,14 @@ class ModuleHttpStats : public Module
data << "</body></html>";
/* Send the document back to m_httpd */
- HTTPDocument response(http->sock, &data, 200);
+ HTTPDocumentResponse response(this, *http, &data, 200);
response.headers.SetHeader("X-Powered-By", "m_httpd_config.so");
response.headers.SetHeader("Content-Type", "text/html");
- Request req((char*)&response, (Module*)this, event->GetSource());
- req.Send();
+ response.Send();
}
}
}
- const char* OnRequest(Request* request)
- {
- return NULL;
- }
-
-
virtual ~ModuleHttpStats()
{
}
diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp
index 46f474e2d..5e30c90ca 100644
--- a/src/modules/m_httpd_stats.cpp
+++ b/src/modules/m_httpd_stats.cpp
@@ -35,8 +35,8 @@ class ModuleHttpStats : public Module
ModuleHttpStats() {
ReadConfig();
this->changed = true;
- Implementation eventlist[] = { I_OnEvent, I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 2);
+ Implementation eventlist[] = { I_OnEvent };
+ ServerInstance->Modules->Attach(eventlist, this, 1);
}
std::string Sanitize(const std::string &str)
@@ -67,14 +67,14 @@ class ModuleHttpStats : public Module
return ret;
}
- void OnEvent(Event* event)
+ void OnEvent(Event& event)
{
std::stringstream data("");
- if (event->GetEventID() == "httpd_url")
+ if (event.id == "httpd_url")
{
ServerInstance->Logs->Log("m_http_stats", DEBUG,"Handling httpd event");
- HTTPRequest* http = (HTTPRequest*)event->GetData();
+ HTTPRequest* http = (HTTPRequest*)&event;
if ((http->GetURI() == "/stats") || (http->GetURI() == "/stats/"))
{
@@ -172,21 +172,14 @@ class ModuleHttpStats : public Module
data << "</inspircdstats>";
/* Send the document back to m_httpd */
- HTTPDocument response(http->sock, &data, 200);
+ HTTPDocumentResponse response(this, *http, &data, 200);
response.headers.SetHeader("X-Powered-By", "m_httpd_stats.so");
response.headers.SetHeader("Content-Type", "text/xml");
- Request req((char*)&response, (Module*)this, event->GetSource());
- req.Send();
+ response.Send();
}
}
}
- const char* OnRequest(Request* request)
- {
- return NULL;
- }
-
-
virtual ~ModuleHttpStats()
{
}
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index d74873e00..0ba9e6e3a 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -283,8 +283,8 @@ class ModuleIdent : public Module
{
Conf = new ConfigReader;
OnRehash(NULL);
- Implementation eventlist[] = { I_OnRehash, I_OnUserRegister, I_OnCheckReady, I_OnCleanup, I_OnUserDisconnect };
- ServerInstance->Modules->Attach(eventlist, this, 5);
+ Implementation eventlist[] = { I_OnRehash, I_OnUserRegister, I_OnCheckReady, I_OnUserDisconnect };
+ ServerInstance->Modules->Attach(eventlist, this, 4);
}
~ModuleIdent()
diff --git a/src/modules/m_inviteexception.cpp b/src/modules/m_inviteexception.cpp
index b71992c05..91f4e22c8 100644
--- a/src/modules/m_inviteexception.cpp
+++ b/src/modules/m_inviteexception.cpp
@@ -46,8 +46,8 @@ public:
ServerInstance->Modules->PublishInterface("ChannelBanList", this);
ie.DoImplements(this);
- Implementation eventlist[] = { I_OnRequest, I_On005Numeric, I_OnCheckInvite };
- ServerInstance->Modules->Attach(eventlist, this, 3);
+ Implementation eventlist[] = { I_On005Numeric, I_OnCheckInvite };
+ ServerInstance->Modules->Attach(eventlist, this, 2);
}
void On005Numeric(std::string &output)
@@ -77,11 +77,6 @@ public:
return MOD_RES_PASSTHRU;
}
- const char* OnRequest(Request* request)
- {
- return ie.DoOnRequest(request);
- }
-
void OnCleanup(int target_type, void* item)
{
ie.DoCleanup(target_type, item);
diff --git a/src/modules/m_md5.cpp b/src/modules/m_md5.cpp
index 911f6d926..00d3fb1e9 100644
--- a/src/modules/m_md5.cpp
+++ b/src/modules/m_md5.cpp
@@ -259,17 +259,11 @@ class ModuleMD5 : public Module
*dest++ = 0;
}
- unsigned int *key;
- char* chars;
-
public:
ModuleMD5()
- : key(NULL), chars(NULL)
{
ServerInstance->Modules->PublishInterface("HashRequest", this);
- Implementation eventlist[] = { I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 1);
}
virtual ~ModuleMD5()
@@ -278,37 +272,29 @@ class ModuleMD5 : public Module
}
- virtual const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- HashRequest* MD5 = (HashRequest*)request;
-
- if (strcmp("KEY", request->GetId()) == 0)
- {
- this->key = (unsigned int*)MD5->GetKeyData();
- }
- else if (strcmp("HEX", request->GetId()) == 0)
- {
- this->chars = (char*)MD5->GetOutputs();
- }
- else if (strcmp("SUM", request->GetId()) == 0)
+ if (strcmp("HASH", request.id) == 0)
{
- static char data[MAXBUF];
- GenHash(MD5->GetHashData().data(), data, chars ? chars : "0123456789abcdef", key, MD5->GetHashData().length());
- return data;
+ char res[33];
+ HashRequest& req = static_cast<HashRequest&>(request);
+ GenHash(req.data.data(), res, "0123456789abcdef", NULL, req.data.length());
+ req.result = res;
}
- else if (strcmp("NAME", request->GetId()) == 0)
+ else if (strcmp("HASH-IV", request.id) == 0)
{
- return "md5";
+ char res[33];
+ HashRequestIV& req = static_cast<HashRequestIV&>(request);
+ GenHash(req.data.data(), res, req.map, req.iv, req.data.length());
+ req.result = res;
}
- else if (strcmp("RESET", request->GetId()) == 0)
+ else if (strcmp("NAME", request.id) == 0)
{
- this->chars = NULL;
- this->key = NULL;
+ static_cast<HashNameRequest&>(request).response = "md5";
}
- return NULL;
}
- virtual Version GetVersion()
+ Version GetVersion()
{
return Version("Allows for MD5 encrypted oper passwords",VF_VENDOR|VF_SERVICEPROVIDER,API_VERSION);
}
diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp
index 7614cdc76..093ebc64f 100644
--- a/src/modules/m_namesx.cpp
+++ b/src/modules/m_namesx.cpp
@@ -72,7 +72,7 @@ class ModuleNamesX : public Module
prefixes = memb->chan->GetAllPrefixChars(memb->user);
}
- void OnEvent(Event *ev)
+ void OnEvent(Event& ev)
{
cap.HandleEvent(ev);
}
diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp
index 8162d45e3..c737be286 100644
--- a/src/modules/m_override.cpp
+++ b/src/modules/m_override.cpp
@@ -12,7 +12,6 @@
*/
#include "inspircd.h"
-#include "m_override.h"
/* $ModDesc: Provides support for unreal-style oper-override */
@@ -31,12 +30,8 @@ class ModuleOverride : public Module
// read our config options (main config file)
OnRehash(NULL);
ServerInstance->SNO->EnableSnomask('G', "GODMODE");
- if (!ServerInstance->Modules->PublishFeature("Override", this))
- {
- throw ModuleException("m_override: Unable to publish feature 'Override'");
- }
- Implementation eventlist[] = { I_OnRehash, I_OnPreMode, I_On005Numeric, I_OnUserPreJoin, I_OnUserPreKick, I_OnPreTopicChange, I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 7);
+ Implementation eventlist[] = { I_OnRehash, I_OnPreMode, I_On005Numeric, I_OnUserPreJoin, I_OnUserPreKick, I_OnPreTopicChange };
+ ServerInstance->Modules->Attach(eventlist, this, 6);
}
void OnRehash(User* user)
@@ -205,19 +200,8 @@ class ModuleOverride : public Module
return MOD_RES_PASSTHRU;
}
- const char* OnRequest(Request* request)
- {
- if(strcmp(OVRREQID, request->GetId()) == 0)
- {
- OVRrequest* req = static_cast<OVRrequest*>(request);
- return this->CanOverride(req->requser,req->reqtoken.c_str()) ? "yes":"";
- }
- return NULL;
- }
-
~ModuleOverride()
{
- ServerInstance->Modules->UnpublishFeature("Override");
ServerInstance->SNO->DisableSnomask('G');
}
diff --git a/src/modules/m_override.h b/src/modules/m_override.h
deleted file mode 100755
index f17e78e76..000000000
--- a/src/modules/m_override.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "modules.h"
-#define OVRREQID "Override Request"
-class OVRrequest : public Request
-{
-public:
-User * requser;
-std::string reqtoken;
-OVRrequest(Module* s, Module* d, User* src, const std::string &token)
- : Request(s, d, OVRREQID), reqtoken(token)
- {
- requser = src;
- }
-};
diff --git a/src/modules/m_password_hash.cpp b/src/modules/m_password_hash.cpp
index 12769acd4..b9fcb63a4 100644
--- a/src/modules/m_password_hash.cpp
+++ b/src/modules/m_password_hash.cpp
@@ -12,7 +12,6 @@
*/
/* $ModDesc: Allows for hashed oper passwords */
-/* $ModDep: m_hash.h */
#include "inspircd.h"
#include "m_hash.h"
@@ -38,10 +37,10 @@ class CommandMkpasswd : public Command
hashymodules::iterator x = hashers.find(algo);
if (x != hashers.end())
{
- /* Yup, reset it first (Always ALWAYS do this) */
- HashResetRequest(creator, x->second).Send();
+ HashRequest hash(creator, x->second, stuff);
/* Now attempt to generate a hash */
- user->WriteServ("NOTICE %s :%s hashed password for %s is %s",user->nick.c_str(), algo, stuff, HashSumRequest(creator, x->second, stuff).Send() );
+ user->WriteServ("NOTICE %s :%s hashed password for %s is %s",
+ user->nick.c_str(), algo, stuff, hash.result.c_str());
}
else if (names.empty())
{
@@ -94,7 +93,7 @@ class ModuleOperHash : public Module
/* Make a request to it for its name, its implementing
* HashRequest so we know its safe to do this
*/
- std::string name = HashNameRequest(this, *m).Send();
+ std::string name = HashNameRequest(this, *m).response;
/* Build a map of them */
hashers[name.c_str()] = *m;
names.push_back(name);
@@ -120,7 +119,7 @@ class ModuleOperHash : public Module
if (ServerInstance->Modules->ModuleHasInterface(mod, "HashRequest"))
{
ServerInstance->Logs->Log("m_password-hash",DEBUG, "Post-load registering hasher: %s", name.c_str());
- std::string sname = HashNameRequest(this, mod).Send();
+ std::string sname = HashNameRequest(this, mod).response;
hashers[sname.c_str()] = mod;
names.push_back(sname);
if (!diduseiface)
@@ -139,10 +138,8 @@ class ModuleOperHash : public Module
/* Is this a valid hash name? (case insensitive) */
if (x != hashers.end())
{
- /* Reset the hashing module */
- HashResetRequest(this, x->second).Send();
/* Compare the hash in the config to the generated hash */
- if (!strcasecmp(data.c_str(), HashSumRequest(this, x->second, input.c_str()).Send()))
+ if (!strcasecmp(data.c_str(), HashRequest(this, x->second, input).result.c_str()))
return MOD_RES_ALLOW;
/* No match, and must be hashed, forbid */
else
diff --git a/src/modules/m_regex.h b/src/modules/m_regex.h
index c8cbc10b6..969c4920b 100644
--- a/src/modules/m_regex.h
+++ b/src/modules/m_regex.h
@@ -67,8 +67,10 @@ public:
class RegexNameRequest : public Request
{
public:
+ std::string result;
RegexNameRequest(Module* Me, Module* Target) : Request(Me, Target, "REGEX-NAME")
{
+ Send();
}
};
diff --git a/src/modules/m_regex_glob.cpp b/src/modules/m_regex_glob.cpp
index ef843cc76..a3923205f 100644
--- a/src/modules/m_regex_glob.cpp
+++ b/src/modules/m_regex_glob.cpp
@@ -15,7 +15,6 @@
#include "inspircd.h"
/* $ModDesc: Regex module using plain wildcard matching. */
-/* $ModDep: m_regex.h */
class GlobRegex : public Regex
{
@@ -39,13 +38,11 @@ class ModuleRegexGlob : public Module
public:
ModuleRegexGlob() {
ServerInstance->Modules->PublishInterface("RegularExpression", this);
- Implementation eventlist[] = { I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 1);
}
virtual Version GetVersion()
{
- return Version("Regex module using plain wildcard matching.", VF_COMMON | VF_VENDOR | VF_SERVICEPROVIDER, API_VERSION);
+ return Version("Regex module using plain wildcard matching.", VF_OPTCOMMON | VF_VENDOR | VF_SERVICEPROVIDER);
}
virtual ~ModuleRegexGlob()
@@ -53,20 +50,18 @@ public:
ServerInstance->Modules->UnpublishInterface("RegularExpression", this);
}
- virtual const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- if (strcmp("REGEX-NAME", request->GetId()) == 0)
+ if (strcmp("REGEX-NAME", request.id) == 0)
{
- return "glob";
+ static_cast<RegexNameRequest&>(request).result = "glob";
}
- else if (strcmp("REGEX", request->GetId()) == 0)
+ else if (strcmp("REGEX", request.id) == 0)
{
- RegexFactoryRequest* rfr = (RegexFactoryRequest*)request;
- std::string rx = rfr->GetRegex();
- rfr->result = new GlobRegex(rx);
- return "OK";
+ RegexFactoryRequest& rfr = (RegexFactoryRequest&)request;
+ std::string rx = rfr.GetRegex();
+ rfr.result = new GlobRegex(rx);
}
- return NULL;
}
};
diff --git a/src/modules/m_ripemd160.cpp b/src/modules/m_ripemd160.cpp
index 1d3b1eb34..3e94efb0a 100644
--- a/src/modules/m_ripemd160.cpp
+++ b/src/modules/m_ripemd160.cpp
@@ -149,6 +149,8 @@ typedef uint32_t dword;
}
+const char* const chars = "0123456789abcdef";
+
class ModuleRIPEMD160 : public Module
{
@@ -437,16 +439,11 @@ class ModuleRIPEMD160 : public Module
return (byte *)hashcode;
}
- unsigned int* currkey;
- const char* chars;
-
public:
- ModuleRIPEMD160() : currkey(NULL), chars("0123456789abcdef")
+ ModuleRIPEMD160()
{
ServerInstance->Modules->PublishInterface("HashRequest", this);
- Implementation eventlist[] = { I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 1);
}
virtual ~ModuleRIPEMD160()
@@ -454,42 +451,26 @@ class ModuleRIPEMD160 : public Module
ServerInstance->Modules->UnpublishInterface("HashRequest", this);
}
-
- virtual const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- HashRequest* SHA = (HashRequest*)request;
- if (strcmp("KEY", request->GetId()) == 0)
- {
- this->currkey = (unsigned int*)SHA->GetKeyData();
- }
- else if (strcmp("HEX", request->GetId()) == 0)
+ if (strcmp("HASH", request.id) == 0)
{
- this->chars = SHA->GetOutputs();
- }
- else if (strcmp("SUM", request->GetId()) == 0)
- {
- static char output[MAXBUF];
- unsigned char* data = (unsigned char*)RMD((byte *)SHA->GetHashData().data(),SHA->GetHashData().length(), currkey);
+ char res[41];
+ HashRequest& req = static_cast<HashRequest&>(request);
+ unsigned char* data = (unsigned char*)RMD((byte*)req.data.data(), req.data.length(), NULL);
int j = 0;
for (int i = 0; i < RMDsize / 8; i++)
{
- output[j++] = chars[data[i] / 16];
- output[j++] = chars[data[i] % 16];
- ServerInstance->Logs->Log("m_ripemd160", DEBUG, "Hash: %02x", data[i]);
+ res[j++] = chars[data[i] / 16];
+ res[j++] = chars[data[i] % 16];
}
- output[j] = '\0';
- return output;
- }
- else if (strcmp("NAME", request->GetId()) == 0)
- {
- return "ripemd160";
+ res[j] = '\0';
+ req.result = res;
}
- else if (strcmp("RESET", request->GetId()) == 0)
+ else if (strcmp("NAME", request.id) == 0)
{
- this->chars = "0123456789abcdef";
- this->currkey = NULL;
+ static_cast<HashNameRequest&>(request).response = "ripemd160";
}
- return NULL;
}
virtual Version GetVersion()
diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp
index 31b382a22..a1a57199a 100644
--- a/src/modules/m_rline.cpp
+++ b/src/modules/m_rline.cpp
@@ -268,7 +268,7 @@ class ModuleRLine : public Module
{
for (modulelist::iterator i = ml->begin(); i != ml->end(); ++i)
{
- if (RegexNameRequest(this, *i).Send() == newrxengine)
+ if (RegexNameRequest(this, *i).result == newrxengine)
{
ServerInstance->SNO->WriteToSnoMask('a', "R-Line now using engine '%s'", RegexEngine.c_str());
rxengine = *i;
@@ -294,7 +294,7 @@ class ModuleRLine : public Module
{
if (ServerInstance->Modules->ModuleHasInterface(mod, "RegularExpression"))
{
- std::string rxname = RegexNameRequest(this, mod).Send();
+ std::string rxname = RegexNameRequest(this, mod).result;
if (rxname == RegexEngine)
{
ServerInstance->SNO->WriteToSnoMask('a', "R-Line now using engine '%s'", RegexEngine.c_str());
diff --git a/src/modules/m_rpc_json.cpp b/src/modules/m_rpc_json.cpp
deleted file mode 100644
index e57bb77b5..000000000
--- a/src/modules/m_rpc_json.cpp
+++ /dev/null
@@ -1,368 +0,0 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "httpd.h"
-#include "rpc.h"
-#include <exception>
-
-/* $ModDesc: Encode and decode JSON-RPC requests for modules */
-/* $ModDep: httpd.h rpc.h */
-
-class JsonException : public std::exception
-{
- private:
- std::string _what;
- public:
- JsonException(const std::string &swhat)
- : _what(swhat)
- {
- }
-
- virtual ~JsonException() throw() { }
-
- virtual const char *what() const throw()
- {
- return _what.c_str();
- }
-};
-
-class ModuleRpcJson : public Module
-{
- private:
-
- public:
- ModuleRpcJson()
- {
- ServerInstance->Modules->PublishInterface("RPC", this);
- Implementation eventlist[] = { I_OnEvent };
- ServerInstance->Modules->Attach(eventlist, this, 1);
- }
-
- virtual ~ModuleRpcJson()
- {
- ServerInstance->Modules->UnpublishInterface("RPC", this);
- }
-
- virtual Version GetVersion()
- {
- return Version("Encode and decode JSON-RPC requests for modules", VF_SERVICEPROVIDER | VF_VENDOR, API_VERSION);
- }
-
-
- virtual void OnEvent(Event *event)
- {
- if (event->GetEventID() == "httpd_url")
- {
- HTTPRequest *req = (HTTPRequest*) event->GetData();
-
- if ((req->GetURI() == "/rpc/json") || (req->GetURI() == "/rpc/json/"))
- {
- std::stringstream data;
-
- RPCValue *reqobj = NULL;
-
- try
- {
- reqobj = this->JSONParse(req->GetPostData());
-
- if (!reqobj || (reqobj->GetType() != RPCObject))
- throw JsonException("RPC requests must be in the form of a single object");
-
- RPCValue *method = reqobj->GetObject("method");
- if (!method || method->GetType() != RPCString)
- throw JsonException("RPC requests must have a 'method' string field");
-
- RPCValue *params = reqobj->GetObject("params");
- if (!params || params->GetType() != RPCArray)
- throw JsonException("RPC requests must have a 'params' array field");
-
- RPCRequest modreq("json", method->GetString(), params);
- Event mev((char*) &modreq, this, "RPCMethod");
- mev.Send();
-
- if (!modreq.claimed)
- throw JsonException("Unrecognized method");
-
- if (!modreq.error.empty())
- {
- data << "{\"result\":null,\"error\":\"" << modreq.error << "\"";
- }
- else
- {
- data << "{\"result\":";
- this->JSONSerialize(modreq.result, data);
- data << ",\"error\":null";
- }
-
- if (reqobj->GetObject("id"))
- {
- data << ",\"id\":";
- this->JSONSerialize(reqobj->GetObject("id"), data);
- }
- data << "}";
-
- delete reqobj;
- reqobj = NULL;
- }
- catch (std::exception &e)
- {
- if (reqobj)
- delete reqobj;
- data << "{\"result\":null,\"error\":\"" << e.what() << "\"}";
- }
-
- HTTPDocument response(req->sock, &data, 200);
- response.headers.SetHeader("X-Powered-By", "m_rpc_json.so");
- response.headers.SetHeader("Content-Type", "application/json");
- response.headers.SetHeader("Connection", "Keep-Alive");
-
- Request rreq((char*) &response, (Module*) this, event->GetSource());
- rreq.Send();
- }
- }
- }
-
- void AttachToParent(RPCValue *parent, RPCValue *child, const std::string &key = "")
- {
- if (!parent || !child)
- return;
-
- if (parent->GetType() == RPCArray)
- parent->ArrayAdd(child);
- else if (parent->GetType() == RPCObject)
- parent->ObjectAdd(key, child);
- else
- throw JsonException("Cannot add a value to a non-container");
- }
-
- void AttachToParentReset(RPCValue *parent, RPCValue *&child, std::string &key)
- {
- AttachToParent(parent, child, key);
- child = NULL;
- key.clear();
- }
-
- RPCValue *JSONParse(const std::string &data)
- {
- bool pisobject = false;
- bool instring = false;
- std::string stmp;
- std::string vkey;
- std::string pvkey;
- RPCValue *aparent = NULL;
- RPCValue *value = NULL;
-
- for (std::string::const_iterator i = data.begin(); i != data.end(); i++)
- {
- if (instring)
- {
- // TODO escape sequences
- if (*i == '"')
- {
- instring = false;
-
- if (pisobject && vkey.empty())
- vkey = stmp;
- else
- value = new RPCValue(stmp);
-
- stmp.clear();
- }
- else
- stmp += *i;
-
- continue;
- }
-
- if ((*i == ' ') || (*i == '\t') || (*i == '\r') || (*i == '\n'))
- continue;
-
- if (*i == '{')
- {
- // Begin object
- if ((value) || (pisobject && vkey.empty()))
- throw JsonException("Unexpected begin object token ('{')");
-
- RPCValue *nobj = new RPCValue(RPCObject, aparent);
- aparent = nobj;
- pvkey = vkey;
- vkey.clear();
- pisobject = true;
- }
- else if (*i == '}')
- {
- // End object
- if ((!aparent) || (!pisobject) || (!vkey.empty() && !value))
- throw JsonException("Unexpected end object token ('}')");
-
- // End value
- if (value)
- AttachToParentReset(aparent, value, vkey);
-
- if (!aparent->parent)
- return aparent;
-
- value = aparent;
- aparent = aparent->parent;
- vkey = pvkey;
- pvkey.clear();
- pisobject = (aparent->GetType() == RPCObject);
- }
- else if (*i == '"')
- {
- // Begin string
- if (value)
- throw JsonException("Unexpected begin string token ('\"')");
-
- instring = true;
- }
- else if (*i == ':')
- {
- if ((!aparent) || (!pisobject) || (vkey.empty()) || (value))
- throw JsonException("Unexpected object value token (':')");
- }
- else if (*i == ',')
- {
- if ((!aparent) || (!value) || ((pisobject) && (vkey.empty())))
- throw JsonException("Unexpected value seperator token (',')");
-
- AttachToParentReset(aparent, value, vkey);
- }
- else if (*i == '[')
- {
- // Begin array
- if ((value) || (pisobject && vkey.empty()))
- throw JsonException("Unexpected begin array token ('[')");
-
- RPCValue *nar = new RPCValue(RPCArray, aparent);
- aparent = nar;
- pvkey = vkey;
- vkey.clear();
- pisobject = false;
- }
- else if (*i == ']')
- {
- // End array (also an end value delimiter)
- if (!aparent || pisobject)
- throw JsonException("Unexpected end array token (']')");
-
- if (value)
- AttachToParentReset(aparent, value, vkey);
-
- if (!aparent->parent)
- return aparent;
-
- value = aparent;
- aparent = aparent->parent;
- vkey = pvkey;
- pvkey.clear();
- pisobject = (aparent->GetType() == RPCObject);
- }
- else
- {
- // Numbers, false, null, and true fall under this heading.
- if ((*i == 't') && ((i + 3) < data.end()) && (*(i + 1) == 'r') && (*(i + 2) == 'u') && (*(i + 3) == 'e'))
- {
- value = new RPCValue(true);
- i += 3;
- }
- else if ((*i == 'f') && ((i + 4) < data.end()) && (*(i + 1) == 'a') && (*(i + 2) == 'l') && (*(i + 3) == 's') && (*(i + 4) == 'e'))
- {
- value = new RPCValue(false);
- i += 4;
- }
- else if ((*i == 'n') && ((i + 3) < data.end()) && (*(i + 1) == 'u') && (*(i + 2) == 'l') && (*(i + 3) == 'l'))
- {
- value = new RPCValue();
- i += 3;
- }
- else if ((*i == '-') || (*i == '+') || (*i == '.') || ((*i >= '0') && (*i <= '9')))
- {
- std::string ds = std::string(i, data.end());
- char *eds = NULL;
-
- errno = 0;
- double v = strtod(ds.c_str(), &eds);
-
- if (errno != 0)
- throw JsonException("Error parsing numeric value");
-
- value = new RPCValue(v);
-
- i += eds - ds.c_str() - 1;
- }
- else
- throw JsonException("Unknown data in value portion");
- }
- }
-
- if (instring)
- throw JsonException("Unterminated string");
-
- if (aparent && pisobject)
- throw JsonException("Unterminated object");
- else if (aparent && !pisobject)
- throw JsonException("Unterminated array");
-
- if (value)
- return value;
- else
- throw JsonException("No JSON data found");
- }
-
- void JSONSerialize(RPCValue *value, std::stringstream &re)
- {
- int ac;
- switch (value->GetType())
- {
- case RPCNull:
- re << "null";
- break;
- case RPCBoolean:
- re << ((value->GetBool()) ? "true" : "false");
- break;
- case RPCInteger:
- re << value->GetInt();
- break;
- case RPCString:
- re << "\"" << value->GetString() << "\"";
- break;
- case RPCArray:
- re << "[";
- ac = value->ArraySize();
- for (int i = 0; i < ac; i++)
- {
- this->JSONSerialize(value->GetArray(i), re);
- if (i != (ac - 1))
- re << ",";
- }
- re << "]";
- break;
- case RPCObject:
- re << "{";
- std::pair<RPCObjectContainer::iterator,RPCObjectContainer::iterator> its = value->GetObjectIterator();
- while (its.first != its.second)
- {
- re << "\"" << its.first->first << "\":";
- this->JSONSerialize(its.first->second, re);
- if (++its.first != its.second)
- re << ",";
- }
- re << "}";
- break;
- }
- }
-};
-
-MODULE_INIT(ModuleRpcJson)
diff --git a/src/modules/m_rpctest.cpp b/src/modules/m_rpctest.cpp
deleted file mode 100644
index a33976510..000000000
--- a/src/modules/m_rpctest.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "rpc.h"
-
-/* $ModDesc: A test of the RPC API */
-/* $ModDep: rpc.h */
-
-class ModuleRPCTest : public Module
-{
- private:
-
- public:
- ModuleRPCTest() {
- Implementation eventlist[] = { I_OnEvent };
- ServerInstance->Modules->Attach(eventlist, this, 1);
- }
-
- virtual ~ModuleRPCTest()
- {
- }
-
- virtual Version GetVersion()
- {
- return Version("A test of the RPC API", VF_VENDOR, API_VERSION);
- }
-
-
- virtual void OnEvent(Event *ev)
- {
- if (ev->GetEventID() == "RPCMethod")
- {
- RPCRequest *req = (RPCRequest*) ev->GetData();
-
- if (req->method == "test.echo")
- {
- req->claimed = true;
- if (req->parameters->ArraySize() < 1)
- {
- req->error = "Insufficient parameters";
- return;
- }
-
- req->result->SetString(req->parameters->GetArray(0)->GetString());
- }
- }
- }
-};
-
-MODULE_INIT(ModuleRPCTest)
-
diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp
index 48e07ef6d..938449bbb 100644
--- a/src/modules/m_sasl.cpp
+++ b/src/modules/m_sasl.cpp
@@ -226,8 +226,8 @@ class ModuleSASL : public Module
ModuleSASL()
: authExt("sasl_auth", this), cap(this, "sasl"), auth(this, authExt, cap), sasl(this, authExt)
{
- Implementation eventlist[] = { I_OnEvent, I_OnUserRegister, I_OnPostConnect, I_OnUserDisconnect, I_OnCleanup };
- ServerInstance->Modules->Attach(eventlist, this, 5);
+ Implementation eventlist[] = { I_OnEvent, I_OnUserRegister, I_OnPostConnect, I_OnUserDisconnect };
+ ServerInstance->Modules->Attach(eventlist, this, 4);
ServerInstance->AddCommand(&auth);
ServerInstance->AddCommand(&sasl);
@@ -258,7 +258,7 @@ class ModuleSASL : public Module
return Version("Provides support for IRC Authentication Layer (aka: atheme SASL) via AUTHENTICATE.",VF_VENDOR,API_VERSION);
}
- void OnEvent(Event *ev)
+ void OnEvent(Event &ev)
{
cap.HandleEvent(ev);
}
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index 73723f4e1..159f5ec0f 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -117,7 +117,7 @@ class ModuleServicesAccount : public Module
Extensible::Register(&accountname);
Implementation eventlist[] = { I_OnWhois, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreJoin, I_OnCheckBan,
- I_OnSyncUser, I_OnUserQuit, I_OnCleanup, I_OnDecodeMetaData, I_On005Numeric, I_OnUserPostNick };
+ I_OnSyncUser, I_OnUserQuit, I_OnDecodeMetaData, I_On005Numeric, I_OnUserPostNick };
ServerInstance->Modules->Attach(eventlist, this, 10);
}
@@ -262,11 +262,7 @@ class ModuleServicesAccount : public Module
dest->WriteNumeric(900, "%s %s %s :You are now logged in as %s",
dest->nick.c_str(), dest->GetFullHost().c_str(), account->c_str(), account->c_str());
- AccountData ac;
- ac.user = dest;
- ac.account = *account;
- Event n((char*)&ac, this, "account_login");
- n.Send();
+ AccountEvent(this, dest, *account).Send();
}
}
}
diff --git a/src/modules/m_sha256.cpp b/src/modules/m_sha256.cpp
index c41bd0699..07c9ea04b 100644
--- a/src/modules/m_sha256.cpp
+++ b/src/modules/m_sha256.cpp
@@ -132,6 +132,8 @@ uint32_t sha256_k[64] =
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
};
+const char* const hxc("0123456789abcdef");
+
class ModuleSHA256 : public Module
{
void SHA256Init(SHA256Context *ctx, const unsigned int* ikey)
@@ -236,33 +238,28 @@ class ModuleSHA256 : public Module
UNPACK32(ctx->h[i], &digest[i << 2]);
}
- void SHA256(const char *src, char *dest, int len, const char* hxc, const unsigned int* ikey = NULL)
+ void SHA256(const char *src, char *dest, unsigned int len)
{
// Generate the hash
unsigned char bytehash[SHA256_DIGEST_SIZE];
SHA256Context ctx;
- SHA256Init(&ctx, ikey);
- SHA256Update(&ctx, (unsigned char *)src, (unsigned int)len);
+ SHA256Init(&ctx, NULL);
+ SHA256Update(&ctx, (unsigned char *)src, len);
SHA256Final(&ctx, bytehash);
// Convert it to hex
- for (int i = 0, j = 0; i < SHA256_DIGEST_SIZE; i++)
+ int j=0;
+ for (int i = 0; i < SHA256_DIGEST_SIZE; i++)
{
dest[j++] = hxc[bytehash[i] / 16];
dest[j++] = hxc[bytehash[i] % 16];
- dest[j] = '\0';
}
+ dest[j] = '\0';
}
- unsigned int* key;
- char* chars;
-
public:
-
- ModuleSHA256() : key(NULL), chars(NULL)
+ ModuleSHA256()
{
ServerInstance->Modules->PublishInterface("HashRequest", this);
- Implementation eventlist[] = { I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 1);
}
virtual ~ModuleSHA256()
@@ -271,36 +268,22 @@ class ModuleSHA256 : public Module
}
- virtual const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- HashRequest* SHA = (HashRequest*)request;
- if (strcmp("KEY", request->GetId()) == 0)
- {
- this->key = (unsigned int*)SHA->GetKeyData();
- }
- else if (strcmp("HEX", request->GetId()) == 0)
- {
- this->chars = (char*)SHA->GetOutputs();
- }
- else if (strcmp("SUM", request->GetId()) == 0)
- {
- static char data[MAXBUF];
- SHA256((const char*)SHA->GetHashData().data(), data, SHA->GetHashData().length(), chars ? chars : "0123456789abcdef", key);
- return data;
- }
- else if (strcmp("NAME", request->GetId()) == 0)
+ if (strcmp("HASH", request.id) == 0)
{
- return "sha256";
+ char res[65];
+ HashRequest& req = static_cast<HashRequest&>(request);
+ SHA256(req.data.data(), res, req.data.length());
+ req.result = res;
}
- else if (strcmp("RESET", request->GetId()) == 0)
+ else if (strcmp("NAME", request.id) == 0)
{
- this->chars = NULL;
- this->key = NULL;
+ static_cast<HashNameRequest&>(request).response = "sha256";
}
- return NULL;
}
- virtual Version GetVersion()
+ Version GetVersion()
{
return Version("Allows for SHA-256 encrypted oper passwords", VF_VENDOR|VF_SERVICEPROVIDER, API_VERSION);
}
diff --git a/src/modules/m_spanningtree/cachetimer.cpp b/src/modules/m_spanningtree/cachetimer.cpp
index 989ed565f..7b5478b13 100644
--- a/src/modules/m_spanningtree/cachetimer.cpp
+++ b/src/modules/m_spanningtree/cachetimer.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "cachetimer.h"
#include "main.h"
diff --git a/src/modules/m_spanningtree/handshaketimer.cpp b/src/modules/m_spanningtree/handshaketimer.cpp
deleted file mode 100644
index b264a4c2f..000000000
--- a/src/modules/m_spanningtree/handshaketimer.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "socket.h"
-#include "xline.h"
-#include "../transport.h"
-
-#include "main.h"
-#include "utils.h"
-#include "treeserver.h"
-#include "link.h"
-#include "treesocket.h"
-#include "handshaketimer.h"
-
-/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */
-
-HandshakeTimer::HandshakeTimer(TreeSocket* s, Link* l, SpanningTreeUtilities* u, int delay)
- : Timer(delay, ServerInstance->Time(), true), sock(s), lnk(l), Utils(u)
-{
- thefd = sock->GetFd();
-}
-
-HandshakeTimer::~HandshakeTimer()
-{
- sock->hstimer = NULL;
-}
-
-void HandshakeTimer::Tick(time_t TIME)
-{
- if (!sock->GetIOHook())
- {
- CancelRepeat();
- sock->SendCapabilities(1);
- }
- else if (BufferedSocketHSCompleteRequest(sock, Utils->Creator, sock->GetIOHook()).Send())
- {
- CancelRepeat();
- BufferedSocketAttachCertRequest(sock, Utils->Creator, sock->GetIOHook()).Send();
- sock->SendCapabilities(1);
- }
- // otherwise, try again later
-}
-
diff --git a/src/modules/m_spanningtree/handshaketimer.h b/src/modules/m_spanningtree/handshaketimer.h
deleted file mode 100644
index 527b056bc..000000000
--- a/src/modules/m_spanningtree/handshaketimer.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#ifndef __HANDSHAKE_TIMER_H__
-#define __HANDSHAKE_TIMER_H__
-
-#include "inspircd.h"
-#include "timer.h"
-
-class SpanningTreeUtilities;
-class TreeSocket;
-class Link;
-
-class HandshakeTimer : public Timer
-{
- private:
- TreeSocket* sock;
- reference<Link> lnk;
- SpanningTreeUtilities* Utils;
- int thefd;
- public:
- HandshakeTimer(TreeSocket* s, Link* l, SpanningTreeUtilities* u, int delay);
- ~HandshakeTimer();
- virtual void Tick(time_t TIME);
-};
-
-#endif
diff --git a/src/modules/m_spanningtree/hmac.cpp b/src/modules/m_spanningtree/hmac.cpp
index b7cddc47a..ad35a585f 100644
--- a/src/modules/m_spanningtree/hmac.cpp
+++ b/src/modules/m_spanningtree/hmac.cpp
@@ -14,8 +14,8 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "../m_hash.h"
+#include "../ssl.h"
#include "socketengine.h"
#include "main.h"
@@ -24,7 +24,6 @@
#include "link.h"
#include "treesocket.h"
#include "resolvers.h"
-#include "handshaketimer.h"
/* $ModDep: m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_hash.h */
@@ -78,12 +77,10 @@ std::string TreeSocket::MakePass(const std::string &password, const std::string
}
hmac2 += challenge;
- HashResetRequest(Utils->Creator, sha256).Send();
- hmac2 = HashSumRequest(Utils->Creator, sha256, hmac2).Send();
-
- HashResetRequest(Utils->Creator, sha256).Send();
+ hmac2 = HashRequest(Utils->Creator, sha256, hmac2).result;
+
std::string hmac = hmac1 + hmac2;
- hmac = HashSumRequest(Utils->Creator, sha256, hmac).Send();
+ hmac = HashRequest(Utils->Creator, sha256, hmac).result;
return "HMAC-SHA256:"+ hmac;
}
@@ -131,8 +128,7 @@ bool TreeSocket::ComparePass(const Link& link, const std::string &theirs)
std::string fp;
if (GetIOHook())
{
- BufferedSocketCertificateRequest req(this, Utils->Creator, GetIOHook());
- req.Send();
+ SSLCertificateRequest req(this, Utils->Creator);
if (req.cert)
{
fp = req.cert->GetFingerprint();
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 7d6974cf0..23523107a 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -16,7 +16,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "cachetimer.h"
#include "resolvers.h"
@@ -49,7 +48,7 @@ ModuleSpanningTree::ModuleSpanningTree()
I_OnWallops, I_OnUserNotice, I_OnUserMessage, I_OnBackgroundTimer, I_OnUserJoin,
I_OnChangeLocalUserHost, I_OnChangeName, I_OnChangeIdent, I_OnUserPart, I_OnUnloadModule,
I_OnUserQuit, I_OnUserPostNick, I_OnUserKick, I_OnRemoteKill, I_OnRehash, I_OnPreRehash,
- I_OnOper, I_OnAddLine, I_OnDelLine, I_OnMode, I_OnLoadModule, I_OnStats, I_OnEvent,
+ I_OnOper, I_OnAddLine, I_OnDelLine, I_OnMode, I_OnLoadModule, I_OnStats,
I_OnSetAway, I_OnPostCommand, I_OnUserConnect
};
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
@@ -294,9 +293,8 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
if (ipvalid)
{
/* Gave a hook, but it wasnt one we know */
- if ((!x->Hook.empty()) && (Utils->hooks.find(x->Hook.c_str()) == Utils->hooks.end()))
- return;
- TreeSocket* newsocket = new TreeSocket(Utils, x->IPAddr,x->Port, x->Timeout ? x->Timeout : 10,x->Name.c_str(), x->Bind, y, x->Hook.empty() ? NULL : Utils->hooks[x->Hook.c_str()]);
+ TreeSocket* newsocket = new TreeSocket(Utils, x->IPAddr, x->Port, x->Timeout ? x->Timeout : 10,
+ x->Name.c_str(), x->Bind, y, x->Hook);
if (newsocket->GetFd() > -1)
{
/* Handled automatically on success */
@@ -313,7 +311,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
try
{
bool cached;
- ServernameResolver* snr = new ServernameResolver((Module*)this, Utils, x->IPAddr, x, cached, start_type, y);
+ ServernameResolver* snr = new ServernameResolver(Utils, x->IPAddr, x, cached, start_type, y);
ServerInstance->AddResolver(snr, cached);
}
catch (ModuleException& e)
@@ -953,15 +951,6 @@ void ModuleSpanningTree::ProtoSendMetaData(void* opaque, Extensible* target, con
s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA * "+extname+" :"+extdata);
}
-void ModuleSpanningTree::OnEvent(Event* event)
-{
- if ((event->GetEventID() == "send_encap") || (event->GetEventID() == "send_metadata") || (event->GetEventID() == "send_topic") || (event->GetEventID() == "send_mode") || (event->GetEventID() == "send_mode_explicit") || (event->GetEventID() == "send_opers")
- || (event->GetEventID() == "send_modeset") || (event->GetEventID() == "send_snoset") || (event->GetEventID() == "send_push"))
- {
- ServerInstance->Logs->Log("m_spanningtree", DEBUG, "WARNING: Deprecated use of old 1.1 style m_spanningtree event ignored, type '"+event->GetEventID()+"'!");
- }
-}
-
bool ModuleSpanningTree::cull()
{
Utils->cull();
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index 59d40eca4..1057fcdfc 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -188,7 +188,6 @@ class ModuleSpanningTree : public Module
ModResult OnSetAway(User* user, const std::string &awaymsg);
void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::vector<std::string> &modeline, const std::vector<TranslateType> &translate);
void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata);
- void OnEvent(Event* event);
void OnLoadModule(Module* mod,const std::string &name);
void OnUnloadModule(Module* mod,const std::string &name);
bool cull();
diff --git a/src/modules/m_spanningtree/override_admin.cpp b/src/modules/m_spanningtree/override_admin.cpp
index 2a5cfcdab..293768759 100644
--- a/src/modules/m_spanningtree/override_admin.cpp
+++ b/src/modules/m_spanningtree/override_admin.cpp
@@ -16,7 +16,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "main.h"
#include "utils.h"
diff --git a/src/modules/m_spanningtree/override_motd.cpp b/src/modules/m_spanningtree/override_motd.cpp
index 270608062..a5f4e684e 100644
--- a/src/modules/m_spanningtree/override_motd.cpp
+++ b/src/modules/m_spanningtree/override_motd.cpp
@@ -16,7 +16,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "main.h"
#include "utils.h"
diff --git a/src/modules/m_spanningtree/override_squit.cpp b/src/modules/m_spanningtree/override_squit.cpp
index 5360f176c..e30c9ba50 100644
--- a/src/modules/m_spanningtree/override_squit.cpp
+++ b/src/modules/m_spanningtree/override_squit.cpp
@@ -16,7 +16,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "main.h"
#include "utils.h"
diff --git a/src/modules/m_spanningtree/override_stats.cpp b/src/modules/m_spanningtree/override_stats.cpp
index 93190a978..09d0a691d 100644
--- a/src/modules/m_spanningtree/override_stats.cpp
+++ b/src/modules/m_spanningtree/override_stats.cpp
@@ -16,7 +16,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "main.h"
#include "utils.h"
@@ -77,11 +76,9 @@ ModResult ModuleSpanningTree::OnStats(char statschar, User* user, string_list &r
if (ip.empty())
ip = "*";
- std::string transport("plaintext");
- if (Utils->Bindings[i]->Hook)
- transport = BufferedSocketNameRequest(this, Utils->Bindings[i]->Hook).Send();
+ std::string transport(Utils->Bindings[i]->Hook);
- results.push_back(ConvToStr(ServerInstance->Config->ServerName) + " 249 "+user->nick+" :" + ip + ":" + ConvToStr(Utils->Bindings[i]->GetPort())+
+ results.push_back(ServerInstance->Config->ServerName + " 249 "+user->nick+" :" + ip + ":" + ConvToStr(Utils->Bindings[i]->GetPort())+
" (server, " + transport + ")");
}
}
diff --git a/src/modules/m_spanningtree/override_time.cpp b/src/modules/m_spanningtree/override_time.cpp
index 54a2870bd..b3384720e 100644
--- a/src/modules/m_spanningtree/override_time.cpp
+++ b/src/modules/m_spanningtree/override_time.cpp
@@ -16,7 +16,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "main.h"
#include "utils.h"
diff --git a/src/modules/m_spanningtree/override_whois.cpp b/src/modules/m_spanningtree/override_whois.cpp
index 84bf8ce77..ee3be53fd 100644
--- a/src/modules/m_spanningtree/override_whois.cpp
+++ b/src/modules/m_spanningtree/override_whois.cpp
@@ -16,7 +16,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "main.h"
#include "utils.h"
diff --git a/src/modules/m_spanningtree/ping.cpp b/src/modules/m_spanningtree/ping.cpp
index c3467c984..2d468916d 100644
--- a/src/modules/m_spanningtree/ping.cpp
+++ b/src/modules/m_spanningtree/ping.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "socketengine.h"
#include "main.h"
diff --git a/src/modules/m_spanningtree/pong.cpp b/src/modules/m_spanningtree/pong.cpp
index 274641897..675e17f45 100644
--- a/src/modules/m_spanningtree/pong.cpp
+++ b/src/modules/m_spanningtree/pong.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "socketengine.h"
#include "main.h"
diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp
index fbac46faa..84ca342ec 100644
--- a/src/modules/m_spanningtree/postcommand.cpp
+++ b/src/modules/m_spanningtree/postcommand.cpp
@@ -16,7 +16,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "main.h"
#include "utils.h"
diff --git a/src/modules/m_spanningtree/precommand.cpp b/src/modules/m_spanningtree/precommand.cpp
index a024a4901..c43e4e927 100644
--- a/src/modules/m_spanningtree/precommand.cpp
+++ b/src/modules/m_spanningtree/precommand.cpp
@@ -16,7 +16,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "main.h"
#include "utils.h"
diff --git a/src/modules/m_spanningtree/push.cpp b/src/modules/m_spanningtree/push.cpp
index 778c2291c..e67b926c8 100644
--- a/src/modules/m_spanningtree/push.cpp
+++ b/src/modules/m_spanningtree/push.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "socketengine.h"
#include "main.h"
diff --git a/src/modules/m_spanningtree/rconnect.cpp b/src/modules/m_spanningtree/rconnect.cpp
index 422a4b428..5a4c71c3c 100644
--- a/src/modules/m_spanningtree/rconnect.cpp
+++ b/src/modules/m_spanningtree/rconnect.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "resolvers.h"
#include "main.h"
diff --git a/src/modules/m_spanningtree/resolvers.cpp b/src/modules/m_spanningtree/resolvers.cpp
index e168b98f5..b95ba79c3 100644
--- a/src/modules/m_spanningtree/resolvers.cpp
+++ b/src/modules/m_spanningtree/resolvers.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "resolvers.h"
#include "main.h"
@@ -31,10 +30,9 @@
* callback to OnLookupComplete or OnError when completed. Once it has completed we
* will have an IP address which we can then use to continue our connection.
*/
-ServernameResolver::ServernameResolver(Module* me, SpanningTreeUtilities* Util, const std::string &hostname, Link* x, bool &cached, QueryType qt, Autoconnect* myac)
- : Resolver(hostname, qt, cached, me), Utils(Util), query(qt), host(hostname), mine(me), MyLink(x), myautoconnect(myac)
+ServernameResolver::ServernameResolver(SpanningTreeUtilities* Util, const std::string &hostname, Link* x, bool &cached, QueryType qt, Autoconnect* myac)
+ : Resolver(hostname, qt, cached, Util->Creator), Utils(Util), query(qt), host(hostname), MyLink(x), myautoconnect(myac)
{
- /* Nothing in here, folks */
}
void ServernameResolver::OnLookupComplete(const std::string &result, unsigned int ttl, bool cached)
@@ -46,12 +44,8 @@ void ServernameResolver::OnLookupComplete(const std::string &result, unsigned in
TreeServer* CheckDupe = Utils->FindServer(MyLink->Name.c_str());
if (!CheckDupe) /* Check that nobody tried to connect it successfully while we were resolving */
{
-
- if ((!MyLink->Hook.empty()) && (Utils->hooks.find(MyLink->Hook.c_str()) == Utils->hooks.end()))
- return;
-
- TreeSocket* newsocket = new TreeSocket(this->Utils, result,MyLink->Port,MyLink->Timeout ? MyLink->Timeout : 10,MyLink->Name.c_str(),
- MyLink->Bind, myautoconnect, MyLink->Hook.empty() ? NULL : Utils->hooks[MyLink->Hook.c_str()]);
+ TreeSocket* newsocket = new TreeSocket(Utils, result, MyLink->Port, MyLink->Timeout ? MyLink->Timeout : 10,
+ MyLink->Name.c_str(), MyLink->Bind, myautoconnect, MyLink->Hook);
if (newsocket->GetFd() > -1)
{
/* We're all OK */
@@ -72,7 +66,7 @@ void ServernameResolver::OnError(ResolverError e, const std::string &errormessag
if (query == DNS_QUERY_AAAA)
{
bool cached;
- ServernameResolver* snr = new ServernameResolver(mine, Utils, host, MyLink, cached, DNS_QUERY_A, myautoconnect);
+ ServernameResolver* snr = new ServernameResolver(Utils, host, MyLink, cached, DNS_QUERY_A, myautoconnect);
ServerInstance->AddResolver(snr, cached);
return;
}
diff --git a/src/modules/m_spanningtree/resolvers.h b/src/modules/m_spanningtree/resolvers.h
index 29ead13de..5d4386c4b 100644
--- a/src/modules/m_spanningtree/resolvers.h
+++ b/src/modules/m_spanningtree/resolvers.h
@@ -17,7 +17,6 @@
#include "socket.h"
#include "inspircd.h"
#include "xline.h"
-#include "../transport.h"
#include "utils.h"
#include "link.h"
@@ -69,13 +68,12 @@ class ServernameResolver : public Resolver
SpanningTreeUtilities* Utils;
QueryType query;
std::string host;
- Module* mine;
reference<Link> MyLink;
reference<Autoconnect> myautoconnect;
public:
- ServernameResolver(Module* me, SpanningTreeUtilities* Util, const std::string &hostname, Link* x, bool &cached, QueryType qt, Autoconnect* myac);
- void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached);
- void OnError(ResolverError e, const std::string &errormessage);
+ ServernameResolver(SpanningTreeUtilities* Util, const std::string &hostname, Link* x, bool &cached, QueryType qt, Autoconnect* myac);
+ void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached);
+ void OnError(ResolverError e, const std::string &errormessage);
};
#endif
diff --git a/src/modules/m_spanningtree/rsquit.cpp b/src/modules/m_spanningtree/rsquit.cpp
index 194536c47..271e845d5 100644
--- a/src/modules/m_spanningtree/rsquit.cpp
+++ b/src/modules/m_spanningtree/rsquit.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "main.h"
#include "utils.h"
diff --git a/src/modules/m_spanningtree/save.cpp b/src/modules/m_spanningtree/save.cpp
index cfa8dc794..1fbea0052 100644
--- a/src/modules/m_spanningtree/save.cpp
+++ b/src/modules/m_spanningtree/save.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "socketengine.h"
#include "main.h"
diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp
index 900aceb9d..6fda446ea 100644
--- a/src/modules/m_spanningtree/server.cpp
+++ b/src/modules/m_spanningtree/server.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "socketengine.h"
#include "main.h"
@@ -251,11 +250,6 @@ bool TreeSocket::Inbound_Server(parameterlist &params)
ServerInstance->SNO->WriteToSnoMask('l',"Verified incoming server connection from \002"+sname+"\002["+(x->HiddenFromStats ? "<hidden>" : this->IP)+"] ("+description+")");
- if (this->GetIOHook())
- {
- std::string name = BufferedSocketNameRequest(Utils->Creator, this->GetIOHook()).Send();
- ServerInstance->SNO->WriteToSnoMask('l',"Connection from \2"+sname+"\2["+(x->HiddenFromStats ? "<hidden>" : this->IP)+"] using transport \2"+name+"\2");
- }
// this is good. Send our details: Our server name and description and hopcount of 0,
// along with the sendpass from this block.
diff --git a/src/modules/m_spanningtree/stats.cpp b/src/modules/m_spanningtree/stats.cpp
index 71f12d50b..bc568de26 100644
--- a/src/modules/m_spanningtree/stats.cpp
+++ b/src/modules/m_spanningtree/stats.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "socketengine.h"
#include "main.h"
diff --git a/src/modules/m_spanningtree/svsjoin.cpp b/src/modules/m_spanningtree/svsjoin.cpp
index dff882f62..4fdc05dea 100644
--- a/src/modules/m_spanningtree/svsjoin.cpp
+++ b/src/modules/m_spanningtree/svsjoin.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "socketengine.h"
#include "main.h"
diff --git a/src/modules/m_spanningtree/svsnick.cpp b/src/modules/m_spanningtree/svsnick.cpp
index 7a723a36d..87b63ec26 100644
--- a/src/modules/m_spanningtree/svsnick.cpp
+++ b/src/modules/m_spanningtree/svsnick.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "socketengine.h"
#include "main.h"
diff --git a/src/modules/m_spanningtree/svspart.cpp b/src/modules/m_spanningtree/svspart.cpp
index 1e26c90d9..cc49aa72e 100644
--- a/src/modules/m_spanningtree/svspart.cpp
+++ b/src/modules/m_spanningtree/svspart.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "socketengine.h"
#include "main.h"
diff --git a/src/modules/m_spanningtree/time.cpp b/src/modules/m_spanningtree/time.cpp
index 6fdcf8b53..f44a08e5c 100644
--- a/src/modules/m_spanningtree/time.cpp
+++ b/src/modules/m_spanningtree/time.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "socketengine.h"
#include "main.h"
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index 95f686698..5c7162094 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -14,7 +14,8 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
+#include "main.h"
+#include "../spanningtree.h"
#include "utils.h"
#include "treeserver.h"
@@ -147,8 +148,7 @@ void TreeServer::FinishBurst()
unsigned long bursttime = ts - this->StartBurst;
ServerInstance->SNO->WriteToSnoMask(Parent == Utils->TreeRoot ? 'l' : 'L', "Received end of netburst from \2%s\2 (burst time: %lu %s)",
ServerName.c_str(), (bursttime > 10000 ? bursttime / 1000 : bursttime), (bursttime > 10000 ? "secs" : "msecs"));
- Event rmode((char*)ServerName.c_str(), (Module*)Utils->Creator, "new_server");
- rmode.Send();
+ AddServerEvent(Utils->Creator, ServerName.c_str());
}
void TreeServer::SetID(const std::string &id)
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index b29a0480c..a0f0e5d88 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -17,10 +17,8 @@
#include "socket.h"
#include "inspircd.h"
#include "xline.h"
-#include "../transport.h"
#include "utils.h"
-#include "handshaketimer.h"
/*
* The server list in InspIRCd is maintained as two structures
@@ -91,7 +89,6 @@ class TreeSocket : public BufferedSocket
bool auth_challenge; /* Did we auth using challenge/response */
int proto_version; /* Remote protocol version */
public:
- HandshakeTimer* hstimer; /* Handshake timer, needed to work around I/O hook buffering */
reference<Autoconnect> myautoconnect; /* Autoconnect used to cause this connection, if any */
time_t age;
@@ -100,13 +97,13 @@ class TreeSocket : public BufferedSocket
* most of the action, and append a few of our own values
* to it.
*/
- TreeSocket(SpanningTreeUtilities* Util, std::string host, int port, unsigned long maxtime, const std::string &ServerName, const std::string &bindto, Autoconnect* myac, Module* HookMod = NULL);
+ TreeSocket(SpanningTreeUtilities* Util, const std::string& host, int port, unsigned long maxtime, const std::string &ServerName, const std::string &bindto, Autoconnect* myac, const std::string& Hook);
/** When a listening socket gives us a new file descriptor,
* we must associate it with a socket without creating a new
* connection. This constructor is used for this purpose.
*/
- TreeSocket(SpanningTreeUtilities* Util, int newfd, char* ip, Autoconnect* myac, Module* HookMod = NULL);
+ TreeSocket(SpanningTreeUtilities* Util, int newfd, ListenSocketBase* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
/** Get link state
*/
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index 70046d774..2c845bbd4 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -14,27 +14,23 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "../m_hash.h"
#include "socketengine.h"
#include "main.h"
+#include "../spanningtree.h"
#include "utils.h"
#include "treeserver.h"
#include "link.h"
#include "treesocket.h"
#include "resolvers.h"
-#include "handshaketimer.h"
-
-/* $ModDep: m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_hash.h m_spanningtree/handshaketimer.h */
-
/** Because most of the I/O gubbins are encapsulated within
* BufferedSocket, we just call the superclass constructor for
* most of the action, and append a few of our own values
* to it.
*/
-TreeSocket::TreeSocket(SpanningTreeUtilities* Util, std::string shost, int iport, unsigned long maxtime, const std::string &ServerName, const std::string &bindto, Autoconnect* myac, Module* HookMod)
+TreeSocket::TreeSocket(SpanningTreeUtilities* Util, const std::string& shost, int iport, unsigned long maxtime, const std::string &ServerName, const std::string &bindto, Autoconnect* myac, const std::string& hook)
: Utils(Util), IP(shost), myautoconnect(myac)
{
age = ServerInstance->Time();
@@ -44,33 +40,31 @@ TreeSocket::TreeSocket(SpanningTreeUtilities* Util, std::string shost, int iport
LinkState = CONNECTING;
DoConnect(shost, iport, maxtime, bindto);
Utils->timeoutlist[this] = std::pair<std::string, int>(ServerName, maxtime);
- if (HookMod)
- BufferedSocketHookRequest(this, Utils->Creator, HookMod).Send();
- hstimer = NULL;
+ // TODO AddIOHook using the given hook
+ SendCapabilities(1);
}
/** When a listening socket gives us a new file descriptor,
* we must associate it with a socket without creating a new
* connection. This constructor is used for this purpose.
*/
-TreeSocket::TreeSocket(SpanningTreeUtilities* Util, int newfd, char* ip, Autoconnect* myac, Module* HookMod)
- : BufferedSocket(newfd), Utils(Util), IP(ip), myautoconnect(myac)
+TreeSocket::TreeSocket(SpanningTreeUtilities* Util, int newfd, ListenSocketBase* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server)
+ : BufferedSocket(newfd), Utils(Util)
{
+ int dummy;
+ irc::sockets::satoap(client, IP, dummy);
age = ServerInstance->Time();
LinkState = WAIT_AUTH_1;
capab_phase = 0;
proto_version = 0;
- /* If we have a transport module hooked to the parent, hook the same module to this
- * socket, and set a timer waiting for handshake before we send CAPAB etc.
- */
- if (HookMod)
- BufferedSocketHookRequest(this, Utils->Creator, HookMod).Send();
- hstimer = new HandshakeTimer(this, Utils->LinkBlocks[0], this->Utils, 1);
- ServerInstance->Timers->AddTimer(hstimer);
+ FOREACH_MOD(I_OnHookIO, OnHookIO(this, via));
+ if (GetIOHook())
+ GetIOHook()->OnStreamSocketAccept(this, client, server);
+ SendCapabilities(1);
/* Fix by Brain - inbound sockets need a timeout, too. 30 secs should be pleanty */
- Utils->timeoutlist[this] = std::pair<std::string, int>("<from " + std::string(ip) + ">", 30);
+ Utils->timeoutlist[this] = std::pair<std::string, int>("<from " + IP + ">", 30);
}
ServerState TreeSocket::GetLinkState()
@@ -90,16 +84,12 @@ void TreeSocket::CleanNegotiationInfo()
bool TreeSocket::cull()
{
- if (GetIOHook())
- BufferedSocketUnhookRequest(this, Utils->Creator, GetIOHook()).Send();
Utils->timeoutlist.erase(this);
return this->BufferedSocket::cull();
}
TreeSocket::~TreeSocket()
{
- if (hstimer)
- ServerInstance->Timers->DelTimer(hstimer);
}
/** When an outbound connection finishes connecting, we receive
@@ -120,14 +110,7 @@ void TreeSocket::OnConnected()
{
ServerInstance->SNO->WriteToSnoMask('l', "Connection to \2%s\2[%s] started.", myhost.c_str(), (x->HiddenFromStats ? "<hidden>" : this->IP.c_str()));
this->OutboundPass = x->SendPass;
- if (GetIOHook())
- {
- ServerInstance->SNO->WriteToSnoMask('l', "Connection to \2%s\2[%s] using transport \2%s\2", myhost.c_str(), (x->HiddenFromStats ? "<hidden>" : this->IP.c_str()), x->Hook.c_str());
- hstimer = new HandshakeTimer(this, &(*x), this->Utils, 1);
- ServerInstance->Timers->AddTimer(hstimer);
- }
- else
- this->SendCapabilities(1);
+ this->SendCapabilities(1);
return;
}
}
@@ -209,8 +192,7 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
if ((Current) && (Current != Utils->TreeRoot))
{
- Event rmode((char*)Current->GetName().c_str(), (Module*)Utils->Creator, "lost_server");
- rmode.Send();
+ DelServerEvent(Utils->Creator, Current->GetName());
parameterlist params;
params.push_back(Current->GetName());
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index bdda77ee1..c670e4b9a 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "socketengine.h"
#include "main.h"
@@ -23,9 +22,6 @@
#include "link.h"
#include "treesocket.h"
#include "resolvers.h"
-#include "handshaketimer.h"
-
-/* $ModDep: m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/handshaketimer.h */
/* Handle ERROR command */
bool TreeSocket::Error(parameterlist &params)
diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp
index 6279564df..4e3b07eea 100644
--- a/src/modules/m_spanningtree/uid.cpp
+++ b/src/modules/m_spanningtree/uid.cpp
@@ -19,7 +19,6 @@
#include "link.h"
#include "treesocket.h"
#include "resolvers.h"
-#include "handshaketimer.h"
/* $ModDep: m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_hash.h m_spanningtree/handshaketimer.h */
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index 3cdd495aa..3b70fce31 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "socketengine.h"
#include "main.h"
@@ -33,14 +32,13 @@ void ServerSocketListener::OnAcceptReady(int newsock)
int port;
std::string incomingip;
irc::sockets::satoap(&client, incomingip, port);
- char *ip = const_cast<char*>(incomingip.c_str());
- found = (std::find(Utils->ValidIPs.begin(), Utils->ValidIPs.end(), ip) != Utils->ValidIPs.end());
+ found = (std::find(Utils->ValidIPs.begin(), Utils->ValidIPs.end(), incomingip) != Utils->ValidIPs.end());
if (!found)
{
for (std::vector<std::string>::iterator i = Utils->ValidIPs.begin(); i != Utils->ValidIPs.end(); i++)
{
- if (*i == "*" || irc::sockets::MatchCIDR(ip, *i))
+ if (*i == "*" || irc::sockets::MatchCIDR(incomingip, *i))
{
found = true;
break;
@@ -49,19 +47,15 @@ void ServerSocketListener::OnAcceptReady(int newsock)
if (!found)
{
- ServerInstance->SNO->WriteToSnoMask('l', "Server connection from %s denied (no link blocks with that IP address)", ip);
+ ServerInstance->SNO->WriteToSnoMask('l', "Server connection from %s denied (no link blocks with that IP address)", incomingip.c_str());
ServerInstance->SE->Close(newsock);
return;
}
}
/* we don't need to do anything with the pointer, creating it stores it in the necessary places */
- TreeSocket* ts = new TreeSocket(Utils, newsock, ip, NULL, Hook);
- if (Hook)
- Hook->OnStreamSocketAccept(ts, &client, &server);
-
- return;
+ new TreeSocket(Utils, newsock, this, &client, &server);
}
/** Yay for fast searches!
@@ -387,29 +381,6 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
{
ConfigReader* Conf = new ConfigReader;
- /* We don't need to worry about these being *unloaded* on the fly, only loaded,
- * because we 'use' the interface locking the module in memory.
- */
- hooks.clear();
- hooknames.clear();
- modulelist* ml = ServerInstance->Modules->FindInterface("BufferedSocketHook");
-
- /* Did we find any modules? */
- if (ml)
- {
- /* Yes, enumerate them all to find out the hook name */
- for (modulelist::iterator m = ml->begin(); m != ml->end(); m++)
- {
- /* Make a request to it for its name, its implementing
- * BufferedSocketHook so we know its safe to do this
- */
- std::string name = BufferedSocketNameRequest((Module*)Creator, *m).Send();
- /* Build a map of them */
- hooks[name.c_str()] = *m;
- hooknames.push_back(name);
- }
- }
-
if (rebind)
{
for (unsigned int i = 0; i < Bindings.size(); i++)
@@ -423,7 +394,7 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
std::string Type = Conf->ReadValue("bind","type",j);
std::string IP = Conf->ReadValue("bind","address",j);
std::string Port = Conf->ReadValue("bind","port",j);
- std::string transport = Conf->ReadValue("bind","transport",j);
+ std::string ssl = Conf->ReadValue("bind","ssl",j);
if (Type == "servers")
{
irc::portparser portrange(Port, false);
@@ -434,22 +405,13 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
while ((portno = portrange.GetToken()))
{
- if ((!transport.empty()) && (hooks.find(transport.c_str()) == hooks.end()))
- {
- throw CoreException("Can't find transport type '"+transport+"' for port "+IP+":"+Port+" - maybe you forgot to load it BEFORE m_spanningtree in your config file?");
- break;
- }
-
- ServerSocketListener *listener = new ServerSocketListener(this, portno, (char *)IP.c_str());
+ ServerSocketListener *listener = new ServerSocketListener(this, portno, IP, ssl);
if (listener->GetFd() == -1)
{
delete listener;
continue;
}
- if (!transport.empty())
- listener->Hook = hooks[transport.c_str()];
-
Bindings.push_back(listener);
}
}
@@ -490,13 +452,6 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
L->Bind = Conf->ReadValue("link", "bind", j);
L->Hidden = Conf->ReadFlag("link", "hidden", j);
- if ((!L->Hook.empty()) && (hooks.find(L->Hook.c_str()) == hooks.end()))
- {
- throw CoreException("Can't find transport type '"+L->Hook+"' for link '"+assign(L->Name)+"' - maybe you forgot to load it BEFORE m_spanningtree in your config file? Skipping <link> tag completely.");
- continue;
-
- }
-
if (L->Name.find('.') == std::string::npos)
throw CoreException("The link name '"+assign(L->Name)+"' is invalid and must contain at least one '.' character");
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index d8bf765b5..7c15b2839 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -45,24 +45,18 @@ class ServerSocketListener : public ListenSocketBase
SpanningTreeUtilities *Utils;
public:
- ServerSocketListener(SpanningTreeUtilities *u, int port, char* addr) : ListenSocketBase(port, addr)
+ ServerSocketListener(SpanningTreeUtilities *u, int port, const std::string& addr, const std::string& hook)
+ : ListenSocketBase(port, addr), Utils(u), Hook(hook)
{
- this->Utils = u;
- Hook = NULL;
}
- Module* Hook;
+ std::string Hook;
virtual void OnAcceptReady(int nfd);
};
typedef std::map<TreeServer*,TreeServer*> TreeServerList;
-/** A group of modules that implement BufferedSocketHook
- * that we can use to hook our server to server connections.
- */
-typedef std::map<irc::string, Module*> hookmodules;
-
/** Contains helper functions and variables for this module,
* and keeps them out of the global namespace
*/
@@ -126,14 +120,6 @@ class SpanningTreeUtilities : public classbase
*/
std::vector<reference<Autoconnect> > AutoconnectBlocks;
- /** List of module pointers which can provide I/O abstraction
- */
- hookmodules hooks;
-
- /** List of module names which can provide I/O abstraction
- */
- std::vector<std::string> hooknames;
-
/** True (default) if we are to use challenge-response HMAC
* to authenticate passwords.
*
diff --git a/src/modules/m_spanningtree/version.cpp b/src/modules/m_spanningtree/version.cpp
index 6cec7baf9..ba5386ffb 100644
--- a/src/modules/m_spanningtree/version.cpp
+++ b/src/modules/m_spanningtree/version.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "socketengine.h"
#include "main.h"
diff --git a/src/modules/m_spanningtree/whois.cpp b/src/modules/m_spanningtree/whois.cpp
index 79e2d7355..03fb5f923 100644
--- a/src/modules/m_spanningtree/whois.cpp
+++ b/src/modules/m_spanningtree/whois.cpp
@@ -14,7 +14,6 @@
#include "inspircd.h"
#include "socket.h"
#include "xline.h"
-#include "../transport.h"
#include "socketengine.h"
#include "main.h"
diff --git a/src/modules/m_sqlauth.cpp b/src/modules/m_sqlauth.cpp
index 256bf346a..aefd54ef7 100644
--- a/src/modules/m_sqlauth.cpp
+++ b/src/modules/m_sqlauth.cpp
@@ -47,8 +47,8 @@ public:
throw ModuleException("Can't find an SQL provider module. Please load one before attempting to load m_sqlauth.");
OnRehash(NULL);
- Implementation eventlist[] = { I_OnUserDisconnect, I_OnCheckReady, I_OnRequest, I_OnRehash, I_OnUserRegister };
- ServerInstance->Modules->Attach(eventlist, this, 5);
+ Implementation eventlist[] = { I_OnUserDisconnect, I_OnCheckReady, I_OnRehash, I_OnUserRegister };
+ ServerInstance->Modules->Attach(eventlist, this, 4);
}
virtual ~ModuleSQLAuth()
@@ -109,47 +109,37 @@ public:
if (HashMod)
{
- HashResetRequest(this, HashMod).Send();
- SearchAndReplace(thisquery, std::string("$md5pass"), std::string(HashSumRequest(this, HashMod, user->password).Send()));
+ SearchAndReplace(thisquery, std::string("$md5pass"), HashRequest(this, HashMod, user->password).result);
}
HashMod = ServerInstance->Modules->Find("m_sha256.so");
if (HashMod)
{
- HashResetRequest(this, HashMod).Send();
- SearchAndReplace(thisquery, std::string("$sha256pass"), std::string(HashSumRequest(this, HashMod, user->password).Send()));
+ SearchAndReplace(thisquery, std::string("$sha256pass"), HashRequest(this, HashMod, user->password).result);
}
/* Build the query */
SQLrequest req = SQLrequest(this, SQLprovider, databaseid, SQLquery(thisquery));
- if(req.Send())
- {
- /* When we get the query response from the service provider we will be given an ID to play with,
- * just an ID number which is unique to this query. We need a way of associating that ID with a User
- * so we insert it into a map mapping the IDs to users.
- * Thankfully m_sqlutils provides this, it will associate a ID with a user or channel, and if the user quits it removes the
- * association. This means that if the user quits during a query we will just get a failed lookup from m_sqlutils - telling
- * us to discard the query.
- */
- AssociateUser(this, SQLutils, req.id, user).Send();
-
- return true;
- }
- else
- {
- if (verbose)
- ServerInstance->SNO->WriteGlobalSno('a', "Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), req.error.Str());
- return false;
- }
+ req.Send();
+ /* When we get the query response from the service provider we will be given an ID to play with,
+ * just an ID number which is unique to this query. We need a way of associating that ID with a User
+ * so we insert it into a map mapping the IDs to users.
+ * Thankfully m_sqlutils provides this, it will associate a ID with a user or channel, and if the user quits it removes the
+ * association. This means that if the user quits during a query we will just get a failed lookup from m_sqlutils - telling
+ * us to discard the query.
+ */
+ AssociateUser(this, SQLutils, req.id, user).Send();
+
+ return true;
}
- virtual const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- if(strcmp(SQLRESID, request->GetId()) == 0)
+ if(strcmp(SQLRESID, request.id) == 0)
{
- SQLresult* res = static_cast<SQLresult*>(request);
+ SQLresult* res = static_cast<SQLresult*>(&request);
User* user = GetAssocUser(this, SQLutils, res->id).S().user;
UnAssociate(this, SQLutils, res->id).S();
@@ -176,16 +166,14 @@ public:
}
else
{
- return NULL;
+ return;
}
if (!sqlAuthed.get(user))
{
ServerInstance->Users->QuitUser(user, killreason);
}
- return SQLSUCCESS;
}
- return NULL;
}
ModResult OnCheckReady(User* user)
diff --git a/src/modules/m_sqllog.cpp b/src/modules/m_sqllog.cpp
index c70c1bf7a..f1174b0ce 100644
--- a/src/modules/m_sqllog.cpp
+++ b/src/modules/m_sqllog.cpp
@@ -56,40 +56,33 @@ public:
void Go(SQLresult* res)
{
- SQLrequest req = SQLrequest(MyMod, SQLModule, dbid, SQLquery(""));
switch (qs)
{
case FIND_SOURCE:
if (res->Rows() && sourceid == -1 && !insert)
{
sourceid = atoi(res->GetValue(0,0).d.c_str());
- req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("SELECT id,actor FROM ircd_log_actors WHERE actor='?'") % nick);
- if(req.Send())
- {
- insert = false;
- qs = FIND_NICK;
- active_queries[req.id] = this;
- }
+ SQLrequest req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("SELECT id,actor FROM ircd_log_actors WHERE actor='?'") % nick);
+ req.Send();
+ insert = false;
+ qs = FIND_NICK;
+ active_queries[req.id] = this;
}
else if (res->Rows() && sourceid == -1 && insert)
{
- req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("SELECT id,actor FROM ircd_log_actors WHERE actor='?'") % source);
- if(req.Send())
- {
- insert = false;
- qs = FIND_SOURCE;
- active_queries[req.id] = this;
- }
+ SQLrequest req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("SELECT id,actor FROM ircd_log_actors WHERE actor='?'") % source);
+ req.Send();
+ insert = false;
+ qs = FIND_SOURCE;
+ active_queries[req.id] = this;
}
else
{
- req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("INSERT INTO ircd_log_actors (actor) VALUES('?')") % source);
- if(req.Send())
- {
- insert = true;
- qs = FIND_SOURCE;
- active_queries[req.id] = this;
- }
+ SQLrequest req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("INSERT INTO ircd_log_actors (actor) VALUES('?')") % source);
+ req.Send();
+ insert = true;
+ qs = FIND_SOURCE;
+ active_queries[req.id] = this;
}
break;
@@ -97,33 +90,27 @@ public:
if (res->Rows() && nickid == -1 && !insert)
{
nickid = atoi(res->GetValue(0,0).d.c_str());
- req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("SELECT id,hostname FROM ircd_log_hosts WHERE hostname='?'") % hostname);
- if(req.Send())
- {
- insert = false;
- qs = FIND_HOST;
- active_queries[req.id] = this;
- }
+ SQLrequest req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("SELECT id,hostname FROM ircd_log_hosts WHERE hostname='?'") % hostname);
+ req.Send();
+ insert = false;
+ qs = FIND_HOST;
+ active_queries[req.id] = this;
}
else if (res->Rows() && nickid == -1 && insert)
{
- req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("SELECT id,actor FROM ircd_log_actors WHERE actor='?'") % nick);
- if(req.Send())
- {
- insert = false;
- qs = FIND_NICK;
- active_queries[req.id] = this;
- }
+ SQLrequest req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("SELECT id,actor FROM ircd_log_actors WHERE actor='?'") % nick);
+ req.Send();
+ insert = false;
+ qs = FIND_NICK;
+ active_queries[req.id] = this;
}
else
{
- req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("INSERT INTO ircd_log_actors (actor) VALUES('?')") % nick);
- if(req.Send())
- {
- insert = true;
- qs = FIND_NICK;
- active_queries[req.id] = this;
- }
+ SQLrequest req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("INSERT INTO ircd_log_actors (actor) VALUES('?')") % nick);
+ req.Send();
+ insert = true;
+ qs = FIND_NICK;
+ active_queries[req.id] = this;
}
break;
@@ -131,44 +118,32 @@ public:
if (res->Rows() && hostid == -1 && !insert)
{
hostid = atoi(res->GetValue(0,0).d.c_str());
- req = SQLrequest(MyMod, SQLModule, dbid,
+ SQLrequest req = SQLrequest(MyMod, SQLModule, dbid,
SQLquery("INSERT INTO ircd_log (category_id,nick,host,source,dtime) VALUES('?','?','?','?','?')") % category % nickid % hostid % sourceid % date);
- if(req.Send())
- {
- insert = true;
- qs = DONE;
- active_queries[req.id] = this;
- }
+ req.Send();
+ insert = true;
+ qs = DONE;
+ active_queries[req.id] = this;
}
else if (res->Rows() && hostid == -1 && insert)
{
- req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("SELECT id,hostname FROM ircd_log_hosts WHERE hostname='?'") % hostname);
- if(req.Send())
- {
- insert = false;
- qs = FIND_HOST;
- active_queries[req.id] = this;
- }
+ SQLrequest req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("SELECT id,hostname FROM ircd_log_hosts WHERE hostname='?'") % hostname);
+ req.Send();
+ insert = false;
+ qs = FIND_HOST;
+ active_queries[req.id] = this;
}
else
{
- req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("INSERT INTO ircd_log_hosts (hostname) VALUES('?')") % hostname);
- if(req.Send())
- {
- insert = true;
- qs = FIND_HOST;
- active_queries[req.id] = this;
- }
+ SQLrequest req = SQLrequest(MyMod, SQLModule, dbid, SQLquery("INSERT INTO ircd_log_hosts (hostname) VALUES('?')") % hostname);
+ req.Send();
+ insert = true;
+ qs = FIND_HOST;
+ active_queries[req.id] = this;
}
break;
case DONE:
- std::map<unsigned long,QueryInfo*>::iterator x = active_queries.find(req.id);
- if (x != active_queries.end())
- {
- delete x->second;
- active_queries.erase(x);
- }
break;
}
}
@@ -196,8 +171,8 @@ class ModuleSQLLog : public Module
active_queries.clear();
Implementation eventlist[] = { I_OnRehash, I_OnOper, I_OnGlobalOper, I_OnKill,
- I_OnPreCommand, I_OnUserConnect, I_OnUserQuit, I_OnLoadModule, I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 9);
+ I_OnPreCommand, I_OnUserConnect, I_OnUserQuit, I_OnLoadModule };
+ ServerInstance->Modules->Attach(eventlist, this, 8);
}
virtual ~ModuleSQLLog()
@@ -218,14 +193,13 @@ class ModuleSQLLog : public Module
ReadConfig();
}
- virtual const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- if(strcmp(SQLRESID, request->GetId()) == 0)
+ if(strcmp(SQLRESID, request.id) == 0)
{
- SQLresult* res;
+ SQLresult* res = static_cast<SQLresult*>(&request);
std::map<unsigned long, QueryInfo*>::iterator n;
- res = static_cast<SQLresult*>(request);
n = active_queries.find(res->id);
if (n != active_queries.end())
@@ -233,11 +207,7 @@ class ModuleSQLLog : public Module
n->second->Go(res);
active_queries.erase(n);
}
-
- return SQLSUCCESS;
}
-
- return NULL;
}
void AddLogEntry(int category, const std::string &nick, const std::string &host, const std::string &source)
@@ -247,12 +217,10 @@ class ModuleSQLLog : public Module
return;
SQLrequest req = SQLrequest(this, SQLModule, dbid, SQLquery("SELECT id,actor FROM ircd_log_actors WHERE actor='?'") % source);
- if(req.Send())
- {
- QueryInfo* i = new QueryInfo(nick, source, host, req.id, category);
- i->qs = FIND_SOURCE;
- active_queries[req.id] = i;
- }
+ req.Send();
+ QueryInfo* i = new QueryInfo(nick, source, host, req.id, category);
+ i->qs = FIND_SOURCE;
+ active_queries[req.id] = i;
}
virtual void OnOper(User* user, const std::string &opertype)
diff --git a/src/modules/m_sqloper.cpp b/src/modules/m_sqloper.cpp
index 5f0df4c10..36bda5c58 100644
--- a/src/modules/m_sqloper.cpp
+++ b/src/modules/m_sqloper.cpp
@@ -55,7 +55,7 @@ public:
/* Make a request to it for its name, its implementing
* HashRequest so we know its safe to do this
*/
- std::string name = HashNameRequest(this, *m).Send();
+ std::string name = HashNameRequest(this, *m).response;
/* Build a map of them */
hashers[name.c_str()] = *m;
names.push_back(name);
@@ -92,7 +92,7 @@ public:
if (ServerInstance->Modules->ModuleHasInterface(mod, "HashRequest"))
{
ServerInstance->Logs->Log("m_sqloper",DEBUG, "Post-load registering hasher: %s", name.c_str());
- std::string sname = HashNameRequest(this, mod).Send();
+ std::string sname = HashNameRequest(this, mod).response;
hashers[sname.c_str()] = mod;
names.push_back(sname);
if (!diduseiface)
@@ -149,10 +149,8 @@ public:
if (x == hashers.end())
return false;
- /* Reset hash module first back to MD5 standard state */
- HashResetRequest(this, x->second).Send();
/* Make an MD5 hash of the password for using in the query */
- std::string md5_pass_hash = HashSumRequest(this, x->second, password.c_str()).Send();
+ std::string md5_pass_hash = HashRequest(this, x->second, password).result;
/* We generate our own sum here because some database providers (e.g. SQLite) dont have a builtin md5/sha256 function,
* also hashing it in the module and only passing a remote query containing a hash is more secure.
@@ -160,26 +158,19 @@ public:
SQLrequest req = SQLrequest(this, target, databaseid,
SQLquery("SELECT username, password, hostname, type FROM ircd_opers WHERE username = '?' AND password='?'") % username % md5_pass_hash);
- if (req.Send())
- {
- /* When we get the query response from the service provider we will be given an ID to play with,
- * just an ID number which is unique to this query. We need a way of associating that ID with a User
- * so we insert it into a map mapping the IDs to users.
- * Thankfully m_sqlutils provides this, it will associate a ID with a user or channel, and if the user quits it removes the
- * association. This means that if the user quits during a query we will just get a failed lookup from m_sqlutils - telling
- * us to discard the query.
- */
- AssociateUser(this, SQLutils, req.id, user).Send();
-
- saved_user.set(user, username);
- saved_pass.set(user, password);
+ /* When we get the query response from the service provider we will be given an ID to play with,
+ * just an ID number which is unique to this query. We need a way of associating that ID with a User
+ * so we insert it into a map mapping the IDs to users.
+ * Thankfully m_sqlutils provides this, it will associate a ID with a user or channel, and if the user quits it removes the
+ * association. This means that if the user quits during a query we will just get a failed lookup from m_sqlutils - telling
+ * us to discard the query.
+ */
+ AssociateUser(this, SQLutils, req.id, user).Send();
- return true;
- }
- else
- {
- return false;
- }
+ saved_user.set(user, username);
+ saved_pass.set(user, password);
+
+ return true;
}
else
{
@@ -188,11 +179,11 @@ public:
}
}
- const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- if (strcmp(SQLRESID, request->GetId()) == 0)
+ if (strcmp(SQLRESID, request.id) == 0)
{
- SQLresult* res = static_cast<SQLresult*>(request);
+ SQLresult* res = static_cast<SQLresult*>(&request);
User* user = GetAssocUser(this, SQLutils, res->id).S().user;
UnAssociate(this, SQLutils, res->id).S();
@@ -225,7 +216,6 @@ public:
/* If/when one of the rows matches, stop checking and return */
saved_user.unset(user);
saved_pass.unset(user);
- return SQLSUCCESS;
}
if (tried_user && tried_pass)
{
@@ -264,11 +254,7 @@ public:
}
}
-
- return SQLSUCCESS;
}
-
- return NULL;
}
void LoginFail(User* user, const std::string &username, const std::string &pass)
diff --git a/src/modules/m_sqlutils.cpp b/src/modules/m_sqlutils.cpp
index a80e1262b..f63cd3eab 100644
--- a/src/modules/m_sqlutils.cpp
+++ b/src/modules/m_sqlutils.cpp
@@ -34,8 +34,8 @@ public:
ModuleSQLutils() : idExt("sqlutils_list", this)
{
ServerInstance->Modules->PublishInterface("SQLutils", this);
- Implementation eventlist[] = { I_OnChannelDelete, I_OnUnloadModule, I_OnRequest, I_OnUserDisconnect };
- ServerInstance->Modules->Attach(eventlist, this, 4);
+ Implementation eventlist[] = { I_OnChannelDelete, I_OnUnloadModule, I_OnUserDisconnect };
+ ServerInstance->Modules->Attach(eventlist, this, 3);
}
~ModuleSQLutils()
@@ -44,27 +44,27 @@ public:
}
- const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- if(strcmp(SQLUTILAU, request->GetId()) == 0)
+ if(strcmp(SQLUTILAU, request.id) == 0)
{
- AssociateUser* req = (AssociateUser*)request;
+ AssociateUser* req = (AssociateUser*)&request;
iduser.insert(std::make_pair(req->id, req->user));
AttachList(req->user, req->id);
}
- else if(strcmp(SQLUTILAC, request->GetId()) == 0)
+ else if(strcmp(SQLUTILAC, request.id) == 0)
{
- AssociateChan* req = (AssociateChan*)request;
+ AssociateChan* req = (AssociateChan*)&request;
idchan.insert(std::make_pair(req->id, req->chan));
AttachList(req->chan, req->id);
}
- else if(strcmp(SQLUTILUA, request->GetId()) == 0)
+ else if(strcmp(SQLUTILUA, request.id) == 0)
{
- UnAssociate* req = (UnAssociate*)request;
+ UnAssociate* req = (UnAssociate*)&request;
/* Unassociate a given query ID with all users and channels
* it is associated with.
@@ -73,9 +73,9 @@ public:
DoUnAssociate(iduser, req->id);
DoUnAssociate(idchan, req->id);
}
- else if(strcmp(SQLUTILGU, request->GetId()) == 0)
+ else if(strcmp(SQLUTILGU, request.id) == 0)
{
- GetAssocUser* req = (GetAssocUser*)request;
+ GetAssocUser* req = (GetAssocUser*)&request;
IdUserMap::iterator iter = iduser.find(req->id);
@@ -84,9 +84,9 @@ public:
req->user = iter->second;
}
}
- else if(strcmp(SQLUTILGC, request->GetId()) == 0)
+ else if(strcmp(SQLUTILGC, request.id) == 0)
{
- GetAssocChan* req = (GetAssocChan*)request;
+ GetAssocChan* req = (GetAssocChan*)&request;
IdChanMap::iterator iter = idchan.find(req->id);
@@ -95,8 +95,6 @@ public:
req->chan = iter->second;
}
}
-
- return SQLUTILSUCCESS;
}
void OnUserDisconnect(User* user)
diff --git a/src/modules/m_sqlv2.h b/src/modules/m_sqlv2.h
index a9297bd80..bcdcb6546 100644
--- a/src/modules/m_sqlv2.h
+++ b/src/modules/m_sqlv2.h
@@ -214,6 +214,8 @@ public:
* Priority queries may 'queue jump' in the request queue.
*/
bool pri;
+ /** True if this query has been cancelled; send no response */
+ bool cancel;
/** The query ID, assigned by the SQL api.
* After your request is processed, this will
* be initialized for you by the API to a valid request ID,
@@ -246,13 +248,6 @@ public:
{
pri = p;
}
-
- /** Set the source of a request. You should not need to use this method.
- */
- void SetSource(Module* mod)
- {
- source = mod;
- }
};
/**
@@ -497,7 +492,7 @@ bool operator!= (const SQLhost& l, const SQLhost& r)
class QueryQueue : public classbase
{
private:
- typedef std::deque<SQLrequest> ReqDeque;
+ typedef std::deque<SQLrequest*> ReqDeque;
ReqDeque priority; /* The priority queue */
ReqDeque normal; /* The 'normal' queue */
@@ -509,9 +504,9 @@ public:
{
}
- void push(const SQLrequest &q)
+ void push(SQLrequest *q)
{
- if(q.pri)
+ if(q->pri)
priority.push_back(q);
else
normal.push_back(q);
@@ -534,7 +529,7 @@ public:
/* Silently do nothing if there was no element to pop() */
}
- SQLrequest& front()
+ SQLrequest* front()
{
switch(which)
{
@@ -554,14 +549,8 @@ public:
which = NOR;
return normal.front();
}
-
- /* This will probably result in a segfault,
- * but the caller should have checked totalsize()
- * first so..meh - moron :p
- */
-
- return priority.front();
}
+ return NULL;
}
std::pair<int, int> size()
@@ -583,14 +572,16 @@ public:
private:
void DoPurgeModule(Module* mod, ReqDeque& q)
{
- for(ReqDeque::iterator iter = q.begin(); iter != q.end(); iter++)
+ ReqDeque::iterator iter = q.begin();
+ while (iter != q.end())
{
- if(iter->GetSource() == mod)
+ if((**iter).source == mod)
{
- if(iter->id == front().id)
+ if (*iter == front())
{
/* It's the currently active query.. :x */
- iter->SetSource(NULL);
+ (**iter).cancel = true;
+ iter++;
}
else
{
@@ -598,6 +589,8 @@ private:
iter = q.erase(iter);
}
}
+ else
+ iter++;
}
}
};
diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp
index 1b5a39ba4..a1178f917 100644
--- a/src/modules/m_sslinfo.cpp
+++ b/src/modules/m_sslinfo.cpp
@@ -12,7 +12,7 @@
*/
#include "inspircd.h"
-#include "transport.h"
+#include "ssl.h"
/* $ModDesc: Provides SSL metadata, including /WHOIS information and /SSLINFO command */
@@ -125,15 +125,17 @@ class ModuleSSLInfo : public Module
Implementation eventlist[] = { I_OnWhois, I_OnPreCommand };
ServerInstance->Modules->Attach(eventlist, this, 2);
+ ServerInstance->Modules->PublishInterface("SSLCertInfo", this);
}
~ModuleSSLInfo()
{
+ ServerInstance->Modules->UnpublishInterface("SSLCertInfo", this);
}
Version GetVersion()
{
- return Version("SSL Certificate Utilities", VF_VENDOR);
+ return Version("SSL Certificate Utilities", VF_VENDOR | VF_SERVICEPROVIDER);
}
void OnWhois(User* source, User* dest)
@@ -224,19 +226,18 @@ class ModuleSSLInfo : public Module
return MOD_RES_PASSTHRU;
}
- const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- if (strcmp("GET_CERT", request->GetId()) == 0)
+ if (strcmp("GET_CERT", request.id) == 0)
{
- BufferedSocketCertificateRequest* req = static_cast<BufferedSocketCertificateRequest*>(request);
- req->cert = cmd.CertExt.get(req->item);
+ SSLCertificateRequest& req = static_cast<SSLCertificateRequest&>(request);
+ req.cert = cmd.CertExt.get(req.item);
}
- else if (strcmp("SET_CERT", request->GetId()) == 0)
+ else if (strcmp("SET_CERT", request.id) == 0)
{
- BufferedSocketFingerprintSubmission* req = static_cast<BufferedSocketFingerprintSubmission*>(request);
- cmd.CertExt.set(req->item, req->cert);
+ SSLCertSubmission& req = static_cast<SSLCertSubmission&>(request);
+ cmd.CertExt.set(req.item, req.cert);
}
- return NULL;
}
};
diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp
index 50fb17946..d6768904c 100644
--- a/src/modules/m_sslmodes.cpp
+++ b/src/modules/m_sslmodes.cpp
@@ -12,7 +12,7 @@
*/
#include "inspircd.h"
-#include "transport.h"
+#include "ssl.h"
/* $ModDesc: Provides support for unreal-style channel mode +z */
@@ -34,7 +34,7 @@ class SSLMode : public ModeHandler
const UserMembList* userlist = channel->GetUsers();
for(UserMembCIter i = userlist->begin(); i != userlist->end(); i++)
{
- BufferedSocketCertificateRequest req(i->first, creator, i->first->GetIOHook());
+ SSLCertificateRequest req(i->first, creator);
req.Send();
if(!req.cert && !ServerInstance->ULine(i->first->server))
{
@@ -83,7 +83,7 @@ class ModuleSSLModes : public Module
{
if(chan && chan->IsModeSet('z'))
{
- BufferedSocketCertificateRequest req(user, this, user->GetIOHook());
+ SSLCertificateRequest req(user, this);
req.Send();
if (req.cert)
{
@@ -105,7 +105,7 @@ class ModuleSSLModes : public Module
{
if (mask[0] == 'z' && mask[1] == ':')
{
- BufferedSocketCertificateRequest req(user, this, user->GetIOHook());
+ SSLCertificateRequest req(user, this);
req.Send();
if (req.cert && InspIRCd::Match(req.cert->GetFingerprint(), mask.substr(2)))
return MOD_RES_DENY;
diff --git a/src/modules/m_testclient.cpp b/src/modules/m_testclient.cpp
index 3e41f533f..c6abb0064 100644
--- a/src/modules/m_testclient.cpp
+++ b/src/modules/m_testclient.cpp
@@ -21,15 +21,15 @@ private:
public:
ModuleTestClient()
- {
- Implementation eventlist[] = { I_OnRequest, I_OnBackgroundTimer };
- ServerInstance->Modules->Attach(eventlist, this, 2);
+ {
+ Implementation eventlist[] = { I_OnBackgroundTimer };
+ ServerInstance->Modules->Attach(eventlist, this, 1);
}
virtual Version GetVersion()
{
- return Version("Provides SSL support for clients", VF_VENDOR, API_VERSION);
+ return Version("SQL test module", VF_VENDOR);
}
virtual void OnBackgroundTimer(time_t)
@@ -41,24 +41,25 @@ public:
SQLrequest foo = SQLrequest(this, target, "foo",
SQLquery("UPDATE rawr SET foo = '?' WHERE bar = 42") % ServerInstance->Time());
- if(foo.Send())
+ foo.Send();
+ if (foo.cancel)
{
- ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Sent query, got given ID %lu", foo.id);
+ ServerInstance->Logs->Log("m_testclient.so", DEBUG, "SQLrequest failed: %s", foo.error.Str());
}
else
{
- ServerInstance->Logs->Log("m_testclient.so", DEBUG, "SQLrequest failed: %s", foo.error.Str());
+ ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Sent query, got given ID %lu", foo.id);
}
}
}
- virtual const char* OnRequest(Request* request)
+ void OnRequest(Request& request)
{
- if(strcmp(SQLRESID, request->GetId()) == 0)
+ if(strcmp(SQLRESID, request.id) == 0)
{
- ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Got SQL result (%s)", request->GetId());
+ ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Got SQL result (%s)", request.id);
- SQLresult* res = (SQLresult*)request;
+ SQLresult* res = (SQLresult*)&request;
if (res->error.Id() == SQL_NO_ERROR)
{
@@ -84,15 +85,10 @@ public:
else
{
ServerInstance->Logs->Log("m_testclient.so", DEBUG, "SQLrequest failed: %s", res->error.Str());
-
}
-
- return SQLSUCCESS;
}
- ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Got unsupported API version string: %s", request->GetId());
-
- return NULL;
+ ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Got unsupported API version string: %s", request.id);
}
virtual ~ModuleTestClient()
diff --git a/src/modules/m_uhnames.cpp b/src/modules/m_uhnames.cpp
index be199208d..f9ede6c12 100644
--- a/src/modules/m_uhnames.cpp
+++ b/src/modules/m_uhnames.cpp
@@ -71,7 +71,7 @@ class ModuleUHNames : public Module
nick = memb->user->GetFullHost();
}
- void OnEvent(Event* ev)
+ void OnEvent(Event& ev)
{
cap.HandleEvent(ev);
}
diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp
index 24b4edc09..9030c1788 100644
--- a/src/modules/m_watch.cpp
+++ b/src/modules/m_watch.cpp
@@ -375,8 +375,8 @@ class Modulewatch : public Module
ServerInstance->AddCommand(&cmdw);
ServerInstance->AddCommand(&sw);
Extensible::Register(&cmdw.ext);
- Implementation eventlist[] = { I_OnRehash, I_OnGarbageCollect, I_OnCleanup, I_OnUserQuit, I_OnPostConnect, I_OnUserPostNick, I_On005Numeric, I_OnSetAway };
- ServerInstance->Modules->Attach(eventlist, this, 8);
+ Implementation eventlist[] = { I_OnRehash, I_OnGarbageCollect, I_OnUserQuit, I_OnPostConnect, I_OnUserPostNick, I_On005Numeric, I_OnSetAway };
+ ServerInstance->Modules->Attach(eventlist, this, 7);
}
virtual void OnRehash(User* user)
diff --git a/src/modules/rpc.h b/src/modules/rpc.h
deleted file mode 100644
index 36f1c031a..000000000
--- a/src/modules/rpc.h
+++ /dev/null
@@ -1,296 +0,0 @@
-#ifndef RPC_H
-#define RPC_H
-
-#include <string>
-#include <map>
-#include <stdexcept>
-
-class RPCValue;
-
-typedef enum
-{
- RPCNull,
- RPCBoolean,
- RPCInteger,
- RPCString,
- RPCArray,
- RPCObject
-} RPCValueType;
-
-typedef std::map<std::string,RPCValue*> RPCObjectContainer;
-typedef std::vector<RPCValue*> RPCArrayContainer;
-
-class RPCValue : public classbase
-{
- protected:
- RPCValueType type;
- void *value;
-
- double *CastInteger()
- {
- return (double*)value;
- }
-
- std::string *CastString()
- {
- return (std::string*)value;
- }
-
- RPCObjectContainer *CastObject()
- {
- return (RPCObjectContainer*)value;
- }
-
- RPCArrayContainer *CastArray()
- {
- return (RPCArrayContainer*)value;
- }
-
- void DestroyValue()
- {
- // Some versions of GCC complain about declaration in switch statements
- RPCArrayContainer *a;
- RPCObjectContainer *o;
- switch (type)
- {
- case RPCInteger:
- delete this->CastInteger();
- break;
- case RPCString:
- delete this->CastString();
- break;
- case RPCArray:
- a = this->CastArray();
- for (RPCArrayContainer::iterator i = a->begin(); i != a->end(); i++)
- delete *i;
- delete a;
- break;
- case RPCObject:
- o = this->CastObject();
- for (RPCObjectContainer::iterator i = o->begin(); i != o->end(); i++)
- delete i->second;
- delete o;
- break;
- default:
- break;
- }
-
- value = NULL;
- }
-
- void InitValue()
- {
- switch (type)
- {
- case RPCNull:
- case RPCBoolean:
- value = NULL;
- break;
- case RPCInteger:
- value = new double;
- break;
- case RPCString:
- value = new std::string;
- break;
- case RPCArray:
- value = new RPCArrayContainer;
- break;
- case RPCObject:
- value = new RPCObjectContainer;
- break;
- }
- }
-
- RPCValue(const RPCValue &v) { }
-
- public:
- RPCValue *parent;
-
- RPCValue(RPCValue *rparent = NULL) : type(RPCNull), value(NULL), parent(rparent) { }
- RPCValue(RPCValueType ttype, RPCValue *rparent = NULL) : type(ttype), value(NULL), parent(rparent) { InitValue(); }
- RPCValue(bool nvalue, RPCValue *rparent = NULL) : type(RPCBoolean), value((void*)nvalue), parent(rparent) { }
- RPCValue(double nvalue, RPCValue *rparent = NULL) : type(RPCInteger), parent(rparent) { value = new double(nvalue); }
- RPCValue(const std::string &nvalue, RPCValue *rparent = NULL) : type(RPCString), parent(rparent) { value = new std::string(nvalue); }
-
- virtual ~RPCValue()
- {
- DestroyValue();
- }
-
- RPCValueType GetType()
- {
- return type;
- }
-
- void SetNull()
- {
- DestroyValue();
- type = RPCNull;
- }
-
- void SetBoolean(bool nvalue)
- {
- DestroyValue();
- value = (void*)nvalue;
- type = RPCBoolean;
- }
-
- void SetInteger(double nvalue)
- {
- if (type == RPCInteger)
- {
- *this->CastInteger() = nvalue;
- }
- else
- {
- DestroyValue();
- value = new double(nvalue);
- type = RPCInteger;
- }
- }
-
- void SetString(const std::string &nvalue)
- {
- if (type == RPCString)
- {
- this->CastString()->assign(nvalue);
- }
- else
- {
- DestroyValue();
- value = new std::string(nvalue);
- type = RPCString;
- }
- }
-
- void SetArray()
- {
- if (type == RPCArray)
- {
- this->CastArray()->clear();
- }
- else
- {
- DestroyValue();
- type = RPCArray;
- InitValue();
- }
- }
-
- void SetObject()
- {
- if (type == RPCObject)
- {
- this->CastObject()->clear();
- }
- else
- {
- DestroyValue();
- type = RPCObject;
- InitValue();
- }
- }
-
- void ArrayAdd(RPCValue *nvalue)
- {
- if (type != RPCArray)
- return;
- RPCArrayContainer *a = this->CastArray();
- a->push_back(nvalue);
- nvalue->parent = this;
- }
-
- void ObjectAdd(const std::string &key, RPCValue *nvalue)
- {
- if (type != RPCObject)
- return;
- RPCObjectContainer *o = this->CastObject();
- o->insert(std::make_pair(key, nvalue));
- nvalue->parent = this;
- }
-
- RPCValue *GetArray(int i)
- {
- if (type != RPCArray)
- return NULL;
- RPCArrayContainer *a = this->CastArray();
- if ((i < 0) || (i >= (signed)a->size()))
- return NULL;
- return a->at(i);
- }
-
- int ArraySize()
- {
- if (type != RPCArray)
- return 0;
- RPCArrayContainer *a = this->CastArray();
- return a->size();
- }
-
- RPCValue *GetObject(const std::string &key)
- {
- if (type != RPCObject)
- return NULL;
- RPCObjectContainer *o = this->CastObject();
- RPCObjectContainer::iterator it = o->find(key);
- if (it == o->end())
- return NULL;
- return it->second;
- }
-
- std::pair<RPCObjectContainer::iterator,RPCObjectContainer::iterator> GetObjectIterator()
- {
- if (type != RPCObject)
- throw std::runtime_error("Cannot get iterator for a non-object RPC value");
- RPCObjectContainer *o = this->CastObject();
- return std::make_pair(o->begin(), o->end());
- }
-
- std::string GetString()
- {
- if (type != RPCString)
- return std::string();
- return *this->CastString();
- }
-
- double GetInt()
- {
- if (type != RPCInteger)
- return 0;
- return *this->CastInteger();
- }
-
- bool GetBool()
- {
- if (type != RPCBoolean)
- return 0;
- return (value != NULL);
- }
-};
-
-class RPCRequest : public classbase
-{
- protected:
-
- public:
- std::string method;
- RPCValue *parameters;
- RPCValue *result;
- std::string provider;
- bool claimed;
- std::string error;
-
- RPCRequest(const std::string &sprovider, const std::string &smethod, RPCValue *rparameters)
- : method(smethod), parameters(rparameters), provider(sprovider), claimed(false)
- {
- result = new RPCValue();
- }
-
- ~RPCRequest()
- {
- if (result)
- delete result;
- }
-};
-
-#endif
diff --git a/src/modules/transport.h b/src/modules/ssl.h
index ceb16cb73..39a7ef5f6 100644
--- a/src/modules/transport.h
+++ b/src/modules/ssl.h
@@ -11,8 +11,8 @@
* ---------------------------------------------------
*/
-#ifndef __TRANSPORT_H__
-#define __TRANSPORT_H__
+#ifndef __SSL_H__
+#define __SSL_H__
#include <map>
#include <string>
@@ -118,88 +118,32 @@ class ssl_cert
}
};
-/** Used to represent a request to a transport provider module
- */
-class ISHRequest : public Request
-{
- public:
- BufferedSocket* Sock;
-
- ISHRequest(Module* Me, Module* Target, const char* rtype, BufferedSocket* sock) : Request(Me, Target, rtype), Sock(sock)
- {
- }
-};
-
-/** Used to represent a request to attach a cert to an BufferedSocket
- */
-class BufferedSocketAttachCertRequest : public ISHRequest
-{
- public:
- /** Initialize the request as an attach cert message */
- BufferedSocketAttachCertRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_ATTACH", is)
- {
- }
-};
-
-/** Used to check if a handshake is complete on an BufferedSocket yet
- */
-class BufferedSocketHSCompleteRequest : public ISHRequest
+struct SSLCertificateRequest : public Request
{
- public:
- /** Initialize the request as a 'handshake complete?' message */
- BufferedSocketHSCompleteRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_HSDONE", is)
- {
- }
-};
-
-/** Used to hook a transport provider to an BufferedSocket
- */
-class BufferedSocketHookRequest : public ISHRequest
-{
- public:
- /** Initialize request as a hook message */
- BufferedSocketHookRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_HOOK", is)
- {
- }
-};
-
-/** Used to unhook a transport provider from an BufferedSocket
- */
-class BufferedSocketUnhookRequest : public ISHRequest
-{
- public:
- /** Initialize request as an unhook message */
- BufferedSocketUnhookRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_UNHOOK", is)
- {
- }
-};
-
-class BufferedSocketNameRequest : public ISHRequest
-{
- public:
- /** Initialize request as a get name message */
- BufferedSocketNameRequest(Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_NAME", NULL)
+ Extensible* const item;
+ ssl_cert* cert;
+ SSLCertificateRequest(StreamSocket* ss, Module* Me)
+ : Request(Me, ss->GetIOHook(), "GET_CERT"), item(ss), cert(NULL)
{
+ Send();
}
-};
-struct BufferedSocketCertificateRequest : public Request
-{
- Extensible* const item;
- ssl_cert* cert;
- BufferedSocketCertificateRequest(Extensible* is, Module* Me, Module* Target)
- : Request(Me, Target, "GET_CERT"), item(is), cert(NULL)
+ std::string GetFingerprint()
{
+ if (cert)
+ return cert->GetFingerprint();
+ return "";
}
};
-struct BufferedSocketFingerprintSubmission : public Request
+struct SSLCertSubmission : public Request
{
Extensible* const item;
ssl_cert* const cert;
- BufferedSocketFingerprintSubmission(Extensible* is, Module* Me, Module* Target, ssl_cert* Cert)
+ SSLCertSubmission(Extensible* is, Module* Me, Module* Target, ssl_cert* Cert)
: Request(Me, Target, "SET_CERT"), item(is), cert(Cert)
{
+ Send();
}
};