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

ModuleSSLGnuTLS Class Reference

Inheritance diagram for ModuleSSLGnuTLS:

Inheritance graph
[legend]
Collaboration diagram for ModuleSSLGnuTLS:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ModuleSSLGnuTLS (InspIRCd *Me)
virtual void OnRehash (User *user, const std::string &param)
 Called on rehash.
void GenerateDHParams ()
virtual ~ModuleSSLGnuTLS ()
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 void On005Numeric (std::string &output)
 Called when a 005 numeric is about to be output.
virtual void OnHookUserIO (User *user, const std::string &targetip)
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.
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 OnEvent (Event *ev)
 Called whenever an Event class is sent to all module by another module.
void Prioritize ()

Private Attributes

ConfigReaderConf
char * dummy
std::vector< std::stringlistenports
int inbufsize
issl_sessionsessions
gnutls_certificate_credentials x509_cred
gnutls_dh_params dh_params
std::string keyfile
std::string certfile
std::string cafile
std::string crlfile
std::string sslports
int dh_bits
int clientactive
bool cred_alloc
CommandStartTLSstarttls

Detailed Description

Definition at line 94 of file m_ssl_gnutls.cpp.


Constructor & Destructor Documentation

ModuleSSLGnuTLS::ModuleSSLGnuTLS InspIRCd Me  )  [inline]
 

Definition at line 123 of file m_ssl_gnutls.cpp.

References InspIRCd::AddCommand(), ModuleManager::Attach(), InspIRCd::Config, cred_alloc, dh_params, SocketEngine::GetMaxFds(), I_On005Numeric, I_OnBufferFlushed, I_OnCleanup, I_OnDecodeMetaData, I_OnEvent, 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(), ModuleManager::PublishInterface(), InspIRCd::SE, Module::ServerInstance, sessions, starttls, and x509_cred.

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

Definition at line 287 of file m_ssl_gnutls.cpp.

References dh_params, InspIRCd::Modules, Module::ServerInstance, sessions, ModuleManager::UnpublishInterface(), and x509_cred.


Member Function Documentation

void ModuleSSLGnuTLS::CloseSession issl_session session  )  [inline]
 

Definition at line 770 of file m_ssl_gnutls.cpp.

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

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

void ModuleSSLGnuTLS::GenerateDHParams  )  [inline]
 

Definition at line 274 of file m_ssl_gnutls.cpp.

References DEFAULT, dh_bits, dh_params, LogManager::Log(), InspIRCd::Logs, and Module::ServerInstance.

Referenced by OnRehash().

virtual Version ModuleSSLGnuTLS::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 332 of file m_ssl_gnutls.cpp.

References API_VERSION, and VF_VENDOR.

bool ModuleSSLGnuTLS::Handshake issl_session session  )  [inline]
 

Definition at line 680 of file m_ssl_gnutls.cpp.

References CloseSession(), dummy, Extensible::Extend(), issl_session::fd, InspIRCd::FindDescriptor, Extensible::GetExt(), ISSL_CLOSING, ISSL_HANDSHAKEN, ISSL_HANDSHAKING_READ, ISSL_HANDSHAKING_WRITE, MakePollWrite(), Module::ServerInstance, issl_session::sess, and issl_session::status.

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

void ModuleSSLGnuTLS::MakePollWrite issl_session session  )  [inline]
 

Definition at line 752 of file m_ssl_gnutls.cpp.

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

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

virtual void ModuleSSLGnuTLS::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 338 of file m_ssl_gnutls.cpp.

References sslports.

virtual void ModuleSSLGnuTLS::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 760 of file m_ssl_gnutls.cpp.

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

virtual void ModuleSSLGnuTLS::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 296 of file m_ssl_gnutls.cpp.

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

virtual void ModuleSSLGnuTLS::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 666 of file m_ssl_gnutls.cpp.

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

void ModuleSSLGnuTLS::OnEvent Event ev  )  [inline, virtual]
 

Called whenever an Event class is sent to all module by another module.

Please see the documentation of Event::Send() for further information. The Event sent can always be assumed to be non-NULL, you should *always* check the value of Event::GetEventID() before doing anything to the event data, and you should *not* change the event data in any way!

Parameters:
event The Event class being received

Reimplemented from Module.

Definition at line 916 of file m_ssl_gnutls.cpp.

References GenericCapHandler().

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

Reimplemented from Module.

Definition at line 343 of file m_ssl_gnutls.cpp.

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

virtual void ModuleSSLGnuTLS::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 732 of file m_ssl_gnutls.cpp.

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

virtual void ModuleSSLGnuTLS::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 403 of file m_ssl_gnutls.cpp.

References dh_bits, issl_session::fd, SocketEngine::GetMaxFds(), Handshake(), issl_session::inbuf, issl_session::inbufoffset, inbufsize, InspIRCd::SE, Module::ServerInstance, issl_session::sess, sessions, and x509_cred.

virtual void ModuleSSLGnuTLS::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 462 of file m_ssl_gnutls.cpp.

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

virtual void ModuleSSLGnuTLS::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 440 of file m_ssl_gnutls.cpp.

References dh_bits, issl_session::fd, SocketEngine::GetMaxFds(), Handshake(), issl_session::inbuf, issl_session::inbufoffset, inbufsize, InspIRCd::SE, Module::ServerInstance, issl_session::sess, sessions, and x509_cred.

virtual int ModuleSSLGnuTLS::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 481 of file m_ssl_gnutls.cpp.

References CloseSession(), SocketEngine::GetMaxFds(), Handshake(), issl_session::inbuf, issl_session::inbufoffset, inbufsize, ISSL_CLOSING, ISSL_HANDSHAKEN, ISSL_HANDSHAKING_READ, ISSL_HANDSHAKING_WRITE, MakePollWrite(), InspIRCd::SE, Module::ServerInstance, issl_session::sess, sessions, and issl_session::status.

virtual int ModuleSSLGnuTLS::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 576 of file m_ssl_gnutls.cpp.

References CloseSession(), SocketEngine::GetMaxFds(), Handshake(), ISSL_HANDSHAKEN, ISSL_HANDSHAKING_WRITE, MakePollWrite(), issl_session::outbuf, InspIRCd::SE, Module::ServerInstance, issl_session::sess, sessions, and issl_session::status.

Referenced by OnBufferFlushed().

virtual void ModuleSSLGnuTLS::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 149 of file m_ssl_gnutls.cpp.

References cafile, certfile, clientactive, Conf, InspIRCd::Config, InspIRCd::ConfigFileName, ConvToStr(), cred_alloc, crlfile, DEFAULT, dh_bits, dh_params, ConfigReader::Enumerate(), GenerateDHParams(), CoreException::GetReason(), irc::portparser::GetToken(), keyfile, listenports, LogManager::Log(), InspIRCd::Logs, ServerConfig::ports, ConfigReader::ReadInteger(), ConfigReader::ReadValue(), Module::ServerInstance, sslports, ServerConfig::StartsWithWindowsDriveLetter(), and x509_cred.

Referenced by ModuleSSLGnuTLS().

virtual const char* ModuleSSLGnuTLS::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 352 of file m_ssl_gnutls.cpp.

References EventHandler::AddIOHook(), EventHandler::DelIOHook(), InspIRCd::FindDescriptor, EventHandler::GetFd(), Request::GetId(), ISSL_HANDSHAKING_READ, ISSL_HANDSHAKING_WRITE, Module::ServerInstance, issl_session::sess, sessions, ISHRequest::Sock, issl_session::status, and VerifyCertificate().

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

Reimplemented from Module.

Definition at line 651 of file m_ssl_gnutls.cpp.

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

virtual void ModuleSSLGnuTLS::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 319 of file m_ssl_gnutls.cpp.

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

virtual void ModuleSSLGnuTLS::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 639 of file m_ssl_gnutls.cpp.

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

void ModuleSSLGnuTLS::Prioritize  )  [inline, virtual]
 

Reimplemented from Module.

Definition at line 921 of file m_ssl_gnutls.cpp.

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

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

Definition at line 789 of file m_ssl_gnutls.cpp.

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

Referenced by OnPostConnect(), and OnRequest().


Member Data Documentation

std::string ModuleSSLGnuTLS::cafile [private]
 

Definition at line 111 of file m_ssl_gnutls.cpp.

Referenced by OnRehash().

std::string ModuleSSLGnuTLS::certfile [private]
 

Definition at line 110 of file m_ssl_gnutls.cpp.

Referenced by OnRehash().

int ModuleSSLGnuTLS::clientactive [private]
 

Definition at line 116 of file m_ssl_gnutls.cpp.

Referenced by OnRehash(), and OnWhois().

ConfigReader* ModuleSSLGnuTLS::Conf [private]
 

Definition at line 97 of file m_ssl_gnutls.cpp.

Referenced by OnRehash().

bool ModuleSSLGnuTLS::cred_alloc [private]
 

Definition at line 117 of file m_ssl_gnutls.cpp.

Referenced by ModuleSSLGnuTLS(), and OnRehash().

std::string ModuleSSLGnuTLS::crlfile [private]
 

Definition at line 112 of file m_ssl_gnutls.cpp.

Referenced by OnRehash().

int ModuleSSLGnuTLS::dh_bits [private]
 

Definition at line 114 of file m_ssl_gnutls.cpp.

Referenced by GenerateDHParams(), OnRawSocketAccept(), OnRawSocketConnect(), and OnRehash().

gnutls_dh_params ModuleSSLGnuTLS::dh_params [private]
 

Definition at line 107 of file m_ssl_gnutls.cpp.

Referenced by GenerateDHParams(), ModuleSSLGnuTLS(), OnRehash(), and ~ModuleSSLGnuTLS().

char* ModuleSSLGnuTLS::dummy [private]
 

Definition at line 99 of file m_ssl_gnutls.cpp.

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

int ModuleSSLGnuTLS::inbufsize [private]
 

Definition at line 103 of file m_ssl_gnutls.cpp.

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

std::string ModuleSSLGnuTLS::keyfile [private]
 

Definition at line 109 of file m_ssl_gnutls.cpp.

Referenced by OnRehash().

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

Definition at line 101 of file m_ssl_gnutls.cpp.

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

issl_session* ModuleSSLGnuTLS::sessions [private]
 

Definition at line 104 of file m_ssl_gnutls.cpp.

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

std::string ModuleSSLGnuTLS::sslports [private]
 

Definition at line 113 of file m_ssl_gnutls.cpp.

Referenced by On005Numeric(), and OnRehash().

CommandStartTLS* ModuleSSLGnuTLS::starttls [private]
 

Definition at line 119 of file m_ssl_gnutls.cpp.

Referenced by ModuleSSLGnuTLS().

gnutls_certificate_credentials ModuleSSLGnuTLS::x509_cred [private]
 

Definition at line 106 of file m_ssl_gnutls.cpp.

Referenced by ModuleSSLGnuTLS(), OnRawSocketAccept(), OnRawSocketConnect(), OnRehash(), and ~ModuleSSLGnuTLS().


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