InspIRCd
3.0
|
#include <mode.h>
Public Types | |
enum | ModeProcessFlags { MODE_NONE = 0, MODE_MERGE = 1, MODE_LOCALONLY = 2, MODE_CHECKACCESS = 4 } |
typedef TR1NS::unordered_map< std::string, ModeHandler *, irc::insensitive, irc::StrHashComp > | ModeHandlerMap |
typedef std::vector< ListModeBase * > | ListModeList |
typedef std::vector< PrefixMode * > | PrefixModeList |
typedef unsigned int | ModeProcessFlag |
Public Member Functions | |
const Modes::ChangeList & | GetLastChangeList () const |
void | AddMode (ModeHandler *mh) |
bool | DelMode (ModeHandler *mh) |
void | AddModeWatcher (ModeWatcher *mw) |
bool | DelModeWatcher (ModeWatcher *mw) |
void | Process (User *user, Channel *targetchannel, User *targetuser, Modes::ChangeList &changelist, ModeProcessFlag flags=MODE_NONE) |
unsigned int | ProcessSingle (User *user, Channel *targetchannel, User *targetuser, Modes::ChangeList &changelist, ModeProcessFlag flags=MODE_NONE, unsigned int beginindex=0) |
void | ModeParamsToChangeList (User *user, ModeType type, const std::vector< std::string > ¶meters, Modes::ChangeList &changelist, unsigned int beginindex=1, unsigned int endindex=UINT_MAX) |
ModeHandler * | FindMode (const std::string &modename, ModeType mt) |
ModeHandler * | FindMode (unsigned const char modeletter, ModeType mt) |
PrefixMode * | FindPrefixMode (unsigned char modeletter) |
PrefixMode * | FindPrefix (unsigned const char pfxletter) |
std::string | GiveModeList (ModeType mt) |
std::string | BuildPrefixes (bool lettersAndModes=true) |
const ListModeList & | GetListModes () const |
const PrefixModeList & | GetPrefixModes () const |
const ModeHandlerMap & | GetModes (ModeType mt) const |
void | ShowListModeList (User *user, Channel *chan, ModeHandler *mh) |
![]() | |
ModeParser * | operator-> () |
Static Public Member Functions | |
static bool | IsModeChar (char chr) |
static void | CleanMask (std::string &mask) |
Static Public Attributes | |
static const ModeHandler::Id | MODEID_MAX = 64 |
static const size_t | MODE_PARAM_MAX = 250 |
The mode parser handles routing of modes and handling of mode strings. It marshalls, controls and maintains both ModeWatcher and ModeHandler classes, parses client to server MODE strings for user and channel modes, and performs processing for the 004 mode list numeric, amongst other things.
typedef TR1NS::unordered_map<std::string, ModeHandler*, irc::insensitive, irc::StrHashComp> ModeParser::ModeHandlerMap |
Type of the container that maps mode names to ModeHandlers
Enumerator | |
---|---|
MODE_NONE | If only this flag is specified, the mode change will be global and parameter modes will have their parameters explicitly set (not merged). This is the default. |
MODE_MERGE | If this flag is set then the parameters of non-listmodes will be merged according to their conflict resolution rules. Does not affect user modes, channel modes without a parameter and listmodes. |
MODE_LOCALONLY | If this flag is set then the linking module will ignore the mode change and not send it to other servers. The mode change will be processed locally and sent to local user(s) as usual. |
MODE_CHECKACCESS | If this flag is set then the mode change will be subject to access checks. For more information see the documentation of the PrefixMode class, ModeHandler::ranktoset and ModeHandler::AccessCheck(). Modules may explicitly allow a mode change regardless of this flag by returning MOD_RES_ALLOW from the OnPreMode hook. Only affects channel mode changes. |
void ModeParser::AddMode | ( | ModeHandler * | mh | ) |
Add a mode to the mode parser. Throws a ModuleException if the mode cannot be added.
void ModeParser::AddModeWatcher | ( | ModeWatcher * | mw | ) |
Add a mode watcher. A mode watcher is triggered before and after a mode handler is triggered. See the documentation of class ModeWatcher for more information.
mw | The ModeWatcher you want to add |
std::string ModeParser::BuildPrefixes | ( | bool | lettersAndModes = true | ) |
This returns the PREFIX=(ohv)%+ section of the 005 numeric, or just the "@%+" part if the parameter false
|
static |
Tidy a banmask. This makes a banmask 'acceptable' if fields are left out. E.g.
nick -> nick!*@*
nick!ident -> [email protected]*
host.name -> !@host.name
ident -> * @hos t.nam e[email protected]
This method can be used on both IPV4 and IPV6 user masks.
bool ModeParser::DelMode | ( | ModeHandler * | mh | ) |
Delete a mode from the mode parser. When a mode is deleted, the mode handler will be called for every user (if it is a user mode) or for every channel (if it is a channel mode) to unset the mode on all objects. This prevents modes staying in the system which no longer exist.
mh | The mode handler to remove |
bool ModeParser::DelModeWatcher | ( | ModeWatcher * | mw | ) |
Delete a mode watcher. A mode watcher is triggered before and after a mode handler is triggered. See the documentation of class ModeWatcher for more information.
mw | The ModeWatcher you want to delete |
ModeHandler * ModeParser::FindMode | ( | const std::string & | modename, |
ModeType | mt | ||
) |
Find the mode handler for a given mode name and type.
modename | The mode name to search for. |
mt | Type of mode to search for, user or channel. |
ModeHandler * ModeParser::FindMode | ( | unsigned const char | modeletter, |
ModeType | mt | ||
) |
Find the mode handler for a given mode and type.
modeletter | mode letter to search for |
mt | type of mode to search for, user or channel |
PrefixMode * ModeParser::FindPrefix | ( | unsigned const char | pfxletter | ) |
Find a mode handler by its prefix. If there is no mode handler with the given prefix, NULL will be returned.
pfxletter | The prefix to find, e.g. '@' |
PrefixMode * ModeParser::FindPrefixMode | ( | unsigned char | modeletter | ) |
Find the mode handler for the given prefix mode
modeletter | The mode letter to search for |
|
inline |
Gets the last mode change to be processed.
|
inline |
Get a list of all mode handlers that inherit from ListModeBase
|
inline |
Get a mode name -> ModeHandler* map containing all modes of the given type
mt | Type of modes to return, MODETYPE_USER or MODETYPE_CHANNEL |
|
inline |
Get a list of all prefix modes
std::string ModeParser::GiveModeList | ( | ModeType | mt | ) |
Generates a list of modes, comma separated by type: 1; Listmodes EXCEPT those with a prefix 2; Modes that take a param when adding or removing 3; Modes that only take a param when adding 4; Modes that dont take a param
void ModeParser::ModeParamsToChangeList | ( | User * | user, |
ModeType | type, | ||
const std::vector< std::string > & | parameters, | ||
Modes::ChangeList & | changelist, | ||
unsigned int | beginindex = 1 , |
||
unsigned int | endindex = UINT_MAX |
||
) |
Turn a list of parameters compatible with the format of the MODE command into Modes::ChangeList form. All modes are processed, regardless of max modes. Unknown modes are skipped.
user | The source of the mode change, can be a server user. Error numerics are sent to this user. |
type | MODETYPE_USER if this is a user mode change or MODETYPE_CHANNEL if this is a channel mode change. |
parameters | List of strings describing the mode change to convert to a ChangeList. Must be using the same format as the parameters of a MODE command. |
changelist | ChangeList object to populate. |
beginindex | Index of the first element that is part of the MODE list in the parameters container. Defaults to 1. |
endindex | Index of the first element that is not part of the MODE list. By default, the entire container is considered part of the MODE list. |
void ModeParser::Process | ( | User * | user, |
Channel * | targetchannel, | ||
User * | targetuser, | ||
Modes::ChangeList & | changelist, | ||
ModeProcessFlag | flags = MODE_NONE |
||
) |
Process a list of mode changes entirely. If the mode changes do not fit into one MODE line then multiple MODE lines are generated.
user | The source of the mode change, can be a server user. |
targetchannel | Channel to apply the mode change on. NULL if changing modes on a channel. |
targetuser | User to apply the mode change on. NULL if changing modes on a user. |
changelist | Modes to change in form of a Modes::ChangeList. |
flags | Optional flags controlling how the mode change is processed, defaults to MODE_NONE. |
unsigned int ModeParser::ProcessSingle | ( | User * | user, |
Channel * | targetchannel, | ||
User * | targetuser, | ||
Modes::ChangeList & | changelist, | ||
ModeProcessFlag | flags = MODE_NONE , |
||
unsigned int | beginindex = 0 |
||
) |
Process a single MODE line's worth of mode changes, taking max modes and line length limits into consideration. Return value indicates how many modes were processed.
user | The source of the mode change, can be a server user. |
targetchannel | Channel to apply the mode change on. NULL if changing modes on a channel. |
targetuser | User to apply the mode change on. NULL if changing modes on a user. |
changelist | Modes to change in form of a Modes::ChangeList. May not process the entire list due to MODE line length and max modes limitations. |
flags | Optional flags controlling how the mode change is processed, defaults to MODE_NONE. |
beginindex | Index of the first element in changelist to process. Mode changes before the element with this index are ignored. |
void ModeParser::ShowListModeList | ( | User * | user, |
Channel * | chan, | ||
ModeHandler * | mh | ||
) |
std::vector<ListModeBase*> ModeParser::list |
List of mode handlers that inherit from ListModeBase
|
static |
The maximum length of a mode parameter.
|
static |
The maximum number of modes which can be created.
std::vector<PrefixMode*> ModeParser::prefix |
List of mode handlers that inherit from PrefixMode