1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 #ifndef __TRANSPORT_H__
15 #define __TRANSPORT_H__
20 /** A generic container for certificate data
22 typedef std::map<std::string,std::string> ssl_data;
24 /** A shorthand way of representing an iterator into ssl_data
26 typedef ssl_data::iterator ssl_data_iter;
28 /** ssl_cert is a class which abstracts SSL certificate
29 * and key information.
31 * Because gnutls and openssl represent key information in
32 * wildly different ways, this class allows it to be accessed
33 * in a unified manner. These classes are attached to ssl-
34 * connected local users using Extensible::Extend() and the
39 /** Always contains an empty string
41 const std::string empty;
44 /** The data for this certificate
48 /** Default constructor, initializes 'empty'
50 ssl_cert() : empty("")
54 /** Get certificate distinguished name
55 * @return Certificate DN
57 const std::string& GetDN()
59 ssl_data_iter ssldi = data.find("dn");
61 if (ssldi != data.end())
67 /** Get Certificate issuer
68 * @return Certificate issuer
70 const std::string& GetIssuer()
72 ssl_data_iter ssldi = data.find("issuer");
74 if (ssldi != data.end())
80 /** Get error string if an error has occured
81 * @return The error associated with this users certificate,
82 * or an empty string if there is no error.
84 const std::string& GetError()
86 ssl_data_iter ssldi = data.find("error");
88 if (ssldi != data.end())
94 /** Get key fingerprint.
95 * @return The key fingerprint as a hex string.
97 const std::string& GetFingerprint()
99 ssl_data_iter ssldi = data.find("fingerprint");
101 if (ssldi != data.end())
102 return ssldi->second;
108 * @return True if this is a trusted certificate
109 * (the certificate chain validates)
113 ssl_data_iter ssldi = data.find("trusted");
115 if (ssldi != data.end())
116 return (ssldi->second == "1");
121 /** Get validity status
122 * @return True if the certificate itself is
127 ssl_data_iter ssldi = data.find("invalid");
129 if (ssldi != data.end())
130 return (ssldi->second == "1");
135 /** Get signer status
136 * @return True if the certificate appears to be
139 bool IsUnknownSigner()
141 ssl_data_iter ssldi = data.find("unknownsigner");
143 if (ssldi != data.end())
144 return (ssldi->second == "1");
149 /** Get revokation status.
150 * @return True if the certificate is revoked.
151 * Note that this only works properly for GnuTLS
156 ssl_data_iter ssldi = data.find("revoked");
158 if (ssldi != data.end())
159 return (ssldi->second == "1");
165 /** Used to represent a request to a transport provider module
167 class ISHRequest : public Request
170 BufferedSocket* Sock;
172 ISHRequest(Module* Me, Module* Target, const char* rtype, BufferedSocket* sock) : Request(Me, Target, rtype), Sock(sock)
177 /** Used to represent a request to attach a cert to an BufferedSocket
179 class BufferedSocketAttachCertRequest : public ISHRequest
182 /** Initialize the request as an attach cert message */
183 BufferedSocketAttachCertRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_ATTACH", is)
188 /** Used to check if a handshake is complete on an BufferedSocket yet
190 class BufferedSocketHSCompleteRequest : public ISHRequest
193 /** Initialize the request as a 'handshake complete?' message */
194 BufferedSocketHSCompleteRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_HSDONE", is)
199 /** Used to hook a transport provider to an BufferedSocket
201 class BufferedSocketHookRequest : public ISHRequest
204 /** Initialize request as a hook message */
205 BufferedSocketHookRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_HOOK", is)
210 /** Used to unhook a transport provider from an BufferedSocket
212 class BufferedSocketUnhookRequest : public ISHRequest
215 /** Initialize request as an unhook message */
216 BufferedSocketUnhookRequest(BufferedSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_UNHOOK", is)
221 class BufferedSocketNameRequest : public ISHRequest
224 /** Initialize request as a get name message */
225 BufferedSocketNameRequest(Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_NAME", NULL)