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, std::string &reason, 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, bool silent=false)
void ApplyLines ()
 DEPRECATED_METHOD (void InvokeStats(const std::string &type, unsigned int numeric, Stats::Context &stats))
bool InvokeStats (const std::string &type, Stats::Context &context)
void ExpireRemovedConfigLines (const std::string &type, const insp::flat_set< std::string > &configlines)

Protected Attributes

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

Detailed Description

XLineManager is a class used to manage G-lines, K-lines, E-lines, Z-lines and Q-lines, 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,
std::string &  reason,
User user,
bool  simulate = false 

Delete an XLine

hostmaskThe xline-specific string identifying the line, e.g. "*@foo"
typeThe type of xline
reasonThe xline reason, if it is being removed successfully
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


XLineManager::DEPRECATED_METHOD ( void   InvokeStatsconst std::string &type, unsigned int numeric, Stats::Context &stats)

DEPRECATED: use the bool InvokeStats(const std::string&, Stats::Context&) overload instead.

◆ ExpireLine()

void XLineManager::ExpireLine ( ContainerIter  container,
LookupIter  item,
bool  silent = false 

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
silentIf true, doesn't send an expiry SNOTICE.

◆ ExpireRemovedConfigLines()

void XLineManager::ExpireRemovedConfigLines ( const std::string &  type,
const insp::flat_set< std::string > &  configlines 

Expire X-lines which were added by the server configuration and have been removed.

◆ 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 separate strings. This allows for faster matching.

◆ InvokeStats()

bool XLineManager::InvokeStats ( const std::string &  type,
Stats::Context &  context 

Generates a /STATS response for the given X-line type.

typeThe type of X-line to look up.
contextThe stats context to respond with.
True if a response was sent; otherwise, false.

◆ MatchesLine() [1/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

◆ MatchesLine() [2/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

◆ 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 G-lines 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: