InspIRCd  3.0
Public Member Functions | Protected Attributes | List of all members
XLineManager Class Reference

#include <xline.h>

Public Member Functions

 XLineManager ()
 ~XLineManager ()
IdentHostPair IdentSplit (const std::string &ident_and_host)
void CheckELines ()
XLineLookup * GetAll (const std::string &type)
void DelAll (const std::string &type)
std::vector< std::string > GetAllTypes ()
bool AddLine (XLine *line, User *user)
bool DelLine (const char *hostmask, const std::string &type, User *user, bool simulate=false)
bool RegisterFactory (XLineFactory *xlf)
bool UnregisterFactory (XLineFactory *xlf)
XLineFactoryGetFactory (const std::string &type)
XLineMatchesLine (const std::string &type, User *user)
XLineMatchesLine (const std::string &type, const std::string &pattern)
void ExpireLine (ContainerIter container, LookupIter item)
void ApplyLines ()
void InvokeStats (const std::string &type, unsigned int numeric, Stats::Context &stats)

Protected Attributes

std::vector< XLine * > pending_lines
XLineFactMap line_factory
XLineContainer lookup_lines

Detailed Description

XLineManager is a class used to manage glines, klines, elines, zlines and qlines, or any other line created by a module. It also manages XLineFactory classes which can generate a specialized XLine for use by another module.

Constructor & Destructor Documentation

◆ XLineManager()

XLineManager::XLineManager ( )


◆ ~XLineManager()

XLineManager::~XLineManager ( )


Member Function Documentation

◆ AddLine()

bool XLineManager::AddLine ( XLine line,
User user 

Add a new XLine

lineThe line to be added
userThe user adding the line or NULL for the local server
True if the line was added successfully

◆ ApplyLines()

void XLineManager::ApplyLines ( )

Apply any new lines that are pending to be applied. This will only apply lines in the pending_lines list, to save on CPU time.

◆ CheckELines()

void XLineManager::CheckELines ( )

Checks what users match e:lines and sets their ban exempt flag accordingly.

◆ DelAll()

void XLineManager::DelAll ( const std::string &  type)

Remove all lines of a certain type.

◆ DelLine()

bool XLineManager::DelLine ( const char *  hostmask,
const std::string &  type,
User user,
bool  simulate = false 

Delete an XLine

hostmaskThe xline-specific string identifying the line, e.g. "*@foo"
typeThe type of xline
userThe user removing the line or NULL if its the local server
simulateIf this is true, don't actually remove the line, just return
True if the line was deleted successfully

◆ ExpireLine()

void XLineManager::ExpireLine ( ContainerIter  container,
LookupIter  item 

Expire a line given two iterators which identify it in the main map.

containerIterator to the first level of entries the map
itemIterator to the second level of entries in the map

◆ GetAll()

XLineLookup * XLineManager::GetAll ( const std::string &  type)

Get all lines of a certain type to an XLineLookup (std::map<std::string, XLine*>). NOTE: When this function runs any expired items are removed from the list before it is returned to the caller.

typeThe type to look up
A list of all XLines of the given type.

◆ GetAllTypes()

std::vector< std::string > XLineManager::GetAllTypes ( )

Return all known types of line currently stored by the XLineManager.

A vector containing all known line types currently stored in the main list.

◆ GetFactory()

XLineFactory * XLineManager::GetFactory ( const std::string &  type)

Get the XLineFactory for a specific type. Returns NULL if there is no known handler for this xline type.

typeThe type of XLine you require the XLineFactory for

◆ IdentSplit()

IdentHostPair XLineManager::IdentSplit ( const std::string &  ident_and_host)

Split an ident and host into two seperate strings. This allows for faster matching.

◆ InvokeStats()

void XLineManager::InvokeStats ( const std::string &  type,
unsigned int  numeric,
Stats::Context &  stats 

Handle /STATS for a given type. NOTE: Any items in the list for this particular line type which have expired will be expired and removed before the list is displayed.

typeThe type of stats to show
numericThe numeric to give to each result line
statsStats context

◆ MatchesLine() [1/2]

XLine * XLineManager::MatchesLine ( const std::string &  type,
User user 

Check if a user matches an XLine

typeThe type of line to look up
userThe user to match against (what is checked is specific to the xline type)
The reason for the line if there is a match, or NULL if there is no match

◆ MatchesLine() [2/2]

XLine * XLineManager::MatchesLine ( const std::string &  type,
const std::string &  pattern 

Check if a pattern matches an XLine

typeThe type of line to look up
patternA pattern string specific to the xline type
The matching XLine if there is a match, or NULL if there is no match

◆ RegisterFactory()

bool XLineManager::RegisterFactory ( XLineFactory xlf)

Registers an xline factory. An xline factory is a class which when given a particular xline type, will generate a new XLine specialized to that type. For example if you pass the XLineFactory that handles glines some data it will return a pointer to a GLine, polymorphically represented as XLine. This is used where you do not know the full details of the item you wish to create, e.g. in a server protocol module like m_spanningtree, when you receive xlines from other servers.

xlfXLineFactory pointer to register

◆ UnregisterFactory()

bool XLineManager::UnregisterFactory ( XLineFactory xlf)

Unregisters an xline factory. You must do this when your module unloads.

xlfXLineFactory pointer to unregister

Member Data Documentation

◆ line_factory

XLineFactMap XLineManager::line_factory

Current xline factories

◆ lookup_lines

XLineContainer XLineManager::lookup_lines

Container of all lines, this is a map of maps which allows for fast lookup for add/remove of a line, and the shortest possible timed O(n) for checking a user against a line.

◆ pending_lines

std::vector<XLine *> XLineManager::pending_lines

Used to hold XLines which have not yet been applied.

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