]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_ssl_dummy.cpp
Remove unneeded headers from spanningtree. This was done to the rest of the source...
[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
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         }
28         
29         virtual ~ModuleSSLDummy()
30         {
31         }
32                 
33         virtual Version GetVersion()
34         {
35                 return Version(1, 0, 0, 0, VF_VENDOR, API_VERSION);
36         }
37
38         void Implements(char* List)
39         {
40                 List[I_OnSyncUserMetaData] = List[I_OnDecodeMetaData] = List[I_OnWhois] = 1;
41         }
42
43         // :kenny.chatspike.net 320 Om Epy|AFK :is a Secure Connection
44         virtual void OnWhois(userrec* source, userrec* dest)
45         {
46                 if(dest->GetExt("ssl", dummy))
47                 {
48                         ServerInstance->SendWhoisLine(source, dest, 320, "%s %s :is using a secure connection", source->nick, dest->nick);
49                 }
50         }
51         
52         virtual void OnSyncUserMetaData(userrec* user, Module* proto, void* opaque, const std::string &extname, bool displayable)
53         {
54                 // check if the linking module wants to know about OUR metadata
55                 if(extname == "ssl")
56                 {
57                         // check if this user has an ssl field to send
58                         if(user->GetExt(extname, dummy))
59                         {
60                                 // call this function in the linking module, let it format the data how it
61                                 // sees fit, and send it on its way. We dont need or want to know how.
62                                 proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, displayable ? "Enabled" : "ON");
63                         }
64                 }
65         }
66         
67         virtual void OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata)
68         {
69                 // check if its our metadata key, and its associated with a user
70                 if ((target_type == TYPE_USER) && (extname == "ssl"))
71                 {
72                         userrec* dest = (userrec*)target;
73                         // if they dont already have an ssl flag, accept the remote server's
74                         if (!dest->GetExt(extname, dummy))
75                         {
76                                 dest->Extend(extname, "ON");
77                         }
78                 }
79         }
80 };
81
82 MODULE_INIT(ModuleSSLDummy)