]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Update Event and Request APIs
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 8 Oct 2009 23:29:21 +0000 (23:29 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 8 Oct 2009 23:29:21 +0000 (23:29 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11808 e03df62e-2008-0410-955e-edbf42e46eb7

96 files changed:
include/modules.h
include/u_listmode.h
src/commands/cmd_whowas.cpp
src/dynamic.cpp
src/modules.cpp
src/modules/account.h
src/modules/extra/m_mysql.cpp
src/modules/extra/m_pgsql.cpp
src/modules/extra/m_regex_pcre.cpp
src/modules/extra/m_regex_posix.cpp
src/modules/extra/m_regex_tre.cpp
src/modules/extra/m_sqlite3.cpp
src/modules/extra/m_ssl_gnutls.cpp
src/modules/extra/m_ssl_openssl.cpp
src/modules/extra/m_ziplink.cpp
src/modules/httpd.h
src/modules/m_banexception.cpp
src/modules/m_banredirect.cpp
src/modules/m_cap.cpp
src/modules/m_cap.h
src/modules/m_cgiirc.cpp
src/modules/m_chanfilter.cpp
src/modules/m_cloaking.cpp
src/modules/m_filter.cpp
src/modules/m_hash.h
src/modules/m_httpd.cpp
src/modules/m_httpd_acl.cpp
src/modules/m_httpd_config.cpp
src/modules/m_httpd_stats.cpp
src/modules/m_ident.cpp
src/modules/m_inviteexception.cpp
src/modules/m_md5.cpp
src/modules/m_namesx.cpp
src/modules/m_override.cpp
src/modules/m_override.h [deleted file]
src/modules/m_password_hash.cpp
src/modules/m_regex.h
src/modules/m_regex_glob.cpp
src/modules/m_ripemd160.cpp
src/modules/m_rline.cpp
src/modules/m_rpc_json.cpp [deleted file]
src/modules/m_rpctest.cpp [deleted file]
src/modules/m_sasl.cpp
src/modules/m_services_account.cpp
src/modules/m_sha256.cpp
src/modules/m_spanningtree/cachetimer.cpp
src/modules/m_spanningtree/handshaketimer.cpp [deleted file]
src/modules/m_spanningtree/handshaketimer.h [deleted file]
src/modules/m_spanningtree/hmac.cpp
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/main.h
src/modules/m_spanningtree/override_admin.cpp
src/modules/m_spanningtree/override_motd.cpp
src/modules/m_spanningtree/override_squit.cpp
src/modules/m_spanningtree/override_stats.cpp
src/modules/m_spanningtree/override_time.cpp
src/modules/m_spanningtree/override_whois.cpp
src/modules/m_spanningtree/ping.cpp
src/modules/m_spanningtree/pong.cpp
src/modules/m_spanningtree/postcommand.cpp
src/modules/m_spanningtree/precommand.cpp
src/modules/m_spanningtree/push.cpp
src/modules/m_spanningtree/rconnect.cpp
src/modules/m_spanningtree/resolvers.cpp
src/modules/m_spanningtree/resolvers.h
src/modules/m_spanningtree/rsquit.cpp
src/modules/m_spanningtree/save.cpp
src/modules/m_spanningtree/server.cpp
src/modules/m_spanningtree/stats.cpp
src/modules/m_spanningtree/svsjoin.cpp
src/modules/m_spanningtree/svsnick.cpp
src/modules/m_spanningtree/svspart.cpp
src/modules/m_spanningtree/time.cpp
src/modules/m_spanningtree/treeserver.cpp
src/modules/m_spanningtree/treesocket.h
src/modules/m_spanningtree/treesocket1.cpp
src/modules/m_spanningtree/treesocket2.cpp
src/modules/m_spanningtree/uid.cpp
src/modules/m_spanningtree/utils.cpp
src/modules/m_spanningtree/utils.h
src/modules/m_spanningtree/version.cpp
src/modules/m_spanningtree/whois.cpp
src/modules/m_sqlauth.cpp
src/modules/m_sqllog.cpp
src/modules/m_sqloper.cpp
src/modules/m_sqlutils.cpp
src/modules/m_sqlv2.h
src/modules/m_sslinfo.cpp
src/modules/m_sslmodes.cpp
src/modules/m_testclient.cpp
src/modules/m_uhnames.cpp
src/modules/m_watch.cpp
src/modules/rpc.h [deleted file]
src/modules/ssl.h [new file with mode: 0644]
src/modules/transport.h [deleted file]
src/users.cpp

index d59bdf05b9dab521dca8f1d4e916fe233fd792e7..972dabb43042c06964fd262713980825def5a29d 100644 (file)
@@ -105,7 +105,7 @@ struct ModResult {
 };
 
 /** If you change the module API in any way, increment this value. */
-#define API_VERSION 131
+#define API_VERSION 132
 
 class ServerConfig;
 
@@ -254,77 +254,38 @@ class CoreExport VersionBase : public classbase
 
 typedef VersionBase<API_VERSION> Version;
 
-/** The ModuleMessage class is the base class of Request and Event
- * This class is used to represent a basic data structure which is passed
- * between modules for safe inter-module communications.
- */
-class CoreExport ModuleMessage : public Extensible
-{
- public:
-       /** Destructor
-        */
-       virtual ~ModuleMessage() {};
-};
-
 /** The Request class is a unicast message directed at a given module.
  * When this class is properly instantiated it may be sent to a module
  * using the Send() method, which will call the given module's OnRequest
  * method with this class as its parameter.
  */
-class CoreExport Request : public ModuleMessage
+class CoreExport Request : public classbase
 {
- protected:
-       /** This member holds a pointer to arbitary data set by the emitter of the message
-        */
-       char* data;
+ public:
        /** This should be a null-terminated string identifying the type of request,
         * all modules should define this and use it to determine the nature of the
         * request before they attempt to cast the Request in any way.
         */
-       const char* id;
+       const char* const id;
        /** This is a pointer to the sender of the message, which can be used to
         * directly trigger events, or to create a reply.
         */
-       Module* source;
+       Module* const source;
        /** The single destination of the Request
         */
-       Module* dest;
- public:
-       /** Create a new Request
-        * This is for the 'old' way of casting whatever the data is
-        * to char* and hoping you get the right thing at the other end.
-        * This is slowly being depreciated in favor of the 'new' way.
-        */
-       Request(char* anydata, Module* src, Module* dst);
+       Module* const dest;
+
        /** Create a new Request
         * This is for the 'new' way of defining a subclass
         * of Request and defining it in a common header,
         * passing an object of your Request subclass through
         * as a Request* and using the ID string to determine
-        * what to cast it back to and the other end. This is
-        * much safer as there are no casts not confirmed by
-        * the ID string, and all casts are child->parent and
-        * can be checked at runtime with dynamic_cast<>()
+        * what to cast it back to and the other end.
         */
        Request(Module* src, Module* dst, const char* idstr);
-       /** Fetch the Request data
-        */
-       char* GetData();
-       /** Fetch the ID string
-        */
-       const char* GetId();
-       /** Fetch the request source
-        */
-       Module* GetSource();
-       /** Fetch the request destination (should be 'this' in the receiving module)
-        */
-       Module* GetDest();
        /** Send the Request.
-        * Upon returning the result will be arbitary data returned by the module you
-        * sent the request to. It is up to your module to know what this data is and
-        * how to deal with it.
         */
-       const char* Send();
+       void Send();
 };
 
 
@@ -333,40 +294,27 @@ class CoreExport Request : public ModuleMessage
  * using the Send() method, which will trigger the OnEvent method in
  * all modules passing the object as its parameter.
  */
-class CoreExport Event : public ModuleMessage
+class CoreExport Event : public classbase
 {
- protected:
-       /** This member holds a pointer to arbitary data set by the emitter of the message
-        */
-       char* data;
+ public:
        /** This is a pointer to the sender of the message, which can be used to
         * directly trigger events, or to create a reply.
         */
-       Module* source;
+       Module* const source;
        /** The event identifier.
         * This is arbitary text which should be used to distinguish
         * one type of event from another.
         */
-       std::string id;
- public:
+       const std::string id;
+
        /** Create a new Event
         */
-       Event(char* anydata, Module* src, const std::string &eventid);
-       /** Get the Event data
-        */
-       char* GetData();
-       /** Get the event Source
-        */
-       Module* GetSource();
-       /** Get the event ID.
-        * Use this to determine the event type for safe casting of the data
-        */
-       std::string GetEventID();
+       Event(Module* src, const std::string &eventid);
        /** Send the Event.
         * The return result of an Event::Send() will always be NULL as
         * no replies are expected.
         */
-       char* Send();
+       void Send();
 };
 
 /** Priority types which can be returned from Module::Prioritize()
@@ -383,12 +331,12 @@ enum Implementation
        I_OnUserPreInvite, I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreNick,
        I_OnUserMessage, I_OnUserNotice, I_OnMode, I_OnGetServerDescription, I_OnSyncUser,
        I_OnSyncChannel, I_OnDecodeMetaData, I_OnWallops,
-       I_OnChangeHost, I_OnChangeName, I_OnAddLine, I_OnDelLine, I_OnExpireLine, I_OnCleanup,
+       I_OnChangeHost, I_OnChangeName, I_OnAddLine, I_OnDelLine, I_OnExpireLine,
        I_OnUserPostNick, I_OnPreMode, I_On005Numeric, I_OnKill, I_OnRemoteKill, I_OnLoadModule,
        I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite,
        I_OnRawMode, I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnCheckChannelBan, I_OnExtBanCheck,
        I_OnStats, I_OnChangeLocalUserHost, I_OnChangeLocalUserGecos, I_OnPreTopicChange,
-       I_OnPostTopicChange, I_OnEvent, I_OnRequest, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan,
+       I_OnPostTopicChange, I_OnEvent, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan,
        I_OnDelBan, I_OnChangeLocalUserGECOS, I_OnUserRegister, I_OnChannelPreDelete, I_OnChannelDelete,
        I_OnPostOper, I_OnSyncNetwork, I_OnSetAway, I_OnUserList, I_OnPostCommand, I_OnPostJoin,
        I_OnWhoisLine, I_OnBuildNeighborList, I_OnGarbageCollect,
@@ -1165,22 +1113,17 @@ class CoreExport Module : public Extensible
         */
        virtual void OnPostTopicChange(User* user, Channel* chan, const std::string &topic);
 
-       /** Called whenever an Event class is sent to all module by another module.
-        * Please see the documentation of Event::Send() for further information. The Event sent can
-        * always be assumed to be non-NULL, you should *always* check the value of Event::GetEventID()
-        * before doing anything to the event data, and you should *not* change the event data in any way!
+       /** Called whenever an Event class is sent to all modules by another module.
+        * You should *always* check the value of Event::id to determine the event type.
         * @param event The Event class being received
         */
-       virtual void OnEvent(Event* event);
+       virtual void OnEvent(Event& event);
 
        /** Called whenever a Request class is sent to your module by another module.
-        * Please see the documentation of Request::Send() for further information. The Request sent
-        * can always be assumed to be non-NULL, you should not change the request object or its data.
-        * Your method may return arbitary data in the char* result which the requesting module
-        * may be able to use for pre-determined purposes (e.g. the results of an SQL query, etc).
+        * The value of Request::id should be used to determine the type of request.
         * @param request The Request class being received
         */
-       virtual const char* OnRequest(Request* request);
+       virtual void OnRequest(Request& request);
 
        /** Called whenever a password check is to be made. Replaces the old OldOperCompare API.
         * The password field (from the config file) is in 'password' and is to be compared against
index 7c34605f4bb920145fb48d598a2db44aaf98f99d..86749b8abf86e08cf245ef3c7c1dfe628ecc2468 100644 (file)
@@ -49,59 +49,6 @@ typedef std::list<ListItem> modelist;
  */
 typedef std::list<ListLimit> limitlist;
 
-/** A request used to check if a user is on a channel's list or not
- */
-class ListModeRequest : public Request
-{
- public:
-       User* user;
-       std::string literal;
-       const char extban;
-       Channel* chan;
-
-       /** Check if a user is on a channel's list.
-        * The Event::Send() event returns the ban string if the user is on the channel's list,
-        * or NULL if the user is not on the list.
-        * @param sender Sending module
-        * @param target Target module
-        * @param u User to check against
-        * @param c Channel to check against
-        */
-       ListModeRequest(Module* sender, Module* target, User* u, Channel* c) : Request(sender, target, "LM_CHECKLIST"), user(u), literal(""), extban(0), chan(c)
-       {
-       }
-
-       /** Check if a literal string is on a channel's list, optionally using an extban char.
-        * The Event::Send() event returns the ban string if the user is on the channel's list,
-        * or NULL if the user is not on the list.
-        * @param sender Sending module
-        * @param target Target module
-        * @param literalstr String to check against, e.g. "Bob!Bobbertson@weeblshouse"
-        * @param extbanchar Extended ban character to use for the match, or a null char if not using extban
-        */
-       ListModeRequest(Module* sender, Module* target, std::string literalstr, char extbanchar, Channel* channel) : Request(sender, target, "LM_CHECKLIST_EX"), user(NULL), literal(literalstr), extban(extbanchar), chan(channel)
-       {
-       }
-
-       /** Check if a literal string is on a channel's list, optionally using an extban char.
-        * The Event::Send() event returns the ban string if the user is on the channel's list,
-        * or NULL if the user is not on the list.
-        * @param sender Sending module
-        * @param target Target module
-        * @param User to check against, e.g. "Bob!Bobbertson@weeblshouse"
-        * @param extbanchar Extended ban character to use for the match, or a null char if not using extban
-        */
-       ListModeRequest(Module* sender, Module* target, User* u, char extbanchar, Channel* channel) : Request(sender, target, "LM_CHECKLIST_EX"), user(u), literal(""), extban(extbanchar), chan(channel)
-       {
-       }
-
-       /** Destructor
-        */
-       ~ListModeRequest()
-       {
-       }
-};
-
 /** The base class for list modes, should be inherited.
  */
 class ListModeBase : public ModeHandler
@@ -262,8 +209,8 @@ class ListModeBase : public ModeHandler
         */
        virtual void DoImplements(Module* m)
        {
-               Implementation eventlist[] = { I_OnChannelDelete, I_OnSyncChannel, I_OnCleanup, I_OnRehash, I_OnRequest };
-               ServerInstance->Modules->Attach(eventlist, m, 5);
+               Implementation eventlist[] = { I_OnChannelDelete, I_OnSyncChannel, I_OnRehash };
+               ServerInstance->Modules->Attach(eventlist, m, 3);
        }
 
        /** Handle the list mode.
@@ -462,72 +409,6 @@ class ListModeBase : public ModeHandler
        virtual void TellNotSet(User*, Channel*, std::string&)
        {
        }
-
-       virtual const char* DoOnRequest(Request* request)
-       {
-               ListModeRequest* LM = (ListModeRequest*)request;
-               if (strcmp("LM_CHECKLIST", request->GetId()) == 0)
-               {
-                       modelist* mlist = extItem.get(LM->chan);
-                       if (mlist)
-                       {
-                               std::string mask = LM->user->nick + "!" + LM->user->ident + "@" + LM->user->GetIPString();
-                               for (modelist::iterator it = mlist->begin(); it != mlist->end(); ++it)
-                               {
-                                       if (InspIRCd::Match(LM->user->GetFullRealHost(), it->mask) || InspIRCd::Match(LM->user->GetFullHost(), it->mask) || (InspIRCd::MatchCIDR(mask, it->mask)))
-                                               return it->mask.c_str();
-                               }
-                               return NULL;
-                       }
-               }
-               else if (strcmp("LM_CHECKLIST_EX", request->GetId()) == 0)
-               {
-                       modelist* mlist = extItem.get(LM->chan);
-
-                       if (mlist)
-                       {
-                               if (LM->user)
-                               {
-                                       LM->literal = LM->user->nick + "!" + LM->user->ident + "@" + LM->user->GetIPString();
-                               }
-
-                               for (modelist::iterator it = mlist->begin(); it != mlist->end(); it++)
-                               {
-                                       if (LM->extban && it->mask.length() > 1 && it->mask[0] == LM->extban && it->mask[1] == ':')
-                                       {
-                                               std::string ext = it->mask.substr(2);
-                                               if (LM->user)
-                                               {
-                                                       if (InspIRCd::Match(LM->user->GetFullRealHost(), ext) || InspIRCd::Match(LM->user->GetFullHost(), ext) || (InspIRCd::MatchCIDR(LM->literal, ext)))
-                                                       {
-                                                               return it->mask.c_str();
-                                                       }
-                                               }
-                                               else if (InspIRCd::Match(LM->literal, ext))
-                                               {
-                                                       return it->mask.c_str();
-                                               }
-                                       }
-                                       else
-                                       {
-                                               if (LM->user)
-                                               {
-                                                       if (InspIRCd::Match(LM->user->GetFullRealHost(), it->mask) || InspIRCd::Match(LM->user->GetFullHost(), it->mask) || (InspIRCd::MatchCIDR(LM->literal, it->mask)))
-                                                       {
-                                                               return it->mask.c_str();
-                                                       }
-                                               }
-                                               else if (InspIRCd::Match(LM->literal, it->mask))
-                                               {
-                                                       return it->mask.c_str();
-                                               }
-                                       }
-                               }
-                       }
-               }
-               return NULL;
-       }
-
 };
 
 #endif
index 837e5d01627832347bb09d86238320c3f7c6c78b..a11b02b2d70c7312fa222e65e7a2054e407124b6 100644 (file)
@@ -314,16 +314,16 @@ class ModuleWhoWas : public Module
                ServerInstance->AddCommand(&cmd);
        }
 
-       const char* OnRequest(Request* request)
+       void OnRequest(Request& request)
        {
-               WhowasRequest* req = static_cast<WhowasRequest*>(request);
-               switch (req->type)
+               WhowasRequest& req = static_cast<WhowasRequest&>(request);
+               switch (req.type)
                {
                        case WhowasRequest::WHOWAS_ADD:
-                               cmd.AddToWhoWas(req->user);
+                               cmd.AddToWhoWas(req.user);
                                break;
                        case WhowasRequest::WHOWAS_STATS:
-                               req->value = cmd.GetStats();
+                               req.value = cmd.GetStats();
                                break;
                        case WhowasRequest::WHOWAS_PRUNE:
                                cmd.PruneWhoWas(ServerInstance->Time());
@@ -332,7 +332,6 @@ class ModuleWhoWas : public Module
                                cmd.MaintainWhoWas(ServerInstance->Time());
                                break;
                }
-               return NULL;
        }
 
        Version GetVersion()
index 8731489c435cc5761f0a452b2ca6dbd5fedbaa90..453a80127f7c435abca11fad2da498e84f165051 100644 (file)
@@ -29,7 +29,7 @@ DLLManager::DLLManager(const char *fname)
                return;
        }
 
-       h = dlopen(fname, RTLD_NOW|RTLD_LOCAL);
+       h = dlopen(fname, RTLD_NOW|RTLD_LOCAL|RTLD_NODELETE);
        if (!h)
        {
                err = dlerror();
index ee18112a1597dfaecad4a2bf42883be5af470df4..921e710f93de4baba316d4074d95ad76f343f26f 100644 (file)
@@ -33,76 +33,24 @@ VersionBase<API_VERSION>::VersionBase(const std::string &modv, int flags, int, c
 {
 }
 
-Request::Request(char* anydata, Module* src, Module* dst)
-: data(anydata), source(src), dest(dst)
-{
-       /* Ensure that because this module doesnt support ID strings, it doesnt break modules that do
-        * by passing them uninitialized pointers (could happen)
-        */
-       id = '\0';
-}
-
 Request::Request(Module* src, Module* dst, const char* idstr)
 : id(idstr), source(src), dest(dst)
 {
 }
 
-char* Request::GetData()
+void Request::Send()
 {
-       return this->data;
+       if (dest)
+               dest->OnRequest(*this);
 }
 
-const char* Request::GetId()
-{
-       return this->id;
-}
-
-Module* Request::GetSource()
-{
-       return this->source;
-}
+Event::Event(Module* src, const std::string &eventid) : source(src), id(eventid) { }
 
-Module* Request::GetDest()
+void Event::Send()
 {
-       return this->dest;
+       FOREACH_MOD(I_OnEvent,OnEvent(*this));
 }
 
-const char* Request::Send()
-{
-       if (this->dest)
-       {
-               return dest->OnRequest(this);
-       }
-       else
-       {
-               return NULL;
-       }
-}
-
-Event::Event(char* anydata, Module* src, const std::string &eventid) : data(anydata), source(src), id(eventid) { }
-
-char* Event::GetData()
-{
-       return this->data;
-}
-
-Module* Event::GetSource()
-{
-       return this->source;
-}
-
-char* Event::Send()
-{
-       FOREACH_MOD(I_OnEvent,OnEvent(this));
-       return NULL;
-}
-
-std::string Event::GetEventID()
-{
-       return this->id;
-}
-
-
 // These declarations define the behavours of the base class Module (which does nothing at all)
 
 Module::Module() { }
@@ -157,8 +105,8 @@ ModResult   Module::OnStats(char, User*, string_list&) { return MOD_RES_PASSTHRU;
 ModResult      Module::OnChangeLocalUserHost(User*, const std::string&) { return MOD_RES_PASSTHRU; }
 ModResult      Module::OnChangeLocalUserGECOS(User*, const std::string&) { return MOD_RES_PASSTHRU; }
 ModResult      Module::OnPreTopicChange(User*, Channel*, const std::string&) { return MOD_RES_PASSTHRU; }
-void           Module::OnEvent(Event*) { return; }
-const char*            Module::OnRequest(Request*) { return NULL; }
+void           Module::OnEvent(Event&) { }
+void           Module::OnRequest(Request&) { }
 ModResult      Module::OnPassCompare(Extensible* ex, const std::string &password, const std::string &input, const std::string& hashtype) { return MOD_RES_PASSTHRU; }
 void           Module::OnGlobalOper(User*) { }
 void           Module::OnPostConnect(User*) { }
index 8b86a178bc7071e1b56e3e7fdea5cbd9f6eb96e2..9182d7ca6c3b254ea66a1a5f739ede8a8d241b56 100644 (file)
 #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
index a0ac9ffac165d094803f1a13e3c2c8ac5e976976..a921dea8ef102b11b6d477843f0c97ed6dfd7d59 100644 (file)
@@ -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)
index c0b2bbac852516dac9c4d70fd237fcf623186828..df0ca7f4266bb88430a3aa9b9d894822bef4b9d9 100644 (file)
@@ -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)
index 7828477361fa471b7acc2a626f98e4c92f958e8f..16d0cfe15e1e5064faaebe007de9bdf1fea89ef3 100644 (file)
@@ -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;
        }
 };
 
index 7afaad076b62ad22230f6fda2e16f93b7c84e95c..62b44e0e4dae4497c53b1ee9fce605d88b976d65 100644 (file)
@@ -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;
        }
 };
 
index 41aaec31c44db42fbc7ad62f8ce584f1d53b3754..f2a9004bd8325c0ad2a7a8ef158280337074324e 100644 (file)
@@ -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;
        }
 };
 
index 806cbce7210d4aaf763b4c327a59bb6d00d2f6c8..680053bf1e08ff1a31c6a617634fc814a37de6be 100644 (file)
@@ -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()
index 813ae9e9b1a57fa278e107dc38bab8de7878c9d2..3530b0e1fbabe51b6c5894a628eb48f8f17c7e1b 100644 (file)
@@ -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);
        }
index f566b326b3a41d30cb852d180238435b73e58ac4..8af930aa92c3d7d93c0cf2ed68cd393e1c8ac6a5 100644 (file)
@@ -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()
index 976a27b5c7293bec55c4a336b428aaec1f3d989d..4b53cf389c3f0a33d8c6acd288bcb6b33d7473e7 100644 (file)
 
 #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) */
index f40050e36eb90a5f60da4689cd4c1d761ad96ee9..483009095572bcbd409106229bea9e1b0388a890 100644 (file)
@@ -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;
        }
 };
 
index 782f55b9253ceee99cd03a115b91f21745c68a41..31e593fdf723d812ee50c1328f5ff4ee15b56008 100644 (file)
@@ -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);
index 33cb4d87490d4632f2104a9d124d57574d91902d..540155b81fc3ff69cdec37ec0c59e2318589d610 100644 (file)
@@ -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);
index dbd81ed5395585156f0e2729d82ccc9468db2711..3373f7c3f762ea0c3e63f66deaf60bec12fb6bee 100644 (file)
@@ -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());
index a375801264218bf345543b95c8fa1979d5ff77ff..809b0f4cf2eb3062f6537b9351a1ca3d124d1d64 100644 (file)
@@ -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);
                }
index 1300092c7afe7c049b6bbee827942722ed0f4191..d36a1d92a471df30acc368e7fcf148d177430aa1 100644 (file)
@@ -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);
        }
 
 
index b517d363e5bea15b21b9e03c1caab6d8e7288eac..bae2143d75c000789d400b999a4f12c7822ffe31 100644 (file)
@@ -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);
index f8743d94cc0196b7dba373b26a4402aa0829efe5..ade4339b8c17ea64c00696e350b123510de9d4b5 100644 (file)
@@ -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.
index ebb5a0038993a50ace37368204f39ab95456b20b..5beb46fc44c96d34f634af155149444f4906a13a 100644 (file)
@@ -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;
index 88dcb5b6d5fa93872b1288044b0dd4746ea30871..f39d0eee748b676db2a0556c3fb6861a0ca5bc8a 100644 (file)
 #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();
        }
 };
 
index e9d05d3e54c11c93fd63efb4cfd894466ff8c5d1..9d1acfbb99be09cf7e560a791ad5a8de2f393a4a 100644 (file)
@@ -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);
        }
 
 
index 8c682cfa9448d05ad12802d9f43a97cd69d5faf5..dd68f3087f93324545d9f6cbd2b37bab3dd77f34 100644 (file)
@@ -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()
        {
        }
index 55f943d2c33f32b8f0fafe7792a88a915902c1c4..988ba397790cf3d30cc3f3506f18386203bef678 100644 (file)
@@ -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()
        {
        }
index 46f474e2df2c8a61f9b2ef19cb85dd533e815e78..5e30c90ca4810bf5274b89c6a2b08c2ce4a36f89 100644 (file)
@@ -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()
        {
        }
index d74873e00770d9aaeb3b8c93552f5a7babff61ff..0ba9e6e3a6de398400c30c50dc381385bfc7d5d2 100644 (file)
@@ -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()
index b71992c053db8e226e2e8e8cbfa41334a57882aa..91f4e22c8acfacc7ac84f80687c5ca9453b5f9a6 100644 (file)
@@ -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);
index 911f6d9263ebd6a5bf448a28a5698f270659560c..00d3fb1e9260fa1ddcc8247b1b814bfa5c500d29 100644 (file)
@@ -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);
        }
index 7614cdc7642b85ccb04045bec4730c746ef3a1e6..093ebc64ffcd1eaa68d1f4fe444f85d373300569 100644 (file)
@@ -72,7 +72,7 @@ class ModuleNamesX : public Module
                prefixes = memb->chan->GetAllPrefixChars(memb->user);
        }
 
-       void OnEvent(Event *ev)
+       void OnEvent(Eventev)
        {
                cap.HandleEvent(ev);
        }
index 8162d45e33f77f5fddb5a2d5923ba7e25e26550f..c737be28631c005aaa5654e60d7e9d87d4556dd5 100644 (file)
@@ -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 (executable)
index f17e78e..0000000
+++ /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;
-       }
-};
index 12769acd4d07eb28a49496fa590db166df68f7a3..b9fcb63a4cef88216d541d687dbc664edfa00e8f 100644 (file)
@@ -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
index c8cbc10b69c6c3db1a36df45a8dc186200a881ec..969c4920bc1e328ed29b21b5e71f3b972154a7fc 100644 (file)
@@ -67,8 +67,10 @@ public:
 class RegexNameRequest : public Request
 {
 public:
+       std::string result;
        RegexNameRequest(Module* Me, Module* Target) : Request(Me, Target, "REGEX-NAME")
        {
+               Send(); 
        }
 };
 
index ef843cc767e07e0ff30150b2fda9c56d852196be..a3923205f9321771683372beb739d9282dc79759 100644 (file)
@@ -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;
        }
 };
 
index 1d3b1eb3406820252cf50adcd6bc11625c78ba21..3e94efb0ac2509b304d6ad097b8744a3219bfcba 100644 (file)
@@ -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()
index 31b382a22dcc8e3cb73c08a942ceee9a160ab013..a1a57199a328fc87a3792c6e133623f2cfbe8c41 100644 (file)
@@ -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 (file)
index e57bb77..0000000
+++ /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 (file)
index a339765..0000000
+++ /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)
-
index 48e07ef6d58b2aa278c1f5277a96f7a24e2ef08d..938449bbb3f0a445cf8ca2727eff94779084ede6 100644 (file)
@@ -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);
        }
index 73723f4e1bc886dc745a236089cf968da71cfe80..159f5ec0f8d50c977bf710589f85dc6a190bd50e 100644 (file)
@@ -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();
                        }
                }
        }
index c41bd06997c38f67fe11a498662c6ce6087691e0..07c9ea04b674a3a2d00ea6a3666b2183b56965fd 100644 (file)
@@ -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);
        }
index 989ed565f8061e0dcfd25ab339aa5df085aed1ff..7b5478b13c20d1fcf0dba736a60993a1fe7c0dd0 100644 (file)
@@ -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 (file)
index b264a4c..0000000
+++ /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 (file)
index 527b056..0000000
+++ /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
index b7cddc47ac750ce23ef349f043a830a051202a0a..ad35a585f4a1294ffd008a165f7032a18f155301 100644 (file)
@@ -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();
index 7d6974cf013ed73b431259e8ae6a41d02a0fcf3f..23523107af5308b4e4ea617920964c3b89019da9 100644 (file)
@@ -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();
index 59d40eca4917027c311caef72e22ba89ddc3f23f..1057fcdfc511ee45432447e86bad9ac2a4d9b033 100644 (file)
@@ -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();
index 2a5cfcdabd035e48fa63fc5d68a473cc5cadfb2a..293768759448106c96a889800b23c7001b628f61 100644 (file)
@@ -16,7 +16,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 
 #include "main.h"
 #include "utils.h"
index 270608062618b493b2f58e6cc0513cb5b14de7db..a5f4e684efb1645cc0039c61740abb52060de111 100644 (file)
@@ -16,7 +16,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 
 #include "main.h"
 #include "utils.h"
index 5360f176cf9d3a8218e3cc2d63c290b3812785d1..e30c9ba501774f03759dab0585e1c62b9007a83d 100644 (file)
@@ -16,7 +16,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 
 #include "main.h"
 #include "utils.h"
index 93190a978d01f1c28ee31b2a24120f033577aa9d..09d0a691d418963e9e0d660d844ed9725f87a9c6 100644 (file)
@@ -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 + ")");
                }
        }
index 54a2870bdf72e2cb9313fb31ef5f174e633df46b..b3384720edf6606a8ca54d4502511d12e365f118 100644 (file)
@@ -16,7 +16,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 
 #include "main.h"
 #include "utils.h"
index 84bf8ce779e90805f61a4e6a5faf66fa720d112b..ee3be53fd34565b38733ba59e54572580c47ea62 100644 (file)
@@ -16,7 +16,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 
 #include "main.h"
 #include "utils.h"
index c3467c984d6a854e714355b2439bbea56694c837..2d468916d99ad4ff835a5cf024e0596f1c1ba1e5 100644 (file)
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 #include "socketengine.h"
 
 #include "main.h"
index 27464189781541f4e8c45f7f380c3a444f74f131..675e17f45a9e04cca14b8d9e6c82d0c3584c0576 100644 (file)
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 #include "socketengine.h"
 
 #include "main.h"
index fbac46faa4b82b25f45562f53a96df14dbd27a54..84ca342ecb2879fe67ee73c940630e829306f3d2 100644 (file)
@@ -16,7 +16,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 
 #include "main.h"
 #include "utils.h"
index a024a4901eed68a5f57dd1bda1c831b7b89a08bf..c43e4e927c12566bb173dfc517a21838791887eb 100644 (file)
@@ -16,7 +16,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 
 #include "main.h"
 #include "utils.h"
index 778c2291cad09cfdfada27961f43085535f2238e..e67b926c88e945582e6dfec38881da0f15abb8f4 100644 (file)
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 #include "socketengine.h"
 
 #include "main.h"
index 422a4b428ce6161ae318fd0a12b11840623d04be..5a4c71c3c0283cfed1acf23a3a7cad67a086a831 100644 (file)
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 
 #include "resolvers.h"
 #include "main.h"
index e168b98f5667ed4bd123971b82c3ce6517cfc437..b95ba79c3dff1aa3eee8b64a8ff8d2a36155ceeb 100644 (file)
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 
 #include "resolvers.h"
 #include "main.h"
  * 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;
        }
index 29ead13de2ffed539dcbaef9a0f13ae1be92d4d0..5d4386c4b2c276f5931fb34d244e292da27aafc8 100644 (file)
@@ -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
index 194536c478a1771d47a2cbe4efb613098c8340c1..271e845d5efeb0bf37324ef2ca7a83ddb3b939ea 100644 (file)
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 
 #include "main.h"
 #include "utils.h"
index cfa8dc7943974707ce72565092474e88693de408..1fbea005287ce55d7c9e2a7a6d97a54bf3ec55d0 100644 (file)
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 #include "socketengine.h"
 
 #include "main.h"
index 900aceb9dfde62ee11a97c014082487eae0539a9..6fda446ea16fab29cf1348eb77cc36ce1e11e4f6 100644 (file)
@@ -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.
index 71f12d50b8e3ee07f042a6b9210483cd61a95908..bc568de2614211ce6bdfaacee7c9c28ad7631804 100644 (file)
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 #include "socketengine.h"
 
 #include "main.h"
index dff882f622cc2198c7746ddd8bfc9be62c8a0609..4fdc05dea45c4bf6f65ad612caf4c49f37dd5a15 100644 (file)
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 #include "socketengine.h"
 
 #include "main.h"
index 7a723a36d4d6835318c53da31f084807dc408d59..87b63ec26df79a06d4cfc6a69078d76fdbe4e58e 100644 (file)
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 #include "socketengine.h"
 
 #include "main.h"
index 1e26c90d99b1a05ae8a8d8a68979dd8d173411d1..cc49aa72e0020aeeccdc50e51888ae7f1aa40517 100644 (file)
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 #include "socketengine.h"
 
 #include "main.h"
index 6fdcf8b5391eba2e8afc6228f7694b4862ad0881..f44a08e5c8c4031b1d2a9405d28c632a737e9ca1 100644 (file)
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 #include "socketengine.h"
 
 #include "main.h"
index 95f6866988be14306ad97ea6aca97bf2d5408e65..5c7162094738724e5f8832e1be4260b645f7bf08 100644 (file)
@@ -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)
index b29a0480c73b054d3789293eb3cacea23fef81dc..a0f0e5d88e05622c921fb8ae901869f972f82544 100644 (file)
 #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
         */
index 70046d774a0f9f90548034f3dde2e8046423da6e..2c845bbd4bf6384d9c89437a90e2476b62a8e622 100644 (file)
 #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());
index bdda77ee109da3a06e9d1eb6f7b91cad08fd4ba4..c670e4b9a73966f5cb232d0c7551c64dc0508f24 100644 (file)
@@ -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)
index 6279564df90bddd1246b00550a6e89aa770a659c..4e3b07eea02d64132ff2051b7e8c0553d6f90ab3 100644 (file)
@@ -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 */
 
index 3cdd495aac3bbd8fa14b733e4921e1ce48c3c854..3b70fce312fbe0b7abb92bb406f54d36608cf04d 100644 (file)
@@ -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");
 
index d8bf765b57626c5802b9019c4c9a424e8ce031c3..7c15b2839f89d5a26d3d9b32ac57732388d77548 100644 (file)
@@ -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.
         *
index 6cec7baf9d31820c6a12d244ae907da54a4a3563..ba5386ffb02aec8815aef6e05d545370be84b456 100644 (file)
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 #include "socketengine.h"
 
 #include "main.h"
index 79e2d73552cab91572cf7bd5619d4ce9da523d1b..03fb5f9234e627c76065540ca0cd032b32b2e7dd 100644 (file)
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 #include "socketengine.h"
 
 #include "main.h"
index 256bf346a8698f610d267224f83efea366dffca2..aefd54ef7759acc3b52d48c82371dc2fcedcfcdd 100644 (file)
@@ -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)
index c70c1bf7a839a39cc648d38801435eba67833d96..f1174b0ce778bc402f6ca9ad6d8a5055f15d93a5 100644 (file)
@@ -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)
index 5f0df4c1064984d568991ebf1fb549d9d3e2d13e..36bda5c58d468bbc8a69f8eb8ee2d9dfb5c9195f 100644 (file)
@@ -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)
index a80e1262b7c34441caed6acf70bd094f975edd46..f63cd3eab539c663f148e4fec17186b292d4ef84 100644 (file)
@@ -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)
index a9297bd805c8effab3bff60637a34482d9c7203e..bcdcb6546fe6e2b3a7e018c32379e84aef158855 100644 (file)
@@ -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++;
                }
        }
 };
index 1b5a39ba47286616240115b62b55d24312c62780..a1178f9176c0c7b74680bb233be79ba395b26724 100644 (file)
@@ -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;
        }
 };
 
index 50fb179463492476ad94e658e193da420bb9c6a7..d6768904cb0d83304a145494b458d6a5ba1357d7 100644 (file)
@@ -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;
index 3e41f533ffcfb284ed0ebe3d69c0754303a2e667..c6abb006449504b946e8afeb0e8370057d516929 100644 (file)
@@ -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()
index be199208dbd21c4672b91272bedf669163808d3d..f9ede6c12ecb8d8ccbb728918c543781aeda2cea 100644 (file)
@@ -71,7 +71,7 @@ class ModuleUHNames : public Module
                nick = memb->user->GetFullHost();
        }
 
-       void OnEvent(Event* ev)
+       void OnEvent(Event& ev)
        {
                cap.HandleEvent(ev);
        }
index 24b4edc093994e10afa619e70e0746232000bde5..9030c1788e92fac2f154a04564c6134a384d39fc 100644 (file)
@@ -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 (file)
index 36f1c03..0000000
+++ /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/ssl.h b/src/modules/ssl.h
new file mode 100644 (file)
index 0000000..39a7ef5
--- /dev/null
@@ -0,0 +1,150 @@
+/*       +------------------------------------+
+ *       | 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 __SSL_H__
+#define __SSL_H__
+
+#include <map>
+#include <string>
+
+/** ssl_cert is a class which abstracts SSL certificate
+ * and key information.
+ *
+ * Because gnutls and openssl represent key information in
+ * wildly different ways, this class allows it to be accessed
+ * in a unified manner. These classes are attached to ssl-
+ * connected local users using SSLCertExt
+ */
+class ssl_cert
+{
+ public:
+       std::string dn;
+       std::string issuer;
+       std::string error;
+       std::string fingerprint;
+       bool trusted, invalid, unknownsigner, revoked;
+
+       /** Get certificate distinguished name
+        * @return Certificate DN
+        */
+       const std::string& GetDN()
+       {
+               return dn;
+       }
+
+       /** Get Certificate issuer
+        * @return Certificate issuer
+        */
+       const std::string& GetIssuer()
+       {
+               return issuer;
+       }
+
+       /** Get error string if an error has occured
+        * @return The error associated with this users certificate,
+        * or an empty string if there is no error.
+        */
+       const std::string& GetError()
+       {
+               return error;
+       }
+
+       /** Get key fingerprint.
+        * @return The key fingerprint as a hex string.
+        */
+       const std::string& GetFingerprint()
+       {
+               return fingerprint;
+       }
+
+       /** Get trust status
+        * @return True if this is a trusted certificate
+        * (the certificate chain validates)
+        */
+       bool IsTrusted()
+       {
+               return trusted;
+       }
+
+       /** Get validity status
+        * @return True if the certificate itself is
+        * correctly formed.
+        */
+       bool IsInvalid()
+       {
+               return invalid;
+       }
+
+       /** Get signer status
+        * @return True if the certificate appears to be
+        * self-signed.
+        */
+       bool IsUnknownSigner()
+       {
+               return unknownsigner;
+       }
+
+       /** Get revokation status.
+        * @return True if the certificate is revoked.
+        * Note that this only works properly for GnuTLS
+        * right now.
+        */
+       bool IsRevoked()
+       {
+               return revoked;
+       }
+
+       std::string GetMetaLine()
+       {
+               std::stringstream value;
+               bool hasError = error.length();
+               value << (IsInvalid() ? "v" : "V") << (IsTrusted() ? "T" : "t") << (IsRevoked() ? "R" : "r")
+                       << (IsUnknownSigner() ? "s" : "S") << (hasError ? "E" : "e") << " ";
+               if (hasError)
+                       value << GetError();
+               else
+                       value << GetFingerprint() << " " << GetDN() << " " << GetIssuer();
+               return value.str();
+       }
+};
+
+struct SSLCertificateRequest : public Request
+{
+       Extensible* const item;
+       ssl_cert* cert;
+       SSLCertificateRequest(StreamSocket* ss, Module* Me)
+               : Request(Me, ss->GetIOHook(), "GET_CERT"), item(ss), cert(NULL)
+       {
+               Send();
+       }
+
+       std::string GetFingerprint()
+       {
+               if (cert)
+                       return cert->GetFingerprint();
+               return "";
+       }
+};
+
+struct SSLCertSubmission : public Request
+{
+       Extensible* const item;
+       ssl_cert* const cert;
+       SSLCertSubmission(Extensible* is, Module* Me, Module* Target, ssl_cert* Cert)
+               : Request(Me, Target, "SET_CERT"), item(is), cert(Cert)
+       {
+               Send();
+       }
+};
+
+#endif
diff --git a/src/modules/transport.h b/src/modules/transport.h
deleted file mode 100644 (file)
index ceb16cb..0000000
+++ /dev/null
@@ -1,206 +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 __TRANSPORT_H__
-#define __TRANSPORT_H__
-
-#include <map>
-#include <string>
-
-/** ssl_cert is a class which abstracts SSL certificate
- * and key information.
- *
- * Because gnutls and openssl represent key information in
- * wildly different ways, this class allows it to be accessed
- * in a unified manner. These classes are attached to ssl-
- * connected local users using SSLCertExt
- */
-class ssl_cert
-{
- public:
-       std::string dn;
-       std::string issuer;
-       std::string error;
-       std::string fingerprint;
-       bool trusted, invalid, unknownsigner, revoked;
-
-       /** Get certificate distinguished name
-        * @return Certificate DN
-        */
-       const std::string& GetDN()
-       {
-               return dn;
-       }
-
-       /** Get Certificate issuer
-        * @return Certificate issuer
-        */
-       const std::string& GetIssuer()
-       {
-               return issuer;
-       }
-
-       /** Get error string if an error has occured
-        * @return The error associated with this users certificate,
-        * or an empty string if there is no error.
-        */
-       const std::string& GetError()
-       {
-               return error;
-       }
-
-       /** Get key fingerprint.
-        * @return The key fingerprint as a hex string.
-        */
-       const std::string& GetFingerprint()
-       {
-               return fingerprint;
-       }
-
-       /** Get trust status
-        * @return True if this is a trusted certificate
-        * (the certificate chain validates)
-        */
-       bool IsTrusted()
-       {
-               return trusted;
-       }
-
-       /** Get validity status
-        * @return True if the certificate itself is
-        * correctly formed.
-        */
-       bool IsInvalid()
-       {
-               return invalid;
-       }
-
-       /** Get signer status
-        * @return True if the certificate appears to be
-        * self-signed.
-        */
-       bool IsUnknownSigner()
-       {
-               return unknownsigner;
-       }
-
-       /** Get revokation status.
-        * @return True if the certificate is revoked.
-        * Note that this only works properly for GnuTLS
-        * right now.
-        */
-       bool IsRevoked()
-       {
-               return revoked;
-       }
-
-       std::string GetMetaLine()
-       {
-               std::stringstream value;
-               bool hasError = error.length();
-               value << (IsInvalid() ? "v" : "V") << (IsTrusted() ? "T" : "t") << (IsRevoked() ? "R" : "r")
-                       << (IsUnknownSigner() ? "s" : "S") << (hasError ? "E" : "e") << " ";
-               if (hasError)
-                       value << GetError();
-               else
-                       value << GetFingerprint() << " " << GetDN() << " " << GetIssuer();
-               return value.str();
-       }
-};
-
-/** 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
-{
- 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)
-       {
-       }
-};
-
-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)
-       {
-       }
-};
-
-struct BufferedSocketFingerprintSubmission : public Request
-{
-       Extensible* const item;
-       ssl_cert* const cert;
-       BufferedSocketFingerprintSubmission(Extensible* is, Module* Me, Module* Target, ssl_cert* Cert)
-               : Request(Me, Target, "SET_CERT"), item(is), cert(Cert)
-       {
-       }
-};
-
-#endif
index 889e5acdc5c0f0a8e8ac4e6f77dda5fcc9868f1c..647619ae81e7027ec7b6410b21491de712c2714f 100644 (file)
@@ -20,8 +20,7 @@
 #include "bancache.h"
 #include "commands/cmd_whowas.h"
 
-/* XXX: Used for speeding up WriteCommon operations */
-unsigned long uniq_id = 1;
+static unsigned long uniq_id = 1;
 
 static unsigned long* already_sent = NULL;