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