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

ModuleSecureList Class Reference

Inheritance diagram for ModuleSecureList:

Inheritance graph
[legend]
Collaboration diagram for ModuleSecureList:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ModuleSecureList (InspIRCd *Me)
virtual ~ModuleSecureList ()
virtual Version GetVersion ()
 Returns the version number of a Module.
void OnRehash (userrec *user, const std::string &parameter)
 Called on rehash.
void Implements (char *List)
 The Implements function specifies which methods a module should receive events for.
virtual int OnPreCommand (const std::string &command, const char **parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
 Called whenever any command is about to be executed.
virtual void On005Numeric (std::string &output)
 Called when a 005 numeric is about to be output.
virtual Priority Prioritize ()
 Used to set the 'priority' of a module (e.g.

Private Attributes

std::vector< std::stringallowlist
time_t WaitTime

Detailed Description

Definition at line 21 of file m_securelist.cpp.


Constructor & Destructor Documentation

ModuleSecureList::ModuleSecureList InspIRCd Me  )  [inline]
 

Definition at line 27 of file m_securelist.cpp.

References OnRehash().

00027                                        : Module(Me)
00028         {
00029                 OnRehash(NULL,"");
00030         }

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

Definition at line 32 of file m_securelist.cpp.

00033         {
00034         }


Member Function Documentation

virtual Version ModuleSecureList::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 36 of file m_securelist.cpp.

References API_VERSION, and VF_VENDOR.

00037         {
00038                 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
00039         }

void ModuleSecureList::Implements char *  List  )  [inline, virtual]
 

The Implements function specifies which methods a module should receive events for.

The char* parameter passed to this function contains a set of true or false values (1 or 0) which indicate wether each function is implemented. You must use the Iimplementation enum (documented elsewhere on this page) to mark functions as active. For example, to receive events for OnUserJoin():

Implements[I_OnUserJoin] = 1;

Parameters:
The implement list

Reimplemented from Module.

Definition at line 51 of file m_securelist.cpp.

References I_On005Numeric, I_OnPreCommand, and I_OnRehash.

00052         {
00053                 List[I_OnRehash] = List[I_OnPreCommand] = List[I_On005Numeric] = 1;
00054         }

virtual void ModuleSecureList::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 85 of file m_securelist.cpp.

00086         {
00087                 output.append(" SECURELIST");
00088         }

virtual int ModuleSecureList::OnPreCommand const std::string command,
const char **  parameters,
int  pcnt,
userrec user,
bool  validated,
const std::string original_line
[inline, virtual]
 

Called whenever any command is about to be executed.

This event occurs for all registered commands, wether they are registered in the core, or another module, and for invalid commands. Invalid commands may only be sent to this function when the value of validated is false. By returning 1 from this method you may prevent the command being executed. If you do this, no output is created by the core, and it is down to your module to produce any output neccessary. Note that unless you return 1, you should not destroy any structures (e.g. by using InspIRCd::QuitUser) otherwise when the command's handler function executes after your method returns, it will be passed an invalid pointer to the user object and crash!)

Parameters:
command The command being executed
parameters An array of array of characters containing the parameters for the command
pcnt The nuimber of parameters passed to the command
user the user issuing the command
validated True if the command has passed all checks, e.g. it is recognised, has enough parameters, the user has permission to execute it, etc.
original_line The entire original line as passed to the parser from the user
Returns:
1 to block the command, 0 to allow

Reimplemented from Module.

Definition at line 60 of file m_securelist.cpp.

References allowlist, IS_OPER, userrec::MakeHost(), InspIRCd::MatchText(), userrec::nick, Module::ServerInstance, connection::signon, InspIRCd::Time(), WaitTime, and userrec::WriteServ().

00061         {
00062                 /* If the command doesnt appear to be valid, we dont want to mess with it. */
00063                 if (!validated)
00064                         return 0;
00065  
00066                 if ((command == "LIST") && (ServerInstance->Time() < (user->signon+WaitTime)) && (!IS_OPER(user)))
00067                 {
00068                         /* Normally wouldnt be allowed here, are they exempt? */
00069                         for (std::vector<std::string>::iterator x = allowlist.begin(); x != allowlist.end(); x++)
00070                                 if (ServerInstance->MatchText(user->MakeHost(), *x))
00071                                         return 0;
00072 
00073                         /* Not exempt, BOOK EM DANNO! */
00074                         user->WriteServ("NOTICE %s :*** You cannot list within the first %d seconds of connecting. Please try again later.",user->nick, WaitTime);
00075                         /* Some crap clients (read: mIRC, various java chat applets) muck up if they don't
00076                          * receive these numerics whenever they send LIST, so give them an empty LIST to mull over.
00077                          */
00078                         user->WriteServ("321 %s Channel :Users Name",user->nick);
00079                         user->WriteServ("323 %s :End of channel list.",user->nick);
00080                         return 1;
00081                 }
00082                 return 0;
00083         }

void ModuleSecureList::OnRehash userrec user,
const std::string parameter
[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 41 of file m_securelist.cpp.

References allowlist, DELETE(), ConfigReader::ReadInteger(), ConfigReader::ReadValue(), Module::ServerInstance, and WaitTime.

Referenced by ModuleSecureList().

00042         {
00043                 ConfigReader* MyConf = new ConfigReader(ServerInstance);
00044                 allowlist.clear();
00045                 for (int i = 0; i < MyConf->Enumerate("securehost"); i++)
00046                         allowlist.push_back(MyConf->ReadValue("securehost", "exception", i));
00047                 W