The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

ServerConfig Class Reference

This class holds the bulk of the runtime configuration for the ircd. More...

#include <configreader.h>

Inheritance diagram for ServerConfig:

Inheritance graph
[legend]
Collaboration diagram for ServerConfig:

Collaboration graph
[legend]
List of all members.

Public Types

enum  InviteAnnounceState { INVITE_ANNOUNCE_NONE, INVITE_ANNOUNCE_ALL, INVITE_ANNOUNCE_OPS, INVITE_ANNOUNCE_DYNAMIC }
 Used to indicate who we announce invites to on a channel. More...

Public Member Functions

bool DoPipe (ConfigDataHash &target, const std::string &file, std::ostringstream &errorstream)
 Process an include executable directive.
bool DoInclude (ConfigDataHash &target, const std::string &file, std::ostringstream &errorstream)
 Process an include file directive.
InspIRCdGetInstance ()
 Returns the creator InspIRCd pointer.
int DoDownloads ()
 Not used any more as it is named, can probably be removed or renamed.
 ServerConfig (InspIRCd *Instance)
 Construct a new ServerConfig.
void ClearStack ()
 Clears the include stack in preperation for a Read() call.
std::string GetSID ()
 Get server ID as string with required leading zeroes.
void Update005 ()
 Update the 005 vector.
void Send005 (User *user)
 Send the 005 numerics (ISUPPORT) to a user.
void Read (bool bail, const std::string &useruid)
 Read the entire configuration into memory and initialize this class.
bool ReadFile (file_cache &F, const char *fname)
 Read a file into a file_cache object.
bool StartsWithWindowsDriveLetter (const std::string &path)
void ReportConfigError (const std::string &errormessage, bool bail, const std::string &useruid)
 Report a configuration error given in errormessage.
bool LoadConf (ConfigDataHash &target, FILE *&conf, const char *filename, std::ostringstream &errorstream)
 Load 'filename' into 'target', with the new config parser everything is parsed into tag/key/value at load-time rather than at read-value time.
bool LoadConf (ConfigDataHash &target, FILE *&conf, const std::string &filename, std::ostringstream &errorstream)
 Load 'filename' into 'target', with the new config parser everything is parsed into tag/key/value at load-time rather than at read-value time.
bool ConfValue (ConfigDataHash &target, const char *tag, const char *var, int index, char *result, int length, bool allow_linefeeds=false)
 Writes 'length' chars into 'result' as a string.
bool ConfValue (ConfigDataHash &target, const char *tag, const char *var, const char *default_value, int index, char *result, int length, bool allow_linefeeds=false)
 Writes 'length' chars into 'result' as a string.
bool ConfValue (ConfigDataHash &target, const std::string &tag, const std::string &var, int index, std::string &result, bool allow_linefeeds=false)
 Writes 'length' chars into 'result' as a string.
bool ConfValue (ConfigDataHash &target, const std::string &tag, const std::string &var, const std::string &default_value, int index, std::string &result, bool allow_linefeeds=false)
 Writes 'length' chars into 'result' as a string.
bool ConfValueInteger (ConfigDataHash &target, const char *tag, const char *var, int index, int &result)
 Tries to convert the value to an integer and write it to 'result'.
bool ConfValueInteger (ConfigDataHash &target, const char *tag, const char *var, const char *default_value, int index, int &result)
 Tries to convert the value to an integer and write it to 'result'.
bool ConfValueInteger (ConfigDataHash &target, const std::string &tag, const std::string &var, int index, int &result)
 Tries to convert the value to an integer and write it to 'result'.
bool ConfValueInteger (ConfigDataHash &target, const std::string &tag, const std::string &var, const std::string &default_value, int index, int &result)
 Tries to convert the value to an integer and write it to 'result'.
bool ConfValueBool (ConfigDataHash &target, const char *tag, const char *var, int index)
 Returns true if the value exists and has a true value, false otherwise.
bool ConfValueBool (ConfigDataHash &target, const char *tag, const char *var, const char *default_value, int index)
 Returns true if the value exists and has a true value, false otherwise.
bool ConfValueBool (ConfigDataHash &target, const std::string &tag, const std::string &var, int index)
 Returns true if the value exists and has a true value, false otherwise.
bool ConfValueBool (ConfigDataHash &target, const std::string &tag, const std::string &var, const std::string &default_value, int index)
 Returns true if the value exists and has a true value, false otherwise.
int ConfValueEnum (ConfigDataHash &target, const char *tag)
 Returns the number of occurences of tag in the config file.
int ConfValueEnum (ConfigDataHash &target, const std::string &tag)
 Returns the number of occurences of tag in the config file.
int ConfVarEnum (ConfigDataHash &target, const char *tag, int index)
 Returns the numbers of vars inside the index'th 'tag in the config file.
int ConfVarEnum (ConfigDataHash &target, const std::string &tag, int index)
 Returns the numbers of vars inside the index'th 'tag in the config file.
void ValidateHostname (const char *p, const std::string &tag, const std::string &val)
 Validates a hostname value, throwing ConfigException if it is not valid.
void ValidateIP (const char *p, const std::string &tag, const std::string &val, bool wild)
 Validates an IP address value, throwing ConfigException if it is not valid.
void ValidateNoSpaces (const char *p, const std::string &tag, const std::string &val)
 Validates a value that should not contain spaces, throwing ConfigException of it is not valid.
std::string GetFullProgDir ()
 Returns the fully qualified path to the inspircd directory.

Static Public Member Functions

static bool DirValid (const char *dirandfile)
 Returns true if a directory is valid (within the modules directory).
static char * CleanFilename (char *name)
 Clean a filename, stripping the directories (and drives) from string.
static bool FileExists (const char *file)
 Check if a file exists.

Public Attributes

std::string RehashUserUID
 User that is currently performing a rehash, needed because the rehash code is now threaded and needs to know who to give errors and feedback to.
std::string RehashParameter
 Rehash parameter, as above.
std::ostringstream * errstr
 Error stream, contains error output from any failed configuration parsing.
ConfigDataHash newconfig
 Holds the new configuration when a rehash occurs so we dont overwrite the existing working config with a broken one without checking it first and swapping pointers.
std::map< std::string, std::istream * > IncludedFiles
 Set of included files.
Validator DNSServerValidator
 Pointer to function that validates dns server addresses (can be changed depending on platform).
ConfigDataHash config_data
 This holds all the information in the config file, it's indexed by tag name to a vector of key/values.
ServerLimits Limits
 Length limits, see definition of ServerLimits class.
int c_ipv4_range
 Clones CIDR range for ipv4 (0-32) Defaults to 32 (checks clones on all IPs seperately).
int c_ipv6_range
 Clones CIDR range for ipv6 (0-128) Defaults to 128 (checks on all IPs seperately).
int WhoWasGroupSize
 Max number of WhoWas entries per user.
int WhoWasMaxGroups
 Max number of cumulative user-entries in WhoWas.
int WhoWasMaxKeep
 Max seconds a user is kept in WhoWas before being pruned.
char SetUser [MAXBUF]
 Both for set(g|u)id.
char SetGroup [MAXBUF]
char ServerName [MAXBUF]
 Holds the server name of the local server as defined by the administrator.
char MoronBanner [MAXBUF]
 Notice to give to users when they are Xlined.
char Network [MAXBUF]
char ServerDesc [MAXBUF]
 Holds the description of the local server as defined by the administrator.
char AdminName [MAXBUF]
 Holds the admin's name, for output in the /ADMIN command.
char AdminEmail [MAXBUF]
 Holds the email address of the admin, for output in the /ADMIN command.
char AdminNick [MAXBUF]
 Holds the admin's nickname, for output in the /ADMIN command.
char diepass [MAXBUF]
 The admin-configured /DIE password.
char restartpass [MAXBUF]
 The admin-configured /RESTART password.
char powerhash [MAXBUF]
 The hash method for *BOTH* the die and restart passwords.
char motd [MAXBUF]
 The pathname and filename of the message of the day file, as defined by the administrator.
char rules [MAXBUF]
 The pathname and filename of the rules file, as defined by the administrator.
char PrefixQuit [MAXBUF]
 The quit prefix in use, or an empty string.
char SuffixQuit [MAXBUF]
 The quit suffix in use, or an empty string.
char FixedQuit [MAXBUF]
 The fixed quit message in use, or an empty string.
char PrefixPart [MAXBUF]
 The part prefix in use, or an empty string.
char SuffixPart [MAXBUF]
 The part suffix in use, or an empty string.
char FixedPart [MAXBUF]
 The fixed part message in use, or an empty string.
char DieValue [MAXBUF]
 The last string found within a <die> tag, or an empty string.
char DNSServer [MAXBUF]
 The DNS server to use for DNS queries.
bool DisabledDontExist
 Pretend disabled commands don't exist.
char DisabledCommands [MAXBUF]
 This variable contains a space-seperated list of commands which are disabled by the administrator of the server for non-opers.
char DisabledUModes [64]
 This variable identifies which usermodes have been diabled.
char DisabledCModes [64]
 This variable identifies which chanmodes have been disabled.
char ModPath [1024]
 The full path to the modules directory.
char MyExecutable [1024]
 The full pathname to the executable, as given in argv[0] when the program starts.
FILE * log_file
 The file handle of the logfile.
bool nofork
 If this value is true, the owner of the server specified -nofork on the command line, causing the daemon to stay in the foreground.
bool forcedebug
 If this value if true then all log messages will be output, regardless of the level given in the config file.
bool writelog
 If this is true then log output will be written to the logfile.
bool RestrictBannedUsers
 If this value is true, banned users (+b, not extbans) will not be able to change nick if banned on any channel, nor to message them.
bool AllowHalfop
 If this value is true, halfops have been enabled in the configuration file.
bool HideModeLists [256]
 If this is set to true, then mode lists (e.g MODE chan b) are hidden from unprivileged users.
bool ExemptChanOps [256]
 If this is set to true, then channel operators are exempt from this channel mode.
int dns_timeout
 The number of seconds the DNS subsystem will wait before timing out any request.
int NetBufferSize
 The size of the read() buffer in the user handling code, used to read data into a user's recvQ.
int MaxConn
 The value to be used for listen() backlogs as default.
unsigned int SoftLimit
 The soft limit value assigned to the irc server.
unsigned int MaxTargets
 Maximum number of targets for a multi target command such as PRIVMSG or KICK.
int MaxWhoResults
 The maximum number of /WHO results allowed in any single /WHO command.
int debugging
 True if the DEBUG loglevel is selected.
int DieDelay
 How many seconds to wait before exiting the program when /DIE is correctly issued.
bool HideSplits
 True if we're going to hide netsplits as *.net *.split for non-opers.
bool HideBans
 True if we're going to hide ban reasons for non-opers (e.g.
InviteAnnounceState AnnounceInvites
 Announce invites to the channel with a server notice.
bool OperSpyWhois
 If this is enabled then operators will see invisible (+i) channels in /whois.
char HideWhoisServer [MAXBUF]
 Set to a non-empty string to obfuscate the server name of users in WHOIS.
char HideKillsServer [MAXBUF]
 Set to a non empty string to obfuscate nicknames prepended to a KILL.
file_cache MOTD
 The MOTD file, cached in a file_cache type.
file_cache RULES
 The RULES file, cached in a file_cache type.
char PID [1024]
 The full pathname and filename of the PID file as defined in the configuration.
ClassVector Classes
 The connect classes in use by the IRC server.
std::vector< ListenSocketBase * > ports
 A list of the classes for listening ports.
std::string data005
 The 005 tokens of this server (ISUPPORT) populated/repopulated upon loading or unloading modules.
std::vector< std::stringisupport
 isupport strings
char UserStats [MAXBUF]
 STATS characters in this list are available only to operators.
std::string logpath
 The path and filename of the ircd.log file.
char DefaultModes [MAXBUF]
 Default channel modes.
char CustomVersion [MAXBUF]
 Custom version string, which if defined can replace the system info in VERSION.
std::map< irc::string, bool > ulines
 List of u-lined servers.
std::map< std::string, int > maxbans
 Max banlist sizes for channels (the std::string is a glob).
std::string MyDir
 Directory where the inspircd binary resides.
bool NoUserDns
 If set to true, no user DNS lookups are to be performed.
bool SyntaxHints
 If set to true, provide syntax hints for unknown commands.
bool CycleHosts
 If set to true, users appear to quit then rejoin when their hosts change.
bool UndernetMsgPrefix
 If set to true, prefixed channel NOTICEs and PRIVMSGs will have the prefix added to the outgoing text for undernet style msg prefixing.
bool FullHostInTopic
 If set to true, the full nick!user will be shown in the TOPIC command for who set the topic last.
opertype_t opertypes
 All oper type definitions from the config file.
operclass_t operclass
 All oper class definitions from the config file.
char ** argv
 Saved argv from startup.
int argc
 Saved argc from startup.
unsigned int MaxChans
 Max channels per user.
unsigned int OperMaxChans
 Oper max channels per user.
char sid [MAXBUF]
 TS6-like server ID.
bool TestSuite
 True if we have been told to run the testsuite from the commandline, rather than entering the mainloop.
bool InvBypassModes
 If this value is true, invites will bypass more than just +i.

Private Member Functions

bool ParseLine (ConfigDataHash &target, const std::string &filename, std::string &line, long &linenumber, std::ostringstream &errorstream)
 This private method processes one line of configutation, appending errors to errorstream and setting error if an error has occured.
bool CheckOnce (const char *tag, ConfigDataHash &newconf)
 Check that there is only one of each configuration item.

Private Attributes

InspIRCdServerInstance
 Creator/owner pointer.
std::vector< std::stringinclude_stack
 This variable holds the names of all files included from the main one.

Detailed Description

This class holds the bulk of the runtime configuration for the ircd.

It allows for reading new config values, accessing configuration files, and storage of the configuration data needed to run the ircd, such as the servername, connect classes, /ADMIN data, MOTDs and filenames etc.

Definition at line 308 of file configreader.h.


Member Enumeration Documentation

enum ServerConfig::InviteAnnounceState
 

Used to indicate who we announce invites to on a channel.

Enumerator:
INVITE_ANNOUNCE_NONE 
INVITE_ANNOUNCE_ALL 
INVITE_ANNOUNCE_OPS 
INVITE_ANNOUNCE_DYNAMIC 

Definition at line 364 of file configreader.h.


Constructor & Destructor Documentation

ServerConfig::ServerConfig InspIRCd Instance  ) 
 

Construct a new ServerConfig.

Definition at line 39 of file configreader.cpp.

References AdminEmail, AdminName, AdminNick, AllowHalfop, c_ipv4_range, c_ipv6_range, ClearStack(), CustomVersion, CycleHosts, debugging, DefaultModes, DieDelay, diepass, DieValue, DisabledCommands, dns_timeout, DNSServer, DNSServerValidator, FixedQuit, forcedebug, SocketEngine::GetMaxFds(), HideBans, HideKillsServer, HideSplits, HideWhoisServer, InvBypassModes, log_file, maxbans, MaxChans, MaxConn, MaxTargets, MaxWhoResults, ModPath, motd, MyExecutable, NetBufferSize, Network, nofork, NoUserDns, OperMaxChans, OperSpyWhois, PID, PrefixQuit, restartpass, rules, InspIRCd::SE, ServerDesc, ServerName, sid, SoftLimit, SuffixQuit, UndernetMsgPrefix, UserStats, ValidateDnsServer(), WhoWasGroupSize, WhoWasMaxGroups, WhoWasMaxKeep, and writelog.


Member Function Documentation

bool ServerConfig::CheckOnce const char *  tag,
ConfigDataHash newconf
[private]
 

Check that there is only one of each configuration item.

Definition at line 104 of file configreader.cpp.

References ConfValueEnum().

Referenced by Read().

char * ServerConfig::CleanFilename char *  name  )  [static]
 

Clean a filename, stripping the directories (and drives) from string.

Parameters:
name Directory to tidy
Returns:
The cleaned filename

Definition at line 2033 of file configreader.cpp.

void ServerConfig::ClearStack  ) 
 

Clears the include stack in preperation for a Read() call.

Definition at line 65 of file configreader.cpp.

References include_stack.

Referenced by ConfigReader::ConfigReader(), InspIRCd::InspIRCd(), and ServerConfig().

bool ServerConfig::ConfValue ConfigDataHash target,
const std::string tag,
const std::string var,
const std::string default_value,
int  index,
std::string result,
bool  allow_linefeeds = false
 

Writes 'length' chars into 'result' as a string.

Definition at line 1794 of file configreader.cpp.

References DEFAULT, LogManager::Log(), InspIRCd::Logs, and ServerInstance.

bool ServerConfig::ConfValue ConfigDataHash target,
const std::string tag,
const std::string var,
int  index,
std::string result,
bool  allow_linefeeds = false
 

Writes 'length' chars into 'result' as a string.

Definition at line 1789 of file configreader.cpp.

References ConfValue().

bool ServerConfig::ConfValue ConfigDataHash target,
const char *  tag,
const char *  var,
const char *  default_value,
int  index,
char *  result,
int  length,
bool  allow_linefeeds = false
 

Writes 'length' chars into 'result' as a string.

Definition at line 1781 of file configreader.cpp.

References ConfValue(), and strlcpy().

bool ServerConfig::ConfValue ConfigDataHash target,
const char *  tag,
const char *  var,
int  index,
char *  result,
int  length,
bool  allow_linefeeds = false
 

Writes 'length' chars into 'result' as a string.

Definition at line 1776 of file configreader.cpp.

Referenced by InspIRCd::BindPorts(), ConfValue(), ConfValueBool(), ConfValueInteger(), InspIRCd::HostMatchesEveryone(), InspIRCd::IPMatchesEveryone(), ModuleManager::LoadAll(), InspIRCd::NickMatchesEveryone(), Read(), and ConfigReader::ReadValue().

bool ServerConfig::ConfValueBool ConfigDataHash target,
const std::string tag,
const std::string var,
const std::string default_value,
int  index
 

Returns true if the value exists and has a true value, false otherwise.

Definition at line 1917 of file configreader.cpp.

References ConfValue().

bool ServerConfig::ConfValueBool ConfigDataHash target,
const std::string tag,
const std::string var,
int  index
 

Returns true if the value exists and has a true value, false otherwise.

Definition at line 1912 of file configreader.cpp.

References ConfValueBool().

bool ServerConfig::ConfValueBool ConfigDataHash target,
const char *  tag,
const char *  var,
const char *  default_value,
int  index
 

Returns true if the value exists and has a true value, false otherwise.

Definition at line 1907 of file configreader.cpp.

References ConfValueBool().

bool ServerConfig::ConfValueBool ConfigDataHash target,
const char *  tag,
const char *  var,
int  index
 

Returns true if the value exists and has a true value, false otherwise.

Definition at line 1902 of file configreader.cpp.

Referenced by ConfValueBool(), InspIRCd::HostMatchesEveryone(), InspIRCd::IPMatchesEveryone(), InspIRCd::NickMatchesEveryone(), Read(), and ConfigReader::ReadFlag().

int ServerConfig::ConfValueEnum ConfigDataHash target,
const std::string tag
 

Returns the number of occurences of tag in the config file.

Definition at line 1931 of file configreader.cpp.

int ServerConfig::ConfValueEnum ConfigDataHash target,
const char *  tag
 

Returns the number of occurences of tag in the config file.

Definition at line 1926 of file configreader.cpp.

Referenced by CheckOnce(), ConfigReader::Enumerate(), ModuleManager::LoadAll(), and Read().

bool ServerConfig::ConfValueInteger ConfigDataHash target,
const std::string tag,
const std::string var,
const std::string default_value,
int  index,
int &  result
 

Tries to convert the value to an integer and write it to 'result'.

Definition at line 1854 of file configreader.cpp.

References ConfValue().

bool ServerConfig::ConfValueInteger ConfigDataHash target,
const std::string tag,
const std::string var,
int  index,
int &  result
 

Tries to convert the value to an integer and write it to 'result'.

Definition at line 1849 of file configreader.cpp.

References ConfValueInteger().

bool ServerConfig::ConfValueInteger ConfigDataHash target,
const char *  tag,
const char *  var,
const char *  default_value,
int  index,
int &  result
 

Tries to convert the value to an integer and write it to 'result'.

Definition at line 1844 of file configreader.cpp.

References ConfValueInteger().

bool ServerConfig::ConfValueInteger ConfigDataHash target,
const char *  tag,
const char *  var,
int  index,
int &  result
 

Tries to convert the value to an integer and write it to 'result'.

Definition at line 1839 of file configreader.cpp.

Referenced by ConfValueInteger(), Read(), and ConfigReader::ReadInteger().

int ServerConfig::ConfVarEnum ConfigDataHash target,
const std::string tag,
int  index
 

Returns the numbers of vars inside the index'th 'tag in the config file.

Definition at line 1941 of file configreader.cpp.

int ServerConfig::ConfVarEnum ConfigDataHash target,
const char *  tag,
int  index
 

Returns the numbers of vars inside the index'th 'tag in the config file.

Definition at line 1936 of file configreader.cpp.

Referenced by ConfigReader::EnumerateValues().

bool ServerConfig::DirValid const char *  dirandfile  )  [static]
 

Returns true if a directory is valid (within the modules directory).

Parameters:
dirandfile The directory and filename to check
Returns:
True if the directory is valid

Definition at line 2041 of file configreader.cpp.

References strlcpy().

Referenced by ModuleManager::Load().

int ServerConfig::DoDownloads  ) 
 

Not used any more as it is named, can probably be removed or renamed.

bool ServerConfig::DoInclude ConfigDataHash target,
const std::string file,