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

FilterBase Class Reference

#include <m_filter.h>

Inheritance diagram for FilterBase:

Inheritance graph
[legend]
Collaboration diagram for FilterBase:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FilterBase (InspIRCd *Me, const std::string &source)
virtual ~FilterBase ()
virtual int OnUserPreMessage (User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
 Called whenever a user is about to PRIVMSG A user or a channel, before any processing is done.
virtual FilterResultFilterMatch (User *user, const std::string &text, int flags)=0
virtual bool DeleteFilter (const std::string &freeform)=0
virtual void SyncFilters (Module *proto, void *opaque)=0
virtual void SendFilter (Module *proto, void *opaque, FilterResult *iter)
virtual std::pair< bool, std::stringAddFilter (const std::string &freeform, const std::string &type, const std::string &reason, long duration, const std::string &flags)=0
virtual int OnUserPreNotice (User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
 Called whenever a user is about to NOTICE A user or a channel, before any processing is done.
virtual void OnRehash (User *user, const std::string &parameter)
 Called on rehash.
virtual Version GetVersion ()
 Returns the version number of a Module.
std::string EncodeFilter (FilterResult *filter)
FilterResult DecodeFilter (const std::string &data)
virtual void OnSyncOtherMetaData (Module *proto, void *opaque, bool displayable=false)
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.
virtual int OnStats (char symbol, User *user, string_list &results)=0
 Called on all /STATS commands This method is triggered for all /STATS use, including stats symbols handled by the core.
virtual int OnPreCommand (std::string &command, std::vector< std::string > &parameters, User *user, bool validated, const std::string &original_line)
 Called whenever any command is about to be executed.
bool AppliesToMe (User *user, FilterResult *filter, int flags)

Protected Attributes

std::vector< std::stringexemptfromfilter

Private Attributes

CommandFilterfiltcommand
int flags

Detailed Description

Definition at line 93 of file m_filter.h.


Constructor & Destructor Documentation

FilterBase::FilterBase InspIRCd Me,
const std::string source
 

Definition at line 225 of file m_filter.h.

References InspIRCd::AddCommand(), ModuleManager::Attach(), filtcommand, I_OnDecodeMetaData, I_OnPreCommand, I_OnRehash, I_OnStats, I_OnSyncOtherMetaData, I_OnUserPreMessage, I_OnUserPreNotice, InspIRCd::Modules, and Module::ServerInstance.

FilterBase::~FilterBase  )  [virtual]
 

Definition at line 233 of file m_filter.h.


Member Function Documentation

virtual std::pair<bool, std::string> FilterBase::AddFilter const std::string freeform,
const std::string type,
const std::string reason,
long  duration,
const std::string flags
[pure virtual]
 

Implemented in ModuleFilter, and ModuleFilterPCRE.

Referenced by CommandFilter::Handle(), and OnDecodeMetaData().

bool FilterBase::AppliesToMe User user,
FilterResult filter,
int  flags
 

Definition at line 210 of file m_filter.h.

References FilterResult::flag_no_opers, FilterResult::flag_notice, FLAG_NOTICE, FLAG_PART, FilterResult::flag_part_message, FilterResult::flag_privmsg, FLAG_PRIVMSG, FLAG_QUIT, FilterResult::flag_quit_message, and IS_OPER.

Referenced by ModuleFilterPCRE::FilterMatch(), and ModuleFilter::FilterMatch().

FilterResult FilterBase::DecodeFilter const std::string data  ) 
 

Definition at line 422 of file m_filter.h.

References FilterResult::action, FilterResult::FillFlags(), FilterResult::flags, FilterResult::freeform, irc::tokenstream::GetToken(), FilterResult::gline_time, and FilterResult::reason.

Referenced by OnDecodeMetaData().

virtual bool FilterBase::DeleteFilter const std::string freeform  )  [pure virtual]
 

Implemented in ModuleFilter, and ModuleFilterPCRE.

Referenced by CommandFilter::Handle().

std::string FilterBase::EncodeFilter FilterResult filter  ) 
 

Definition at line 408 of file m_filter.h.

References FilterResult::action, FilterResult::flags, FilterResult::freeform, FilterResult::gline_time, and FilterResult::reason.

Referenced by SendFilter().

virtual FilterResult* FilterBase::FilterMatch User user,
const std::string text,
int  flags
[pure virtual]
 

Implemented in ModuleFilter, and ModuleFilterPCRE.

Referenced by OnPreCommand(), and OnUserPreNotice().

Version FilterBase::GetVersion  )  [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 402 of file m_filter.h.

References API_VERSION, VF_COMMON, and VF_VENDOR.

void FilterBase::OnDecodeMetaData int  target_type,
void *  target,
const std::string extname,
const std::string extdata
[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 453 of file m_filter.h.

References FilterResult::action, AddFilter(), DecodeFilter(), FilterResult::flags, FilterResult::freeform, FilterResult::gline_time, FilterResult::reason, and TYPE_OTHER.

int FilterBase::OnPreCommand std::string command,
std::vector< std::string > &  parameters,
User user,
bool  validated,
const std::string original_line
[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. You should only change the parameter list and command string if validated == false (e.g. before the command lookup occurs).
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 298 of file m_filter.h.

References FilterResult::action, XLineManager::AddLine(), XLineManager::ApplyLines(), InspIRCd::Config, exemptfromfilter, FilterMatch(), FLAG_PART, FLAG_QUIT, flags, CommandParser::GetHandler(), User::GetIPString(), FilterResult::gline_time, Command::Handle(), IS_LOCAL, User::nick, InspIRCd::Parser, UserManager::QuitUser(), FilterResult::reason, Module::ServerInstance, ServerConfig::ServerName, InspIRCd::Time(), InspIRCd::Users, User::WriteServ(), and InspIRCd::XLines.

void FilterBase::OnRehash User user,
const std::string parameter
[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.

Reimplemented in ModuleFilter, and ModuleFilterPCRE.

Definition at line 388 of file m_filter.h.

References exemptfromfilter, ConfigReader::ReadValue(), and Module::ServerInstance.

Referenced by ModuleFilterPCRE::OnRehash(), and ModuleFilter::OnRehash().

virtual int FilterBase::OnStats char  symbol,
User user,
string_list results
[pure virtual]
 

Called on all /STATS commands This method is triggered for all /STATS use, including stats symbols handled by the core.

Parameters:
symbol the symbol provided to /STATS
user the user issuing the /STATS command
results A string_list to append results into. You should put all your results into this string_list, rather than displaying them directly, so that your handler will work when remote STATS queries are received.
Returns:
1 to block the /STATS from being processed by the core, 0 to allow it

Reimplemented from Module.

Implemented in ModuleFilter, and ModuleFilterPCRE.

void FilterBase::OnSyncOtherMetaData Module proto,
void *  opaque,
bool  displayable = false
[virtual]
 

Reimplemented from Module.

Definition at line 443 of file m_filter.h.

References SyncFilters().

int FilterBase::OnUserPreMessage User user,
void *  dest,
int  target_type,
std::string text,
char  status,
CUList exempt_list
[virtual]
 

Called whenever a user is about to PRIVMSG A user or a channel, before any processing is done.

Returning any nonzero value from this function stops the process immediately, causing no output to be sent to the user by the core. If you do this you must produce your own numerics, notices etc. This is useful for modules which may want to filter or redirect messages. target_type can be one of TYPE_USER or TYPE_CHANNEL. If the target_type value is a user, you must cast dest to a User* otherwise you must cast it to a Channel*, this is the details of where the message is destined to be sent.

Parameters:
user The user sending the message
dest The target of the message (Channel* or User*)
target_type The type of target (TYPE_USER or TYPE_CHANNEL)
text Changeable text being sent by the user
status The status being used, e.g. PRIVMSG #chan has status== '@', 0 to send to everyone.
exempt_list A list of users not to send to. For channel messages, this will usually contain just the sender. It will be ignored for private messages.
Returns:
1 to deny the NOTICE, 0 to allow it

Reimplemented from Module.

Definition at line 237 of file m_filter.h.

References FLAG_PRIVMSG, flags, and OnUserPreNotice().

int FilterBase::OnUserPreNotice User user,
void *  dest,
int  target_type,
std::string text,
char  status,
CUList exempt_list
[virtual]
 

Called whenever a user is about to NOTICE A user or a channel, before any processing is done.

Returning any nonzero value from this function stops the process immediately, causing no output to be sent to the user by the core. If you do this you must produce your own numerics, notices etc. This is useful for modules which may want to filter or redirect messages. target_type can be one of TYPE_USER or TYPE_CHANNEL. If the target_type value is a user, you must cast dest to a User* otherwise you must cast it to a Channel*, this is the details of where the message is destined to be sent. You may alter the message text as you wish before relinquishing control to the next module in the chain, and if no other modules block the text this altered form of the text will be sent out to the user and possibly to other servers.

Parameters:
user The user sending the message
dest The target of the message (Channel* or User*)
target_type The type of target (TYPE_USER or TYPE_CHANNEL)
text Changeable text being sent by the user
status The status being used, e.g. PRIVMSG #chan has status== '@', 0 to send to everyone.
exempt_list A list of users not to send to. For channel notices, this will usually contain just the sender. It will be ignored for private notices.
Returns:
1 to deny the NOTICE, 0 to allow it

Reimplemented from Module.

Definition at line 243 of file m_filter.h.

References FilterResult::action, XLineManager::AddLine(), XLineManager::ApplyLines(), InspIRCd::Config, DEFAULT, exemptfromfilter, FilterMatch(), FLAG_NOTICE, flags, User::GetIPString(), FilterResult::gline_time, IS_LOCAL, LogManager::Log(), InspIRCd::Logs, Channel::name, User::nick, UserManager::QuitUser(), FilterResult::reason, User::server, Module::ServerInstance, ServerConfig::ServerName, InspIRCd::SNO, InspIRCd::Time(), TYPE_CHANNEL, TYPE_USER, InspIRCd::ULine(), InspIRCd::Users, User::WriteServ(), SnomaskManager::WriteToSnoMask(), and InspIRCd::XLines.

Referenced by OnUserPreMessage().

void FilterBase::SendFilter Module proto,
void *  opaque,
FilterResult iter
[virtual]
 

Definition at line 448 of file m_filter.h.

References EncodeFilter(), Module::ProtoSendMetaData(), and TYPE_OTHER.

Referenced by ModuleFilterPCRE::SyncFilters(), and ModuleFilter::SyncFilters().

virtual void FilterBase::SyncFilters Module proto,
void *  opaque
[pure virtual]
 

Implemented in ModuleFilter, and ModuleFilterPCRE.

Referenced by OnSyncOtherMetaData().


Member Data Documentation

std::vector<std::string> FilterBase::exemptfromfilter [protected]
 

Definition at line 98 of file m_filter.h.

Referenced by OnPreCommand(), OnRehash(), ModuleFilterPCRE::OnStats(), and OnUserPreNotice().

CommandFilter* FilterBase::filtcommand [private]
 

Definition at line 95 of file m_filter.h.

Referenced by FilterBase().

int FilterBase::flags [private]
 

Definition at line 96 of file m_filter.h.

Referenced by OnPreCommand(), OnUserPreMessage(), and OnUserPreNotice().


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