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