]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_ssl_dummy.cpp
Updates, should be able to safely unload client modules with queries in progress...
[user/henk/code/inspircd.git] / src / modules / m_ssl_dummy.cpp
1 /*   +------------------------------------+
2  *   | Inspire Internet Relay Chat Daemon |
3  *   +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *   E-mail:
7  *      <brain@chatspike.net>
8  *      <Craig@chatspike.net>
9  * <omster@gmail.com>
10  * 
11  * Written by Craig Edwards, Craig McLure, and others.
12  * This program is free but copyrighted software; see
13  *the file COPYING for details.
14  *
15  * ---------------------------------------------------
16  */
17
18 #include "users.h"
19 #include "modules.h"
20 #include "helperfuncs.h"
21
22 /* $ModDesc: Makes remote /whoises to SSL servers work on a non-ssl server */
23
24 class ModuleSSLDummy : public Module
25 {
26         Server* Srv;
27         char* dummy;
28  public:
29         
30         ModuleSSLDummy(Server* Me)      : Module::Module(Me)
31         {
32                 Srv = Me;
33         }
34         
35         virtual ~ModuleSSLDummy()
36         {
37         }
38                 
39         virtual Version GetVersion()
40         {
41                 return Version(1, 0, 0, 0, VF_VENDOR);
42         }
43
44         void Implements(char* List)
45         {
46                 List[I_OnSyncUserMetaData] = List[I_OnDecodeMetaData] = List[I_OnWhois] = 1;
47         }
48
49         // :kenny.chatspike.net 320 Om Epy|AFK :is a Secure Connection
50         virtual void OnWhois(userrec* source, userrec* dest)
51         {
52                 if(dest->GetExt("ssl", dummy))
53                 {
54                         WriteServ(source->fd, "320 %s %s :is using a secure connection", source->nick, dest->nick);
55                 }
56         }
57         
58         virtual void OnSyncUserMetaData(userrec* user, Module* proto, void* opaque, const std::string &extname)
59         {
60                 // check if the linking module wants to know about OUR metadata
61                 if(extname == "ssl")
62                 {
63                         // check if this user has an ssl field to send
64                         if(user->GetExt(extname, dummy))
65                         {
66                                 // call this function in the linking module, let it format the data how it
67                                 // sees fit, and send it on its way. We dont need or want to know how.
68                                 proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, "ON");
69                         }
70                 }
71         }
72         
73         virtual void OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata)
74         {
75                 // check if its our metadata key, and its associated with a user
76                 if ((target_type == TYPE_USER) && (extname == "ssl"))
77                 {
78                         userrec* dest = (userrec*)target;
79                         // if they dont already have an ssl flag, accept the remote server's
80                         if (!dest->GetExt(extname, dummy))
81                         {
82                                 dest->Extend(extname, "ON");
83                         }
84                 }
85         }
86 };
87
88 class ModuleSSLDummyFactory : public ModuleFactory
89 {
90  public:
91         ModuleSSLDummyFactory()
92         {
93         }
94         
95         ~ModuleSSLDummyFactory()
96         {
97         }
98         
99         virtual Module * CreateModule(Server* Me)
100         {
101                 return new ModuleSSLDummy(Me);
102         }
103 };
104
105
106 extern "C" void * init_module( void )
107 {
108         return new ModuleSSLDummyFactory;
109 }
110