]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_ssl_dummy.cpp
Header update: 2007 -> 2008
[user/henk/code/inspircd.git] / src / modules / m_ssl_dummy.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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
16 /* $ModDesc: Makes remote /whoises to SSL servers work on a non-ssl server */
17
18 class ModuleSSLDummy : public Module
19 {
20         
21         char* dummy;
22  public:
23         
24         ModuleSSLDummy(InspIRCd* Me)    : Module(Me)
25         {
26                 
27                 Implementation eventlist[] = { I_OnSyncUserMetaData, I_OnDecodeMetaData, I_OnWhois };
28                 ServerInstance->Modules->Attach(eventlist, this, 3);
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
41         // :kenny.chatspike.net 320 Om Epy|AFK :is a Secure Connection
42         virtual void OnWhois(User* source, User* dest)
43         {
44                 if(dest->GetExt("ssl", dummy))
45                 {
46                         ServerInstance->SendWhoisLine(source, dest, 320, "%s %s :is using a secure connection", source->nick, dest->nick);
47                 }
48         }
49         
50         virtual void OnSyncUserMetaData(User* user, Module* proto, void* opaque, const std::string &extname, bool displayable)
51         {
52                 // check if the linking module wants to know about OUR metadata
53                 if(extname == "ssl")
54                 {
55                         // check if this user has an ssl field to send
56                         if(user->GetExt(extname, dummy))
57                         {
58                                 // call this function in the linking module, let it format the data how it
59                                 // sees fit, and send it on its way. We dont need or want to know how.
60                                 proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, displayable ? "Enabled" : "ON");
61                         }
62                 }
63         }
64         
65         virtual void OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata)
66         {
67                 // check if its our metadata key, and its associated with a user
68                 if ((target_type == TYPE_USER) && (extname == "ssl"))
69                 {
70                         User* dest = (User*)target;
71                         // if they dont already have an ssl flag, accept the remote server's
72                         if (!dest->GetExt(extname, dummy))
73                         {
74                                 dest->Extend(extname, "ON");
75                         }
76                 }
77         }
78 };
79
80 MODULE_INIT(ModuleSSLDummy)