The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

ModuleSSLOpenSSL Class Reference

Inheritance diagram for ModuleSSLOpenSSL:

Inheritance graph
[legend]
Collaboration diagram for ModuleSSLOpenSSL:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ModuleSSLOpenSSL (InspIRCd *Me)
virtual void OnHookUserIO (User *user, const std::string &targetip)
virtual void OnRehash (User *user, const std::string &param)
 Called on rehash.
virtual void On005Numeric (std::string &output)
 Called when a 005 numeric is about to be output.
virtual ~ModuleSSLOpenSSL ()
virtual void OnCleanup (int target_type, void *item)
 Called before your module is unloaded to clean up Extensibles.
virtual void OnUnloadModule (Module *mod, const std::string &name)
 Called whenever a module is unloaded.
virtual Version GetVersion ()
 Returns the version number of a Module.
virtual const char * OnRequest (Request *request)
 Called whenever a Request class is sent to your module by another module.
virtual void OnRawSocketAccept (int fd, const std::string &ip, int localport)
 Called immediately after any connection is accepted.
virtual void OnRawSocketConnect (int fd)
 Called immediately upon connection of an outbound BufferedSocket which has been hooked by a module.
virtual void OnRawSocketClose (int fd)
 Called immediately before any socket is closed.
virtual int OnRawSocketRead (int fd, char *buffer, unsigned int count, int &readresult)
 Called immediately before any read() operation on a client socket in the core.
virtual int OnRawSocketWrite (int fd, const char *buffer, int count)
 Called immediately before any write() operation on a user's socket in the core.
int DoWrite (issl_session *session)
int DoRead (issl_session *session)
virtual void OnWhois (User *source, User *dest)
 Called whenever a /WHOIS is performed on a local user.
virtual void OnSyncUserMetaData (User *user, Module *proto, void *opaque, const std::string &extname, bool displayable)
virtual void OnDecodeMetaData (int target_type, void *target, const std::string &extname, const std::string &extdata)
 Allows module data, sent via ProtoSendMetaData, to be decoded again by a receiving module.
bool Handshake (issl_session *session)
virtual void OnPostConnect (User *user)
 Called after a user has fully connected and all modules have executed OnUserConnect This event is informational only.
void MakePollWrite (issl_session *session)
virtual void OnBufferFlushed (User *user)
 Called whenever a user's write buffer has been completely sent.
void CloseSession (issl_session *session)
void VerifyCertificate (issl_session *session, Extensible *user)
void Prioritize ()

Public Attributes

InspIRCdPublicInstance

Private Attributes

std::vector< std::stringlistenports
int inbufsize
issl_sessionsessions
SSL_CTX * ctx
SSL_CTX * clictx
char * dummy
char cipher [MAXBUF]
std::string keyfile
std::string certfile
std::string cafile
std::string dhfile
std::string sslports
int clientactive

Detailed Description

Definition at line 99 of file m_ssl_openssl.cpp.


Constructor & Destructor Documentation

ModuleSSLOpenSSL::ModuleSSLOpenSSL InspIRCd Me  )  [inline]
 

Definition at line 125 of file m_ssl_openssl.cpp.

References ModuleManager::Attach(), clictx, InspIRCd::Config, ctx, SocketEngine::GetMaxFds(), I_On005Numeric, I_OnBufferFlushed, I_OnCleanup, I_OnDecodeMetaData, I_OnHookUserIO, I_OnPostConnect, I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketConnect, I_OnRawSocketRead, I_OnRawSocketWrite, I_OnRehash, I_OnRequest, I_OnSyncUserMetaData, I_OnUnloadModule, I_OnWhois, inbufsize, InspIRCd::Modules, ServerConfig::NetBufferSize, OnRehash(), OnVerify(), ModuleManager::PublishInterface(), InspIRCd::SE, Module::ServerInstance, and sessions.

virtual ModuleSSLOpenSSL::~ModuleSSLOpenSSL  )  [inline, virtual]
 

Definition at line 300 of file m_ssl_openssl.cpp.

References clictx, ctx, InspIRCd::Modules, Module::ServerInstance, sessions, and ModuleManager::UnpublishInterface().


Member Function Documentation

void ModuleSSLOpenSSL::CloseSession issl_session session  )  [inline]
 

Definition at line 809 of file m_ssl_openssl.cpp.

References issl_session::inbuf, ISSL_NONE, issl_session::outbuf, issl_session::sess, and issl_session::status.

Referenced by DoRead(), DoWrite(), Handshake(), OnRawSocketClose(), OnRawSocketRead(), and OnRawSocketWrite().

int ModuleSSLOpenSSL::DoRead issl_session session  )  [inline]
 

Definition at line 627 of file m_ssl_openssl.cpp.

References CloseSession(), issl_session::inbuf, issl_session::inbufoffset, inbufsize, ISSL_READ, ISSL_WRITE, MakePollWrite(), issl_session::rstat, and issl_session::sess.

Referenced by OnRawSocketRead(), and OnRawSocketWrite().

int ModuleSSLOpenSSL::DoWrite issl_session session  )  [inline]
 

Definition at line 588 of file m_ssl_openssl.cpp.

References CloseSession(), ISSL_READ, ISSL_WRITE, issl_session::outbuf, issl_session::sess, and issl_session::wstat.

Referenced by OnRawSocketRead(), and OnRawSocketWrite().

virtual Version ModuleSSLOpenSSL::GetVersion  )  [inline, virtual]
 

Returns the version number of a Module.

The method should return a Version object with its version information assigned via Version::Version

Reimplemented from Module.

Definition at line 344 of file m_ssl_openssl.cpp.

References API_VERSION, and VF_VENDOR.

bool ModuleSSLOpenSSL::Handshake issl_session session  )  [inline]
 

Definition at line 715 of file m_ssl_openssl.cpp.

References CloseSession(), dummy, Extensible::Extend(), issl_session::fd, InspIRCd::FindDescriptor, Extensible::GetExt(), ISSL_HANDSHAKING, ISSL_OPEN, ISSL_READ, ISSL_WRITE, MakePollWrite(), issl_session::outbound, issl_session::rstat, Module::ServerInstance, issl_session::sess, issl_session::status, and issl_session::wstat.

Referenced by OnRawSocketAccept(), OnRawSocketConnect(), OnRawSocketRead(), and OnRawSocketWrite().

void ModuleSSLOpenSSL::MakePollWrite issl_session session  )  [inline]
 

Definition at line 789 of file m_ssl_openssl.cpp.

References issl_session::fd, InspIRCd::FindDescriptor, InspIRCd::SE, Module::ServerInstance, and SocketEngine::WantWrite().

Referenced by DoRead(), Handshake(), and OnRawSocketWrite().

virtual void ModuleSSLOpenSSL::On005Numeric std::string output  )  [inline, virtual]
 

Called when a 005 numeric is about to be output.

The module should modify the 005 numeric if needed to indicate its features.

Parameters:
output The 005 string to be modified if neccessary.

Reimplemented from Module.

Definition at line 295 of file m_ssl_openssl.cpp.

References sslports.

virtual void ModuleSSLOpenSSL::OnBufferFlushed User user  )  [inline, virtual]
 

Called whenever a user's write buffer has been completely sent.

This is called when the user's write buffer is completely empty, and there are no more pending bytes to be written and no pending write events in the socket engine's queue. This may be used to refill the buffer with data which is being spooled in a controlled manner, e.g. LIST lines.

Parameters:
user The user who's buffer is now empty.

Reimplemented from Module.

Definition at line 799 of file m_ssl_openssl.cpp.

References Extensible::GetExt(), EventHandler::GetFd(), OnRawSocketWrite(), issl_session::outbuf, and sessions.

virtual void ModuleSSLOpenSSL::OnCleanup int  target_type,
void *  item
[inline, virtual]
 

Called before your module is unloaded to clean up Extensibles.

This method is called once for every user and channel on the network, so that when your module unloads it may clear up any remaining data in the form of Extensibles added using Extensible::Extend(). If the target_type variable is TYPE_USER, then void* item refers to a User*, otherwise it refers to a Channel*.

Parameters:
target_type The type of item being cleaned
item A pointer to the item's class

Reimplemented from Module.

Definition at line 308 of file m_ssl_openssl.cpp.

References EventHandler::DelIOHook(), dummy, Extensible::GetExt(), EventHandler::GetIOHook(), UserManager::QuitUser(), Module::ServerInstance, Extensible::Shrink(), TYPE_USER, and InspIRCd::Users.

virtual void ModuleSSLOpenSSL::OnDecodeMetaData int  target_type,
void *  target,
const std::string extname,
const std::string extdata
[inline, virtual]
 

Allows module data, sent via ProtoSendMetaData, to be decoded again by a receiving module.

Please see src/modules/m_swhois.cpp for a working example of how to use this method call.

Parameters:
target_type The type of item to decode data for, TYPE_USER or TYPE_CHANNEL
target The Channel* or User* that data should be added to
extname The extension name which is being sent
extdata The extension data, encoded at the other end by an identical module through OnSyncChannelMetaData or OnSyncUserMetaData

Reimplemented from Module.

Definition at line 701 of file m_ssl_openssl.cpp.

References dummy, Extensible::Extend(), Extensible::GetExt(), and TYPE_USER.

virtual void ModuleSSLOpenSSL::OnHookUserIO User user,
const std::string targetip
[inline, virtual]
 

Reimplemented from Module.

Definition at line 158 of file m_ssl_openssl.cpp.

References EventHandler::AddIOHook(), EventHandler::GetIOHook(), User::GetPort(), isin(), and listenports.

virtual void ModuleSSLOpenSSL::OnPostConnect User user  )  [inline, virtual]
 

Called after a user has fully connected and all modules have executed OnUserConnect This event is informational only.

You should not change any user information in this event. To do so, use the OnUserConnect method to change the state of local users. This is called for both local and remote users.

Parameters:
user The user who is connecting

Reimplemented from Module.

Definition at line 774 of file m_ssl_openssl.cpp.

References dummy, Extensible::GetExt(), IS_LOCAL, InspIRCd::PI, ProtocolInterface::SendMetaData(), Module::ServerInstance, sessions, TYPE_USER, and VerifyCertificate().

virtual void ModuleSSLOpenSSL::OnRawSocketAccept int  fd,
const std::string ip,
int  localport
[inline, virtual]
 

Called immediately after any connection is accepted.

This is intended for raw socket processing (e.g. modules which wrap the tcp connection within another library) and provides no information relating to a user record as the connection has not been assigned yet. There are no return values from this call as all modules get an opportunity if required to process the connection.

Parameters:
fd The file descriptor returned from accept()
ip The IP address of the connecting user
localport The local port number the user connected to

Reimplemented from Module.

Definition at line 396 of file m_ssl_openssl.cpp.

References ctx, DEBUG, issl_session::fd, SocketEngine::GetMaxFds(), Handshake(), issl_session::inbuf, issl_session::inbufoffset, inbufsize, ISSL_NONE, LogManager::Log(), InspIRCd::Logs, issl_session::outbound, InspIRCd::SE, Module::ServerInstance, issl_session::sess, sessions, and issl_session::status.

virtual void ModuleSSLOpenSSL::OnRawSocketClose int  fd  )  [inline, virtual]
 

Called immediately before any socket is closed.

When this event is called, shutdown() has not yet been called on the socket.

Parameters:
fd The file descriptor of the socket prior to close()

Reimplemented from Module.

Definition at line 450 of file m_ssl_openssl.cpp.

References CloseSession(), dummy, Extensible::GetExt(), SocketEngine::GetMaxFds(), SocketEngine::GetRef(), InspIRCd::SE, Module::ServerInstance, sessions, and Extensible::Shrink().

virtual void ModuleSSLOpenSSL::OnRawSocketConnect int  fd  )  [inline, virtual]
 

Called immediately upon connection of an outbound BufferedSocket which has been hooked by a module.

Parameters:
fd The file descriptor of the socket immediately after connect()

Reimplemented from Module.

Definition at line 423 of file m_ssl_openssl.cpp.

References clictx, DEBUG, issl_session::fd, SocketEngine::GetMaxFds(), Handshake(), issl_session::inbuf, issl_session::inbufoffset, inbufsize, ISSL_NONE, LogManager::Log(), InspIRCd::Logs, issl_session::outbound, InspIRCd::SE, Module::ServerInstance, issl_session::sess, sessions, and issl_session::status.

virtual int ModuleSSLOpenSSL::OnRawSocketRead int  fd,
char *  buffer,
unsigned int  count,
int &  readresult
[inline, virtual]
 

Called immediately before any read() operation on a client socket in the core.

This occurs AFTER the select() or poll() so there is always data waiting to be read when this event occurs. Your event should return 1 if it has handled the reading itself, which prevents the core just using read(). You should place any data read into buffer, up to but NOT GREATER THAN the value of count. The value of readresult must be identical to an actual result that might be returned from the read() system call, for example, number of bytes read upon success, 0 upon EOF or closed socket, and -1 for error. If your function returns a nonzero value, you MUST set readresult.

Parameters:
fd The file descriptor of the socket
buffer A char* buffer being read to
count The size of the buffer
readresult The amount of characters read, or 0
Returns:
nonzero if the event was handled, in which case readresult must be valid on exit

Reimplemented from Module.

Definition at line 469 of file m_ssl_openssl.cpp.

References CloseSession(), DoRead(), DoWrite(), SocketEngine::GetMaxFds(), Handshake(), issl_session::inbuf, issl_session::inbufoffset, ISSL_HANDSHAKING, ISSL_OPEN, ISSL_READ, issl_session::rstat, InspIRCd::SE, Module::ServerInstance, issl_session::sess, sessions, issl_session::status, and issl_session::wstat.

virtual int ModuleSSLOpenSSL::OnRawSocketWrite int  fd,
const char *  buffer,
int  count
[inline, virtual]
 

Called immediately before any write() operation on a user's socket in the core.

Because this event is a low level event no user information is associated with it. It is intended for use by modules which may wrap connections within another API such as SSL for example. return a non-zero result if you have handled the write operation, in which case the core will not call write().

Parameters:
fd The file descriptor of the socket
buffer A char* buffer being written
Number of characters to write
Returns:
Number of characters actually written or 0 if you didn't handle the operation

Reimplemented from Module.

Definition at line 546 of file m_ssl_openssl.cpp.

References CloseSession(), DoRead(), DoWrite(), SocketEngine::GetMaxFds(), Handshake(), ISSL_HANDSHAKING, ISSL_OPEN, ISSL_WRITE, MakePollWrite(), issl_session::outbuf, issl_session::rstat, InspIRCd::SE, Module::ServerInstance, issl_session::sess, sessions, issl_session::status, and issl_session::wstat.

Referenced by OnBufferFlushed().

virtual void ModuleSSLOpenSSL::OnRehash User user,
const std::string param
[inline, virtual]
 

Called on rehash.

This method is called prior to a /REHASH or when a SIGHUP is received from the operating system. You should use it to reload any files so that your module keeps in step with the rest of the application. If a parameter is given, the core has done nothing. The module receiving the event can decide if this parameter has any relevence to it.

Parameters:
user The user performing the rehash, if any -- if this is server initiated, the value of this variable will be NULL.
parameter The (optional) parameter given to REHASH from the user.

Reimplemented from Module.

Definition at line 167 of file m_ssl_openssl.cpp.

References cafile, certfile, clictx, clientactive, Conf, InspIRCd::Config, InspIRCd::ConfigFileName, ConvToStr(), ctx, DEFAULT, dhfile, ConfigReader::Enumerate(), error_callback(), CoreException::GetReason(), irc::portparser::GetToken(), keyfile, listenports, LogManager::Log(), InspIRCd::Logs, ServerConfig::ports, ConfigReader::ReadValue(), Module::ServerInstance, sslports, and ServerConfig::StartsWithWindowsDriveLetter().

Referenced by ModuleSSLOpenSSL().

virtual const char* ModuleSSLOpenSSL::OnRequest Request request  )  [inline, virtual]
 

Called whenever a Request class is sent to your module by another module.

Please see the documentation of Request::Send() for further information. The Request sent can always be assumed to be non-NULL, you should not change the request object or its data. Your method may return arbitary data in the char* result which the requesting module may be able to use for pre-determined purposes (e.g. the results of an SQL query, etc).

Parameters:
request The Request class being received

Reimplemented from Module.

Definition at line 350 of file m_ssl_openssl.cpp.

References EventHandler::AddIOHook(), EventHandler::DelIOHook(), EventHandler::GetFd(), Request::GetId(), ISSL_HANDSHAKING, issl_session::sess, sessions, ISHRequest::Sock, issl_session::status, and VerifyCertificate().

virtual void ModuleSSLOpenSSL::OnSyncUserMetaData User user,
Module proto,
void *  opaque,
const std::string extname,
bool  displayable
[inline, virtual]
 

Reimplemented from Module.

Definition at line 686 of file m_ssl_openssl.cpp.

References dummy, Extensible::GetExt(), Module::ProtoSendMetaData(), and TYPE_USER.

virtual void ModuleSSLOpenSSL::OnUnloadModule Module mod,
const std::string name
[inline, virtual]
 

Called whenever a module is unloaded.

mod will contain a pointer to the module, and string will contain its name, for example m_widgets.so. This function is primary for dependency checking, your module may decide to enable some extra features if it sees that you have for example loaded "m_killwidgets.so" with "m_makewidgets.so". It is highly recommended that modules do *NOT* bail if they cannot satisfy dependencies, but instead operate under reduced functionality, unless the dependency is absolutely neccessary (e.g. a module that extends the features of another module).

Parameters:
mod Pointer to the module being unloaded (still valid)
name The filename of the module being unloaded

Reimplemented from Module.

Definition at line 331 of file m_ssl_openssl.cpp.

References InspIRCd::Config, ConvToStr(), listenports, ServerConfig::ports, and Module::ServerInstance.

virtual void ModuleSSLOpenSSL::OnWhois User source,
User dest
[inline, virtual]
 

Called whenever a /WHOIS is performed on a local user.

The source parameter contains the details of the user who issued the WHOIS command, and the dest parameter contains the information of the user they are whoising.

Parameters:
source The user issuing the WHOIS command
dest The user who is being WHOISed

Reimplemented from Module.

Definition at line 674 of file m_ssl_openssl.cpp.

References clientactive, dummy, Extensible::GetExt(), IS_LOCAL, User::nick, InspIRCd::SendWhoisLine(), and Module::ServerInstance.

void ModuleSSLOpenSSL::Prioritize  )  [inline, virtual]
 

Reimplemented from Module.

Definition at line 882 of file m_ssl_openssl.cpp.

References ModuleManager::Find(), I_OnPostConnect, InspIRCd::Modules, PRIO_AFTER, Module::ServerInstance, and ModuleManager::SetPriority().

void ModuleSSLOpenSSL::VerifyCertificate issl_session session,
Extensible user
[inline]
 

Definition at line 828 of file m_ssl_openssl.cpp.

References ConvToStr(), ssl_cert::data, Extensible::Extend(), get_error(), irc::hex(), SelfSigned, Module::ServerInstance, issl_session::sess, and InspIRCd::Time().

Referenced by OnPostConnect(), and OnRequest().


Member Data Documentation

std::string ModuleSSLOpenSSL::cafile [private]
 

Definition at line 114 of file m_ssl_openssl.cpp.

Referenced by OnRehash().

std::string ModuleSSLOpenSSL::certfile [private]
 

Definition at line 113 of file m_ssl_openssl.cpp.

Referenced by OnRehash().

char ModuleSSLOpenSSL::cipher[MAXBUF] [private]
 

Definition at line 110 of file m_ssl_openssl.cpp.

SSL_CTX* ModuleSSLOpenSSL::clictx [private]
 

Definition at line 107 of file m_ssl_openssl.cpp.

Referenced by ModuleSSLOpenSSL(), OnRawSocketConnect(), OnRehash(), and ~ModuleSSLOpenSSL().

int ModuleSSLOpenSSL::clientactive [private]
 

Definition at line 119 of file m_ssl_openssl.cpp.

Referenced by OnRehash(), and OnWhois().

SSL_CTX* ModuleSSLOpenSSL::ctx [private]
 

Definition at line 106 of file m_ssl_openssl.cpp.

Referenced by ModuleSSLOpenSSL(), OnRawSocketAccept(), OnRehash(), and ~ModuleSSLOpenSSL().

std::string ModuleSSLOpenSSL::dhfile [private]
 

Definition at line 116 of file m_ssl_openssl.cpp.

Referenced by OnRehash().

char* ModuleSSLOpenSSL::dummy [private]
 

Definition at line 109 of file m_ssl_openssl.cpp.

Referenced by Handshake(), OnCleanup(), OnDecodeMetaData(), OnPostConnect(), OnRawSocketClose(), OnSyncUserMetaData(), and OnWhois().

int ModuleSSLOpenSSL::inbufsize [private]
 

Definition at line 103 of file m_ssl_openssl.cpp.

Referenced by DoRead(), ModuleSSLOpenSSL(), OnRawSocketAccept(), and OnRawSocketConnect().

std::string ModuleSSLOpenSSL::keyfile [private]
 

Definition at line 112 of file m_ssl_openssl.cpp.

Referenced by OnRehash().

std::vector<std::string> ModuleSSLOpenSSL::listenports [private]
 

Definition at line 101 of file m_ssl_openssl.cpp.

Referenced by OnHookUserIO(), OnRehash(), and OnUnloadModule().

InspIRCd* ModuleSSLOpenSSL::PublicInstance
 

Definition at line 123 of file m_ssl_openssl.cpp.

Referenced by error_callback().

issl_session* ModuleSSLOpenSSL::sessions [private]
 

Definition at line 104 of file m_ssl_openssl.cpp.

Referenced by ModuleSSLOpenSSL(), OnBufferFlushed(), OnPostConnect(), OnRawSocketAccept(), OnRawSocketClose(), OnRawSocketConnect(), OnRawSocketRead(), OnRawSocketWrite(), OnRequest(), and ~ModuleSSLOpenSSL().

std::string ModuleSSLOpenSSL::sslports [private]
 

Definition at line 117 of file m_ssl_openssl.cpp.

Referenced by On005Numeric(), and OnRehash().


The documentation for this class was generated from the following file: