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

#include <inspircd.h>

Public Member Functions

UserFindUUID (const std::string &uid)
 
time_t Time ()
 
long Time_ns ()
 
void UpdateTime ()
 
std::string GenRandomStr (int length, bool printable=true)
 
unsigned long GenRandomInt (unsigned long max)
 
int BindPorts (FailedPortList &failed_ports)
 
UserFindNick (const std::string &nick)
 
UserFindNickOnly (const std::string &nick)
 
ChannelFindChan (const std::string &chan)
 
chan_hash & GetChans ()
 
void SignalHandler (int signal)
 
void Exit (int status)
 
void Rehash (const std::string &uuid="")
 
bool PassCompare (Extensible *ex, const std::string &data, const std::string &input, const std::string &hashtype)
 
std::string GetVersionString (bool getFullVersion=false)
 
void WritePID (const std::string &filename, bool exitonfail=true)
 
 InspIRCd (int argc, char **argv)
 
void Cleanup ()
 
void Run ()
 
char * GetReadBuffer ()
 

Static Public Member Functions

static bool IsSID (const std::string &sid)
 
static void SetSignal (int signal)
 
static void QuickExit (int status)
 
static const char * Format (const char *formatString,...)
 
static const char * Format (va_list &vaList, const char *formatString)
 
static bool Match (const std::string &str, const std::string &mask, unsigned const char *map=NULL)
 
static bool Match (const char *str, const char *mask, unsigned const char *map=NULL)
 
static bool MatchCIDR (const std::string &str, const std::string &mask, unsigned const char *map=NULL)
 
static bool MatchCIDR (const char *str, const char *mask, unsigned const char *map=NULL)
 
static bool MatchMask (const std::string &masks, const std::string &hostname, const std::string &ipaddr)
 
static bool IsValidMask (const std::string &mask)
 
static void StripColor (std::string &sentence)
 
static void ProcessColors (file_cache &input)
 
static unsigned long Duration (const std::string &str)
 
static std::string TimeString (time_t curtime, const char *format=NULL, bool utc=false)
 
static bool TimingSafeCompare (const std::string &one, const std::string &two)
 

Public Attributes

UIDGenerator UIDGen
 
CullList GlobalCulls
 
ActionList AtomicActions
 
IsNickHandler HandleIsNick
 
IsIdentHandler HandleIsIdent
 
IsChannelHandler HandleIsChannel
 
GenRandomHandler HandleGenRandom
 
FakeUserFakeClient
 
time_t startup_time
 
std::string ConfigFileName
 
ExtensionManager Extensions
 
ModeParser Modes
 
CommandParser Parser
 
ThreadEngine Threads
 
ConfigReaderThreadConfigThread
 
LogManager Logs
 
ModuleManager Modules
 
BanCacheManager BanCache
 
serverstats stats
 
ServerConfigConfig
 
SnomaskManager SNO
 
TimerManager Timers
 
XLineManagerXLines
 
UserManager Users
 
chan_hash chanlist
 
std::vector< ListenSocket * > ports
 
ProtocolInterfacePI
 
ProtocolInterface DefaultProtocolInterface
 
ISupportManager ISupport
 
caller2< void, char *, size_t > GenRandom
 
caller1< bool, const std::string & > IsChannel
 
caller1< bool, const std::string & > IsNick
 
caller1< bool, const std::string & > IsIdent
 

Static Public Attributes

static sig_atomic_t s_signal = 0
 

Detailed Description

The main class of the irc server. This class contains instances of all the other classes in this software. Amongst other things, it contains a ModeParser, a DNS object, a CommandParser object, and a list of active Module objects, and facilities for Module objects to interact with the core system it implements.

Constructor & Destructor Documentation

◆ InspIRCd()

InspIRCd::InspIRCd ( int  argc,
char **  argv 
)

This constructor initialises all the subsystems and reads the config file.

Parameters
argcThe argument count passed to main()
argvThe argument list passed to main()
Exceptions
<anything>If anything is thrown from here and makes it to you, you should probably just give up and go home. Yes, really. It's that bad. Higher level classes should catch any non-fatal exceptions.

Member Function Documentation

◆ BindPorts()

int InspIRCd::BindPorts ( FailedPortList &  failed_ports)

Bind all ports specified in the configuration file.

Returns
The number of ports bound without error

◆ Cleanup()

void InspIRCd::Cleanup ( )

Prepare the ircd for restart or shutdown. This function unloads all modules which can be unloaded, closes all open sockets, and closes the logfile.

◆ Duration()

unsigned long InspIRCd::Duration ( const std::string &  str)
static

Calculate a duration in seconds from a string in the form 1y2w3d4h6m5s

Parameters
strA string containing a time in the form 1y2w3d4h6m5s (one year, two weeks, three days, four hours, six minutes and five seconds)
Returns
The total number of seconds

Refactored by Brain, Jun 2009. Much faster with some clever O(1) array lookups and pointer maths.

◆ Exit()

void InspIRCd::Exit ( int  status)

Causes the server to exit after unloading modules and closing all open file descriptors.

Parameters
statusThe exit code to give to the operating system (See the ExitStatus enum for valid values)

◆ FindChan()

Channel * InspIRCd::FindChan ( const std::string &  chan)

Find a channel in the channels hash

Parameters
chanThe channel to find
Returns
A pointer to the channel, or NULL if the channel does not exist

◆ FindNick()

User * InspIRCd::FindNick ( const std::string &  nick)

Find a user in the nick hash. If the user cant be found in the nick hash check the uuid hash

Parameters
nickThe nickname to find
Returns
A pointer to the user, or NULL if the user does not exist

◆ FindNickOnly()

User * InspIRCd::FindNickOnly ( const std::string &  nick)

Find a user in the nick hash ONLY

◆ FindUUID()

User * InspIRCd::FindUUID ( const std::string &  uid)

Find a user in the UUID hash

Parameters
uidThe UUID to find
Returns
A pointer to the user, or NULL if the user does not exist

◆ Format()

const char * InspIRCd::Format ( const char *  formatString,
  ... 
)
static

Formats the input string with the specified arguments.

Parameters
formatStringThe string to format
...A variable number of format arguments.
Returns
The formatted string

◆ GenRandomInt()

unsigned long InspIRCd::GenRandomInt ( unsigned long  max)

Generate a random integer. This is generally more secure than rand()

◆ GenRandomStr()

std::string InspIRCd::GenRandomStr ( int  length,
bool  printable = true 
)

Generate a random string with the given length

Parameters
lengthThe length in bytes
printableif false, the string will use characters 0-255; otherwise, it will be limited to 0x30-0x7E ('0'-'~', nonspace printable characters)

◆ GetChans()

chan_hash& InspIRCd::GetChans ( )
inline

Get a hash map containing all channels, keyed by their name

Returns
A hash map mapping channel names to Channel pointers

◆ GetVersionString()

std::string InspIRCd::GetVersionString ( bool  getFullVersion = false)

Returns the full version string of this ircd

Returns
The version string

◆ IsSID()

bool InspIRCd::IsSID ( const std::string &  sid)
static

Return true if str looks like a server ID

Parameters
sidstring to check against

◆ IsValidMask()

bool InspIRCd::IsValidMask ( const std::string &  mask)
static

Return true if the given parameter is a valid [email protected] mask

Parameters
maskA [email protected] masak to match against
Returns
True i the mask is valid

◆ Match()

bool InspIRCd::Match ( const std::string &  str,
const std::string &  mask,
unsigned const char *  map = NULL 
)
static

Match two strings using pattern matching, optionally, with a map to check case against (may be NULL). If map is null, match will be case insensitive.

Parameters
strThe literal string to match against
maskThe glob pattern to match against.
mapThe character map to use when matching.

◆ MatchCIDR()

bool InspIRCd::MatchCIDR ( const std::string &  str,
const std::string &  mask,
unsigned const char *  map = NULL 
)
static

Match two strings using pattern matching, optionally, with a map to check case against (may be NULL). If map is null, match will be case insensitive. Supports CIDR patterns as well as globs.

Parameters
strThe literal string to match against
maskThe glob or CIDR pattern to match against.
mapThe character map to use when matching.

◆ MatchMask()

bool InspIRCd::MatchMask ( const std::string &  masks,
const std::string &  hostname,
const std::string &  ipaddr 
)
static

Matches a hostname and IP against a space delimited list of hostmasks.

Parameters
masksThe space delimited masks to match against.
hostnameThe hostname to try and match.
ipaddrThe IP address to try and match.

◆ PassCompare()

bool InspIRCd::PassCompare ( Extensible ex,
const std::string &  data,
const std::string &  input,
const std::string &  hashtype 
)

Attempt to compare a password to a string from the config file. This will be passed to handling modules which will compare the data against possible hashed equivalents in the input string.

Parameters
exThe object (user, server, whatever) causing the comparison.
dataThe data from the config file
inputThe data input by the oper
hashtypeThe hash from the config file
Returns
True if the strings match, false if they do not

◆ ProcessColors()

void InspIRCd::ProcessColors ( file_cache &  input)
static

Parses color codes from string values to actual color codes

Parameters
inputThe data to process

◆ QuickExit()

void InspIRCd::QuickExit ( int  status)
static

Causes the server to exit immediately with exit code 0. The status code is required for signal handlers, and ignored.

◆ Rehash()

void InspIRCd::Rehash ( const std::string &  uuid = "")

Rehash the local server

Parameters
uuidThe uuid of the user who started the rehash, can be empty

◆ Run()

void InspIRCd::Run ( )

Begin execution of the server. NOTE: this function NEVER returns. Internally, it will repeatedly loop.

◆ SetSignal()

void InspIRCd::SetSignal ( int  signal)
static

Sets the signal recieved

Parameters
signalthe signal recieved

◆ SignalHandler()

void InspIRCd::SignalHandler ( int  signal)

Handles incoming signals after being set

Parameters
signalthe signal recieved

◆ StripColor()

void InspIRCd::StripColor ( std::string &  sentence)
static

Strips all color and control codes except 001 from the given string

Parameters
sentenceThe string to strip from

◆ Time()

time_t InspIRCd::Time ( )
inline

Get the current time Because this only calls time() once every time around the mainloop, it is much faster than calling time() directly.

Returns
The current time as an epoch value (time_t)

◆ Time_ns()

long InspIRCd::Time_ns ( )
inline

The fractional time at the start of this mainloop iteration (nanoseconds)

◆ TimeString()

std::string InspIRCd::TimeString ( time_t  curtime,
const char *  format = NULL,
bool  utc = false 
)
static

Return a time_t as a human-readable string.

Parameters
formatThe format to retrieve the date/time in. See man 3 strftime for more information. If NULL, "%a %b %d %T %Y" is assumed.
curtimeThe timestamp to convert to a human-readable string.
utcTrue to convert the time to string as-is, false to convert it to local time first.
Returns
A string representing the given date/time.

◆ TimingSafeCompare()

bool InspIRCd::TimingSafeCompare ( const std::string &  one,
const std::string &  two 
)
static

Compare two strings in a timing-safe way. If the lengths of the strings differ, the function returns false immediately (leaking information about the length), otherwise it compares each character and only returns after all characters have been compared.

Parameters
oneFirst string
twoSecond string
Returns
True if the strings match, false if they don't

◆ UpdateTime()

void InspIRCd::UpdateTime ( )

Update the current time. Don't call this unless you have reason to do so.

◆ WritePID()

void InspIRCd::WritePID ( const std::string &  filename,
bool  exitonfail = true 
)

Attempt to write the process id to a given file

Parameters
filenameThe PID file to attempt to write to
exitonfailIf true and the PID fail cannot be written log to stdout and exit, otherwise only log on failure
Returns
This function may bail if the file cannot be written

Member Data Documentation

◆ AtomicActions

ActionList InspIRCd::AtomicActions

Actions that must happen outside of the current call stack

◆ BanCache

BanCacheManager InspIRCd::BanCache

BanCacheManager is used to speed up checking of restrictions on connection to the IRCd.

◆ chanlist

chan_hash InspIRCd::chanlist

Channel list, a hash_map containing all channels XXX move to channel manager class

◆ Config

ServerConfig* InspIRCd::Config

Server Config class, holds configuration file data

◆ ConfigFileName

std::string InspIRCd::ConfigFileName

Config file pathname specified on the commandline or via ./configure

◆ ConfigThread

ConfigReaderThread* InspIRCd::ConfigThread

The thread/class used to read config files in REHASH and on startup

◆ DefaultProtocolInterface

ProtocolInterface InspIRCd::DefaultProtocolInterface

Default implementation of the ProtocolInterface, does nothing

◆ FakeClient

FakeUser* InspIRCd::FakeClient

Globally accessible fake user record. This is used to force mode changes etc across s2s, etc.. bit ugly, but.. better than how this was done in 1.1 Reason for it: kludge alert! SendMode expects a User* to send the numeric replies back to, so we create it a fake user that isnt in the user hash and set its descriptor to FD_MAGIC_NUMBER so the data falls into the abyss :p

◆ GenRandom

caller2<void, char*, size_t> InspIRCd::GenRandom

Fill a buffer with random bits

◆ GlobalCulls

CullList InspIRCd::GlobalCulls

Global cull list, will be processed on next iteration

◆ IsChannel

caller1<bool, const std::string&> InspIRCd::IsChannel

Return true if a channel name is valid

Parameters
chnameA channel name to verify
Returns
True if the name is valid

◆ IsIdent

caller1<bool, const std::string&> InspIRCd::IsIdent

Return true if an ident is valid

Parameters
Anident to verify
Returns
True if the ident is valid

◆ IsNick

caller1<bool, const std::string&> InspIRCd::IsNick

Return true if a nickname is valid

Parameters
nA nickname to verify
Returns
True if the nick is valid

◆ ISupport

ISupportManager InspIRCd::ISupport

Manages the generation and transmission of ISUPPORT.

◆ Logs

LogManager InspIRCd::Logs

LogManager handles logging.

◆ Modes

ModeParser InspIRCd::Modes

Mode handler, handles mode setting and removal

◆ Modules

ModuleManager InspIRCd::Modules

ModuleManager contains everything related to loading/unloading modules.

◆ Parser

CommandParser InspIRCd::Parser

Command parser, handles client to server commands

◆ PI

ProtocolInterface* InspIRCd::PI

Protocol interface, overridden by server protocol modules

◆ ports

std::vector<ListenSocket*> InspIRCd::ports

List of the open ports

◆ s_signal

sig_atomic_t InspIRCd::s_signal = 0
static

Set to the current signal recieved

◆ SNO

SnomaskManager InspIRCd::SNO

Snomask manager - handles routing of snomask messages to opers.

◆ startup_time

time_t InspIRCd::startup_time

Time this ircd was booted

◆ stats

serverstats InspIRCd::stats

Stats class, holds miscellaneous stats counters

◆ Threads

ThreadEngine InspIRCd::Threads

Thread engine, Handles threading where required

◆ Timers

TimerManager InspIRCd::Timers

Timer manager class, triggers Timer timer events

◆ Users

UserManager InspIRCd::Users

User manager. Various methods and data associated with users.

◆ XLines

XLineManager* InspIRCd::XLines

X-Line manager. Handles G/K/Q/E line setting, removal and matching


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