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