InspIRCd
3.0
|
#include <inspircd.h>
Public Member Functions | |
User * | FindUUID (const std::string &uid) |
time_t | Time () |
long | Time_ns () |
void | UpdateTime () |
std::string | GenRandomStr (unsigned int length, bool printable=true) |
unsigned long | GenRandomInt (unsigned long max) |
bool | BindPort (ConfigTag *tag, const irc::sockets::sockaddrs &sa, std::vector< ListenSocket * > &old_ports) |
size_t | BindPorts (FailedPortList &failed_ports) |
User * | FindNick (const std::string &nick) |
User * | FindNickOnly (const std::string &nick) |
Channel * | FindChan (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 () |
ClientProtocol::RFCEvents & | GetRFCEvents () |
Static Public Member Functions | |
static void | DefaultGenRandom (char *output, size_t max) |
static bool | DefaultIsChannel (const std::string &channel) |
static bool | IsHost (const std::string &host) |
static bool | IsSID (const std::string &sid) |
static void | SetSignal (int signal) |
static std::string | Format (const char *formatString,...) |
static std::string | Format (va_list &vaList, const char *formatString) |
static bool | DefaultIsNick (const std::string &nick) |
static bool | DefaultIsIdent (const std::string &ident) |
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 bool | Duration (const std::string &str, unsigned long &duration) |
static bool | IsValidDuration (const std::string &str) |
static std::string | DurationString (time_t duration) |
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 |
FakeUser * | FakeClient |
time_t | startup_time |
std::string | ConfigFileName |
ExtensionManager | Extensions |
ModeParser | Modes |
CommandParser | Parser |
ThreadEngine | Threads |
ConfigReaderThread * | ConfigThread |
LogManager | Logs |
ModuleManager | Modules |
BanCacheManager | BanCache |
serverstats | stats |
ServerConfig * | Config |
SnomaskManager | SNO |
TimerManager | Timers |
XLineManager * | XLines |
UserManager | Users |
chan_hash | chanlist |
std::vector< ListenSocket * > | ports |
ProtocolInterface * | PI |
ProtocolInterface | DefaultProtocolInterface |
ISupportManager | ISupport |
std::tr1 ::function< void(char *, size_t)> | GenRandom |
std::tr1 ::function< bool(const std::string &)> | IsChannel |
std::tr1 ::function< bool(const std::string &)> | IsNick |
std::tr1 ::function< bool(const std::string &)> | IsIdent |
Static Public Attributes | |
static sig_atomic_t | s_signal = 0 |
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.
InspIRCd::InspIRCd | ( | int | argc, |
char ** | argv | ||
) |
This constructor initialises all the subsystems and reads the config file.
argc | The argument count passed to main() |
argv | The argument list passed to main() |
<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. |
bool InspIRCd::BindPort | ( | ConfigTag * | tag, |
const irc::sockets::sockaddrs & | sa, | ||
std::vector< ListenSocket * > & | old_ports | ||
) |
Bind to a specific port from a config tag.
tag | the tag that contains bind information. |
sa | The endpoint to listen on. |
old_ports | Previously listening ports that may be on the same endpoint. |
size_t InspIRCd::BindPorts | ( | FailedPortList & | failed_ports | ) |
Bind all ports specified in the configuration file.
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.
|
static |
Fills the output buffer with the specified number of random characters. This is the default function for InspIRCd::GenRandom.
output | The output buffer to store random characters in. |
max | The maximum number of random characters to put in the buffer. |
|
static |
Determines whether a channel name is valid according to the RFC 1459 rules. This is the default function for InspIRCd::IsChannel.
channel | The channel name to validate. |
|
static |
Determines whether a ident is valid according to the RFC 1459 rules. This is the default function for InspIRCd::IsIdent.
ident | The ident to validate. |
|
static |
Determines whether a nickname is valid according to the RFC 1459 rules. This is the default function for InspIRCd::IsNick.
nick | The nickname to validate. |
|
static |
Calculate a duration in seconds from a string in the form 1y2w3d4h6m5s
str | A string containing a time in the form 1y2w3d4h6m5s (one year, two weeks, three days, four hours, six minutes and five seconds) |
|
static |
Calculate a duration in seconds from a string in the form 1y2w3d4h6m5s
str | A string containing a time in the form 1y2w3d4h6m5s (one year, two weeks, three days, four hours, six minutes and five seconds) |
duration | The location to place the parsed duration valur |
|
static |
Return a duration in seconds as a human-readable string.
duration | The duration in seconds to convert to a human-readable string. |
void InspIRCd::Exit | ( | int | status | ) |
Causes the server to exit after unloading modules and closing all open file descriptors.
status | The exit code to give to the operating system (See the ExitStatus enum for valid values) |
Channel * InspIRCd::FindChan | ( | const std::string & | chan | ) |
Find a channel in the channels hash
chan | The channel to find |
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
nick | The nickname to find |
User * InspIRCd::FindNickOnly | ( | const std::string & | nick | ) |
Find a user in the nick hash ONLY
User * InspIRCd::FindUUID | ( | const std::string & | uid | ) |
Find a user in the UUID hash
uid | The UUID to find |
|
static |
Formats the input string with the specified arguments.
formatString | The string to format |
... | A variable number of format arguments. |
unsigned long InspIRCd::GenRandomInt | ( | unsigned long | max | ) |
Generate a random integer. This is generally more secure than rand()
std::string InspIRCd::GenRandomStr | ( | unsigned int | length, |
bool | printable = true |
||
) |
Generate a random string with the given length
length | The length in bytes |
printable | if false, the string will use characters 0-255; otherwise, it will be limited to 0x30-0x7E ('0'-'~', nonspace printable characters) |
|
inline |
Get a hash map containing all channels, keyed by their name
std::string InspIRCd::GetVersionString | ( | bool | getFullVersion = false | ) |
Returns the full version string of this ircd
|
static |
Determines whether a hostname is valid according to RFC 5891 rules.
host | The hostname to validate. |
|
static |
Return true if str looks like a server ID
sid | string to check against |
|
static |
Determines whether a string contains a valid duration.
str | A string containing a time in the form 1y2w3d4h6m5s |
|
static |
Return true if the given parameter is a valid [email protected] mask
mask | A [email protected] masak to match against |
|
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.
str | The literal string to match against |
mask | The glob pattern to match against. |
map | The character map to use when matching. |
|
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.
str | The literal string to match against |
mask | The glob or CIDR pattern to match against. |
map | The character map to use when matching. |
|
static |
Matches a hostname and IP against a space delimited list of hostmasks.
masks | The space delimited masks to match against. |
hostname | The hostname to try and match. |
ipaddr | The IP address to try and match. |
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.
ex | The object (user, server, whatever) causing the comparison. |
data | The data from the config file |
input | The data input by the oper |
hashtype | The hash from the config file |
|
static |
Parses color codes from string values to actual color codes
input | The data to process |
void InspIRCd::Rehash | ( | const std::string & | uuid = "" | ) |
Rehash the local server
uuid | The uuid of the user who started the rehash, can be empty |
void InspIRCd::Run | ( | ) |
Begin execution of the server. NOTE: this function NEVER returns. Internally, it will repeatedly loop.
|
static |
Sets the signal received
signal | the signal received |
void InspIRCd::SignalHandler | ( | int | signal | ) |
Handles incoming signals after being set
signal | the signal received |
|
static |
Strips all color and control codes except 001 from the given string
sentence | The string to strip from |
|
inline |
Get the current time Because this only calls time() once every time around the mainloop, it is much faster than calling time() directly.
|
inline |
The fractional time at the start of this mainloop iteration (nanoseconds)
|
static |
Return a time_t as a human-readable string.
format | The format to retrieve the date/time in. See man 3 strftime for more information. If NULL, "%a %b %d %T %Y" is assumed. |
curtime | The timestamp to convert to a human-readable string. |
utc | True to convert the time to string as-is, false to convert it to local time first. |
|
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.
one | First string |
two | Second string |
void InspIRCd::UpdateTime | ( | ) |
Update the current time. Don't call this unless you have reason to do so.
void InspIRCd::WritePID | ( | const std::string & | filename, |
bool | exitonfail = true |
||
) |
Attempt to write the process id to a given file
filename | The PID file to attempt to write to |
exitonfail | If true and the PID fail cannot be written log to stdout and exit, otherwise only log on failure |
ActionList InspIRCd::AtomicActions |
Actions that must happen outside of the current call stack
BanCacheManager InspIRCd::BanCache |
BanCacheManager is used to speed up checking of restrictions on connection to the IRCd.
chan_hash InspIRCd::chanlist |
Channel list, a hash_map containing all channels XXX move to channel manager class
ServerConfig* InspIRCd::Config |
Server Config class, holds configuration file data
std::string InspIRCd::ConfigFileName |
Config file pathname specified on the commandline or via ./configure
ConfigReaderThread* InspIRCd::ConfigThread |
The thread/class used to read config files in REHASH and on startup
ProtocolInterface InspIRCd::DefaultProtocolInterface |
Default implementation of the ProtocolInterface, does nothing
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 isn't in the user hash and set its descriptor to FD_MAGIC_NUMBER so the data falls into the abyss :p
std::tr1 ::function<void(char*, size_t)> InspIRCd::GenRandom |
Fill a buffer with random bits
CullList InspIRCd::GlobalCulls |
Global cull list, will be processed on next iteration
std::tr1 ::function<bool(const std::string&)> InspIRCd::IsChannel |
Determines whether an channel name is valid.
std::tr1 ::function<bool(const std::string&)> InspIRCd::IsIdent |
Determines whether an ident is valid.
std::tr1 ::function<bool(const std::string&)> InspIRCd::IsNick |
Determines whether a nickname is valid.
ISupportManager InspIRCd::ISupport |
Manages the generation and transmission of ISUPPORT.
LogManager InspIRCd::Logs |
LogManager handles logging.
ModeParser InspIRCd::Modes |
Mode handler, handles mode setting and removal
ModuleManager InspIRCd::Modules |
ModuleManager contains everything related to loading/unloading modules.
CommandParser InspIRCd::Parser |
Command parser, handles client to server commands
ProtocolInterface* InspIRCd::PI |
Protocol interface, overridden by server protocol modules
std::vector<ListenSocket*> InspIRCd::ports |
List of the open ports
|
static |
Set to the current signal received
SnomaskManager InspIRCd::SNO |
Snomask manager - handles routing of snomask messages to opers.
time_t InspIRCd::startup_time |
Time this ircd was booted
serverstats InspIRCd::stats |
Stats class, holds miscellaneous stats counters
ThreadEngine InspIRCd::Threads |
Thread engine, Handles threading where required
TimerManager InspIRCd::Timers |
UserManager InspIRCd::Users |
User manager. Various methods and data associated with users.
XLineManager* InspIRCd::XLines |
X-line manager. Handles G/K/Q/E-line setting, removal and matching