The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download | Blog | Stats
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 Member Functions

InspIRCdGetInstance ()
 ServerConfig (InspIRCd *Instance)
 Construct a new ServerConfig.
void ClearStack ()
 Clears the include stack in preperation for a Read() call.
void Update005 ()
 Update the 005 vector.
void Send005 (userrec *user)
 Send the 005 numerics (ISUPPORT) to a user.
void Read (bool bail, userrec *user)
 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.
void ReportConfigError (const std::string &errormessage, bool bail, userrec *user)
 Report a configuration error given in errormessage.
bool LoadConf (ConfigDataHash &target, 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, 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.
ModuleGetIOHook (int port)
 Get a pointer to the module which has hooked the given port.
bool AddIOHook (int port, Module *iomod)
 Hook a module to a client port, so that it can receive notifications of low-level port activity.
bool DelIOHook (int port)
 Delete a module hook from a client port.
ModuleGetIOHook (InspSocket *is)
 Get a pointer to the module which has hooked the given InspSocket class.
bool AddIOHook (Module *iomod, InspSocket *is)
 Hook a module to an InspSocket class, so that it can receive notifications of low-level socket activity.
bool DelIOHook (InspSocket *is)
 Delete a module hook from an InspSocket.
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

ConfigDataHash config_data
 This holds all the information in the config file, it's indexed by tag name to a vector of key/values.
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 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 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 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.
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 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 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 LogLevel
 The loglevel in use by the IRC server.
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.
bool 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< std::stringmodule_names
 A list of module names (names only, no paths) which are currently loaded by the server.
std::vector< ListenSocket * > ports
 A list of the classes for listening client ports.
char implement_lists [255][255]
 Boolean sets of which modules implement which functions.
char global_implementation [255]
 Global implementation list.
std::map< int, Module * > IOHookModule
 A list of ports claimed by IO Modules.
std::map< InspSocket *, Module * > SocketIOHookModule
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.

Private Member Functions

bool ParseLine (ConfigDataHash &target, 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 DoInclude (ConfigDataHash &target, const std::string &file, std::ostringstream &errorstream)
 Process an include directive.
bool CheckOnce (char *tag, bool bail, userrec *user)
 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 212 of file configreader.h.


Constructor & Destructor Documentation

ServerConfig::ServerConfig InspIRCd Instance  ) 
 

Construct a new ServerConfig.

Definition at line 24 of file configreader.cpp.

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

00024                                              : ServerInstance(Instance)
00025 {
00026         this->ClearStack();
00027         *ServerName = *Network = *ServerDesc = *AdminName = '\0';
00028         *HideWhoisServer = *AdminEmail = *AdminNick = *diepass = *restartpass = *FixedQuit = *HideKillsServer = '\0';
00029         *DefaultModes = *CustomVersion = *motd = *rules = *PrefixQuit = *DieValue = *DNSServer = '\0';
00030         *UserStats = *ModPath = *MyExecutable = *DisabledCommands = *PID = *SuffixQuit = '\0';
00031         WhoWasGroupSize = WhoWasMaxGroups = WhoWasMaxKeep = 0;
00032         log_file = NULL;
00033         NoUserDns = forcedebug = OperSpyWhois = nofork = HideBans = HideSplits = UndernetMsgPrefix = false;
00034         CycleHosts = writelog = AllowHalfop = true;
00035         dns_timeout = DieDelay = 5;
00036         MaxTargets = 20;
00037         NetBufferSize = 10240;
00038         SoftLimit = MAXCLIENTS;
00039         MaxConn = SOMAXCONN;
00040         MaxWhoResults = 0;
00041         debugging = 0;
00042         MaxChans = 20;
00043         OperMaxChans = 30;
00044         LogLevel = DEFAULT;
00045         maxbans.clear();
00046 }


Member Function Documentation

bool ServerConfig::AddIOHook Module iomod,
InspSocket is
 

Hook a module to an InspSocket class, so that it can receive notifications of low-level socket activity.

Parameters:
iomod The module to hook to the socket
is The InspSocket to attach to
Returns:
True if the hook was successful.

Definition at line 79 of file configreader.cpp.

References GetIOHook(), InspSocket::IsIOHooked, and SocketIOHookModule.

00080 {
00081         if (!GetIOHook(is))
00082         {
00083                 SocketIOHookModule[is] = iomod;
00084                 is->IsIOHooked = true;
00085                 return true;
00086         }
00087         else
00088         {
00089                 throw ModuleException("InspSocket derived class already hooked by another module");
00090                 return false;
00091         }
00092 }

bool ServerConfig::AddIOHook int  port,
Module iomod
 

Hook a module to a client port, so that it can receive notifications of low-level port activity.

Parameters:
port The port number
Module the module to hook to the port
Returns:
True if the hook was successful.

Definition at line 65 of file configreader.cpp.

References GetIOHook(), and IOHookModule.

Referenced by ModuleXMLSocket::OnRehash(), ModuleSSLOpenSSL::OnRehash(), ModuleSSLGnuTLS::OnRehash(), ModuleZLib::OnRequest(), ModuleSSLOpenSSL::OnRequest(), and ModuleSSLGnuTLS::OnRequest().

00066 {
00067         if (!GetIOHook(port))
00068         {
00069                 IOHookModule[port] = iomod;
00070                 return true;
00071         }
00072         else
00073         {
00074                 throw ModuleException("Port already hooked by another module");
00075                 return false;
00076         }
00077 }

bool ServerConfig::CheckOnce char *  tag,
bool  bail,
userrec user
[private]
 

Check that there is only one of each configuration item.

Definition at line 150 of file configreader.cpp.

References ConfValueEnum().

Referenced by Read().

00151 {
00152         int count = ConfValueEnum(this->config_data, tag);
00153 
00154         if (count > 1)
00155         {
00156                 throw CoreException("You have more than one <"+std::string(tag)+"> tag, this is not permitted.");
00157                 return false;
00158         }
00159         if (count < 1)
00160         {
00161                 throw CoreException("You have not defined a <"+std::string(tag)+"> tag, this is required.");
00162                 return false;
00163         }
00164         return true;
00165 }

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 1560 of file configreader.cpp.

Referenced by cmd_rehash::Handle(), cmd_modules::Handle(), TreeSocket::Modules(), and InspIRCd::Rehash().

01561 {
01562         char* p = name + strlen(name);
01563         while ((p != name) && (*p != '/') && (*p != '\\')) p--;
01564         return (p != name ? ++p : p);
01565 }

void ServerConfig::ClearStack  ) 
 

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

Definition at line 48 of file configreader.cpp.

References include_stack.

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

00049 {
00050         include_stack.clear();
00051 }

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 1321 of file configreader.cpp.

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

01322 {
01323         ConfigDataHash::size_type pos = index;
01324         if((pos >= 0) && (pos < target.count(tag)))
01325         {
01326                 ConfigDataHash::iterator iter = target.find(tag);
01327 
01328                 for(int i = 0; i < index; i++)
01329                         iter++;
01330 
01331                 for(KeyValList::iterator j = iter->second.begin(); j != iter->second.end(); j++)
01332                 {
01333                         if(j->first == var)
01334                         {
01335                                 if ((!allow_linefeeds) && (j->second.find('\n') != std::string::npos))
01336                                 {
01337                                         ServerInstance->Log(DEFAULT, "Value of <" + tag + ":" + var+ "> contains a linefeed, and linefeeds in this value are not permitted -- stripped to spaces.");
01338                                         for (std::string::iterator n = j->second.begin(); n != j->second.end(); n++)
01339                                                 if (*n == '\n')
01340                                                         *n = ' ';
01341                                 }
01342                                 else
01343                                 {
01344                                         result = j->second;
01345                                         return true;
01346                                 }
01347                         }
01348                 }
01349                 if (!default_value.empty())
01350                 {
01351                         result = default_value;
01352                         return true;
01353                 }
01354         }
01355         else if(pos == 0)
01356         {
01357                 if (!default_value.empty())
01358                 {
01359                         result = default_value;
01360                         return true;
01361                 }
01362         }
01363         return false;
01364 }

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 1316 of file configreader.cpp.

References ConfValue().

01317 {
01318         return ConfValue(target, tag, var, "", index, result, allow_linefeeds);
01319 }

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 1308 of file configreader.cpp.

References ConfValue(), and strlcpy().

01309 {
01310         std::string value;
01311         bool r = ConfValue(target, std::string(tag), std::string(var), std::string(default_value), index, value, allow_linefeeds);
01312         strlcpy(result, value.c_str(), length);
01313         return r;
01314 }

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 1303 of file configreader.cpp.

Referenced by InspIRCd::BindPorts(), ConfValue(), ConfValueBool(), ConfValueInteger(), DoStats(), cmd_oper::Handle(), InspIRCd::HostMatchesEveryone(), InspIRCd::IPMatchesEveryone(), InspIRCd::LoadAllModules(), InspIRCd::NickMatchesEveryone(), Read(), and ConfigReader::ReadValue().

01304 {
01305         return ConfValue(target, tag, var, "", index, result, length, allow_linefeeds);
01306 }

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 1444 of file configreader.cpp.

References ConfValue().

01445 {
01446         std::string result;
01447         if(!ConfValue(target, tag, var, default_value, index, result))
01448                 return false;
01449 
01450         return ((result == "yes") || (result == "true") || (result == "1"));
01451 }

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 1439 of file configreader.cpp.

References ConfValueBool().

01440 {
01441         return ConfValueBool(target, tag, var, "", index);
01442 }

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 1434 of file configreader.cpp.

References ConfValueBool().

01435 {
01436         return ConfValueBool(target, std::string(tag), std::string(var), std::string(default_value), index);
01437 }

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 1429 of file configreader.cpp.

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

01430 {
01431         return ConfValueBool(target, std::string(tag), std::string(var), "", index);
01432 }

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

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

Definition at line 1458 of file configreader.cpp.

01459 {
01460         return target.count(tag);
01461 }

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

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

Definition at line 1453 of file configreader.cpp.

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

01454 {
01455         return target.count(tag);
01456 }

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 1381 of file configreader.cpp.

References ConfValue().

01382 {
01383         std::string value;
01384         std::istringstream stream;
01385         bool r = ConfValue(target, tag, var, default_value, index, value);
01386         stream.str(value);
01387         if(!(stream >> result))
01388                 return false;
01389         else
01390         {
01391                 if (!value.empty())
01392                 {
01393                         if (value.substr(0,2) == "0x")
01394                         {
01395                                 char* endptr;
01396 
01397                                 value.erase(0,2);
01398                                 result = strtol(value.c_str(), &endptr, 16);
01399 
01400                                 /* No digits found */
01401                                 if (endptr == value.c_str())
01402                                         return false;
01403                         }
01404                         else
01405                         {
01406                                 char denominator = *(value.end() - 1);
01407                                 switch (toupper(denominator))
01408                                 {
01409                                         case 'K':
01410                                                 /* Kilobytes -> bytes */
01411                                                 result = result * 1024;
01412                                         break;
01413                                         case 'M':
01414                                                 /* Megabytes -> bytes */
01415                                                 result = result * 1024 * 1024;
01416                                         break;
01417                                         case 'G':
01418                                                 /* Gigabytes -> bytes */
01419                                                 result = result * 1024 * 1024 * 1024;
01420                                         break;
01421                                 }
01422                         }
01423                 }
01424         }
01425         return r;
01426 }

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 1376 of file configreader.cpp.

References ConfValueInteger().

01377 {
01378         return ConfValueInteger(target, tag, var, "", index, result);
01379 }

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 1371 of file configreader.cpp.

References ConfValueInteger().

01372 {
01373         return ConfValueInteger(target, std::string(tag), std::string(var), std::string(default_value), index, result);
01374 }

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 1366 of file configreader.cpp.

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

01367 {
01368         return ConfValueInteger(target, std::string(tag), std::string(var), "", index, result);
01369 }

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 1468 of file configreader.cpp.

01469 {
01470         ConfigDataHash::size_type pos = index;
01471 
01472         if((pos >= 0) && (pos < target.count(tag)))
01473         {
01474                 ConfigDataHash::const_iterator iter = target.find(tag);
01475 
01476                 for(int i = 0; i < index; i++)
01477                         iter++;
01478 
01479                 return iter->second.size();
01480         }
01481 
01482         return 0;
01483 }

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 1463 of file configreader.cpp.

Referenced by ConfigReader::EnumerateValues().

01464 {
01465         return ConfVarEnum(target, std::string(tag), index);
01466 }

bool ServerConfig::DelIOHook InspSocket is  ) 
 

Delete a module hook from an InspSocket.

Parameters:
is The InspSocket to detatch from.
Returns:
True if the unhook was successful

Definition at line 105 of file configreader.cpp.

References SocketIOHookModule.

00106 {
00107         std::map<InspSocket*,Module*>::iterator x = SocketIOHookModule.find(is);
00108         if (x != SocketIOHookModule.end())
00109         {
00110                 SocketIOHookModule.erase(x);
00111                 return true;
00112         }
00113         return false;
00114 }

bool ServerConfig::DelIOHook int  port  ) 
 

Delete a module hook from a client port.

Parameters:
port The port to detatch from
Returns:
True if successful

Definition at line 94 of file configreader.cpp.

References IOHookModule.

Referenced by ModuleXMLSocket::OnRehash(), ModuleSSLOpenSSL::OnRehash(), ModuleSSLGnuTLS::OnRehash(), ModuleZLib::OnRequest(), ModuleSSLOpenSSL::OnRequest(), ModuleSSLGnuTLS::OnRequest(), ModuleXMLSocket::OnUnloadModule(), ModuleSSLOpenSSL::OnUnloadModule(), and ModuleSSLGnuTLS::OnUnloadModule().

00095 {
00096         std::map<int,Module*>::iterator x = IOHookModule.find(port);
00097         if (x != IOHookModule.end())
00098         {
00099                 IOHookModule.erase(x);
00100                 return true;
00101         }
00102         return false;
00103 }

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 1568 of file configreader.cpp.

References strlcpy().

Referenced by InspIRCd::LoadModule().

01569 {
01570 #ifdef WINDOWS
01571         return true;
01572 #endif
01573 
01574         char work[1024];
01575         char buffer[1024];
01576         char otherdir[1024];
01577         int p;
01578 
01579         strlcpy(work, dirandfile, 1024);
01580         p = strlen(work);
01581 
01582         // we just want the dir
01583         while (*work)
01584         {
01585                 if (work[p] == '/')
01586                 {
01587                         work[p] = '\0';
01588                         break;
01589                 }
01590 
01591                 work[p--] = '\0';
01592         }
01593 
01594         // Get the current working directory
01595         if (getcwd(buffer, 1024 ) == NULL )
01596                 return false;
01597 
01598         if (chdir(work) == -1)
01599                 return false;
01600 
01601         if (getcwd(otherdir, 1024 ) == NULL )
01602                 return false;
01603 
01604         if (chdir(buffer) == -1)
01605                 return false;
01606 
01607         size_t t = strlen(work);
01608 
01609         if (strlen(otherdir) >= t)
01610         {
01611                 otherdir[t] = '\0';
01612                 if (!strcmp(otherdir,work))
01613                 {
01614                         return true;
01615                 }
01616 
01617                 return false;
01618         }
01619         else
01620         {
01621                 return false;
01622         }
01623 }

bool ServerConfig::DoInclude ConfigDataHash target,
const std::string file,
std::ostringstream &  errorstream
[private]
 

Process an include directive.

Definition at line 1274 of file configreader.cpp.

References InspIRCd::ConfigFileName, LoadConf(), and ServerInstance.

01275 {
01276         std::string confpath;
01277         std::string newfile;
01278         std::string::size_type pos;
01279 
01280         confpath = ServerInstance->ConfigFileName;
01281         newfile = file;
01282 
01283         std::replace(newfile.begin(),newfile.end(),'\\','/');
01284         std::replace(confpath.begin(),confpath.end(),'\\','/');
01285 
01286         if (newfile[0] != '/')
01287         {
01288                 if((pos = confpath.rfind("/")) != std::string::npos)
01289                 {
01290                         /* Leaves us with just the path */
01291                         newfile = confpath.substr(0, pos) + std::string("/") + newfile;
01292                 }
01293                 else
01294                 {
01295                         errorstream << "Couldn't get config path from: " << ServerInstance->ConfigFileName << std::endl;
01296                         return false;
01297                 }
01298         }
01299 
01300         return LoadConf(target, newfile, errorstream);
01301 }

bool ServerConfig::FileExists const char *  file  )  [static]
 

Check if a file exists.

Parameters:
file The full path to a file
Returns:
True if the file exists and is readable.

Definition at line 1541 of file configreader.cpp.

Referenced by InspIRCd::InspIRCd(), InspIRCd::LoadModule(), and ReadFile().

01542 {
01543         struct stat sb;
01544         if (stat(file, &sb) == -1)
01545                 return false;
01546 
01547         if ((sb.st_mode & S_IFDIR) > 0)
01548                 return false;
01549              
01550         FILE *input;
01551         if ((input = fopen (file, "r")) == NULL)
01552                 return false;
01553         else
01554         {
01555                 fclose(input);
01556                 return true;
01557         }
01558 }

std::string ServerConfig::GetFullProgDir  ) 
 

Returns the fully qualified path to the inspircd directory.

Returns:
The full program directory

Definition at line 1625 of file configreader.cpp.

References argv, and PATH_MAX.

Referenced by InspIRCd::InspIRCd(), and InspIRCd::OpenLog().

01626 {
01627         char buffer[PATH_MAX+1];
01628 #ifdef WINDOWS
01629         /* Windows has specific api calls to get the exe path that never fail.
01630          * For once, windows has something of use, compared to the POSIX code
01631          * for this, this is positively neato.
01632          */
01633         if (GetModuleFileName(NULL, buffer, MAX_PATH))
01634         {
01635                 std::string fullpath = buffer;
01636                 std::string::size_type n = fullpath.rfind("\\inspircd.exe");
01637                 return std::string(fullpath, 0, n);
01638         }
01639 #else
01640         // Get the current working directory
01641         if (getcwd(buffer, PATH_MAX))
01642         {
01643                 std::string remainder = this->argv[0];
01644 
01645                 /* Does argv[0] start with /? its a full path, use it */
01646                 if (remainder[0] == '/')
01647                 {
01648                         std::string::size_type n = remainder.rfind("/inspircd");
01649                         return std::string(remainder, 0, n);
01650                 }
01651 
01652                 std::string fullpath = std::string(buffer) + "/" + remainder;
01653                 std::string::size_type n = fullpath.rfind("/inspircd");
01654                 return std::string(fullpath, 0, n);
01655         }
01656 #endif
01657         return "/";
01658 }

InspIRCd * ServerConfig::GetInstance  ) 
 

Definition at line 1660 of file configreader.cpp.

References ServerInstance.

Referenced by DoELine(), DoKLine(), DoneKLine(), DoneQLine(), DoneZLine(), DoQLine(), DoZLine(), InitConnect(), ValidateDnsServer(), ValidateMaxConn(), ValidateMaxTargets(), ValidateMaxWho(), ValidateNetBufferSize(), ValidateServerName(), ValidateSoftLimit(), and ValidateWhoWas().

01661 {
01662         return ServerInstance;
01663 }

Module * ServerConfig::GetIOHook InspSocket is  ) 
 

Get a pointer to the module which has hooked the given InspSocket class.

port Port number

Returns:
Returns a pointer to the hooking module, or NULL

Definition at line 59 of file configreader.cpp.

References SocketIOHookModule.

00060 {
00061         std::map<InspSocket*,Module*>::iterator x = SocketIOHookModule.find(is);
00062         return (x != SocketIOHookModule.end() ? x->second : NULL);
00063 }

Module * ServerConfig::GetIOHook int  port  ) 
 

Get a pointer to the module which has hooked the given port.

port Port number

Returns:
Returns a pointer to the hooking module, or NULL

Definition at line 53 of file configreader.cpp.

References IOHookModule.

Referenced by AddIOHook(), CullList::Apply(), InspSocket::Close(), InspSocket::FlushWriteBuffer(), ListenSocket::HandleEvent(), InspSocket::Poll(), InspIRCd::ProcessUser(), InspSocket::Read(), and userrec::Write().

00054 {
00055         std::map<int,Module*>::iterator x = IOHookModule.find(port);
00056         return (x != IOHookModule.end() ? x->second : NULL);
00057 }

bool ServerConfig::LoadConf ConfigDataHash target,
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.

Definition at line 1145 of file configreader.cpp.

References LoadConf().

01146 {
01147         return this->LoadConf(target, filename.c_str(), errorstream);
01148 }

bool ServerConfig::LoadConf ConfigDataHash target,
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.

Definition at line 944 of file configreader.cpp.

References conf, and include_stack.

Referenced by ConfigReader::ConfigReader(), DoInclude(), and LoadConf().

00945 {
00946         std::ifstream conf(filename);
00947         std::string line;
00948         char ch;
00949         long linenumber;
00950         bool in_tag;
00951         bool in_quote;
00952         bool in_comment;
00953         int character_count = 0;
00954 
00955         linenumber = 1;
00956         in_tag = false;
00957         in_quote = false;
00958         in_comment = false;
00959 
00960         /* Check if the file open failed first */
00961         if (!conf)
00962         {
00963                 errorstream << "LoadConf: Couldn't open config file: " << filename << std::endl;
00964                 return false;
00965         }
00966 
00967         for (unsigned int t = 0; t < include_stack.size(); t++)
00968         {
00969                 if (std::string(filename) == include_stack[t])
00970                 {
00971                         errorstream << "File " << filename << " is included recursively (looped inclusion)." << std::endl;
00972                         return false;
00973                 }
00974         }
00975 
00976         /* It's not already included, add it to the list of files we've loaded */
00977         include_stack.push_back(filename);
00978 
00979         /* Start reading characters... */
00980         while (conf.get(ch))
00981         {
00982 
00983                 /*
00984                  * Fix for moronic windows issue spotted by Adremelech.
00985                  * Some windows editors save text files as utf-16, which is
00986                  * a total pain in the ass to parse. Users should save in the
00987                  * right config format! If we ever see a file where the first
00988                  * byte is 0xFF or 0xFE, or the second is 0xFF or 0xFE, then
00989                  * this is most likely a utf-16 file. Bail out and insult user.
00990                  */
00991                 if ((character_count++ < 2) && (ch == '\xFF' || ch == '\xFE'))
00992                 {
00993                         errorstream << "File " << filename << " cannot be read, as it is encoded in braindead UTF-16. Save your file as plain ASCII!" << std::endl;
00994                         return false;
00995                 }
00996 
00997                 /*
00998                  * Here we try and get individual tags on separate lines,
00999                  * this would be so easy if we just made people format
01000                  * their config files like that, but they don't so...
01001                  * We check for a '<' and then know the line is over when
01002                  * we get a '>' not inside quotes. If we find two '<' and
01003                  * no '>' then die with an error.
01004                  */
01005 
01006                 if ((ch == '#') && !in_quote)
01007                         in_comment = true;
01008 
01009                 switch (ch)
01010                 {
01011                         case '\n':
01012                                 if (in_quote)
01013                                         line += '\n';
01014                                 linenumber++;
01015                         case '\r':
01016                                 if (!in_quote)
01017                                         in_comment = false;
01018                         case '\0':
01019                                 continue;
01020                         case '\t':
01021                                 ch = ' ';
01022                 }
01023 
01024                 if(in_comment)
01025                         continue;
01026 
01027                 /* XXX: Added by Brain, May 1st 2006 - Escaping of characters.
01028                  * Note that this WILL NOT usually allow insertion of newlines,
01029                  * because a newline is two characters long. Use it primarily to
01030                  * insert the " symbol.
01031                  *
01032                  * Note that this also involves a further check when parsing the line,
01033                  * which can be found below.
01034                  */
01035                 if ((ch == '\\') && (in_quote) && (in_tag))
01036                 {
01037                         line += ch;
01038                         char real_character;
01039                         if (conf.get(real_character))
01040                         {
01041                                 if (real_character == 'n')
01042                                         real_character = '\n';
01043                                 line += real_character;
01044                                 continue;
01045                         }
01046                         else
01047                         {
01048                                 errorstream << "End of file after a \\, what did you want to escape?: " << filename << ":" << linenumber << std::endl;
01049                                 return false;
01050                         }
01051                 }
01052 
01053                 if (ch != '\r')
01054                         line += ch;
01055 
01056                 if (ch == '<')
01057                 {
01058                         if (in_tag)
01059                         {
01060                                 if (!in_quote)
01061                                 {
01062                                         errorstream << "Got another opening < when the first one wasn't closed: " << filename << ":" << linenumber << std::endl;
01063                                         return false;
01064                                 }
01065                         }
01066                         else
01067                         {
01068                                 if (in_quote)
01069                                 {
01070                                         errorstream << "We're in a quote but outside a tag, interesting. " << filename << ":" << linenumber << std::endl;
01071                                         return false;
01072                                 }
01073                                 else
01074                                 {
01075                                         // errorstream << "Opening new config tag on line " << linenumber << std::endl;
01076                                         in_tag = true;
01077                                 }
01078                         }
01079                 }
01080                 else if (ch == '"')
01081                 {
01082                         if (in_tag)
01083                         {
01084                                 if (in_quote)
01085                                 {
01086                                         // errorstream << "Closing quote in config tag on line " << linenumber << std::endl;
01087                                         in_quote = false;
01088                                 }
01089                                 else
01090                                 {
01091                                         // errorstream << "Opening quote in config tag on line " << linenumber << std::endl;
01092                                         in_quote = true;
01093                                 }
01094                         }
01095                         else
01096                         {
01097                                 if (in_quote)
01098                                 {
01099                                         errorstream << "Found a (closing) \" outside a tag: " << filename << ":" << linenumber << std::endl;
01100                                 }
01101                                 else
01102                                 {
01103                                         errorstream << "Found a (opening) \" outside a tag: " << filename << ":" << linenumber << std::endl;
01104                                 }
01105                         }
01106                 }
01107                 else if (ch == '>')
01108                 {
01109                         if (!in_quote)
01110                         {
01111                                 if (in_tag)
01112                                 {
01113                                         // errorstream << "Closing config tag on line " << linenumber << std::endl;
01114                                         in_tag = false;
01115 
01116                                         /*
01117                                          * If this finds an <include> then ParseLine can simply call
01118                                          * LoadConf() and load the included config into the same ConfigDataHash
01119                                          */
01120 
01121                                         if (!this->ParseLine(target, line, linenumber, errorstream))
01122                                                 return false;
01123 
01124                                         line.clear();
01125                                 }
01126                                 else
01127                                 {
01128                                         errorstream << "Got a closing > when we weren't inside a tag: " << filename << ":" << linenumber << std::endl;
01129                                         return false;
01130                                 }
01131                         }
01132                 }
01133         }
01134 
01135         /* Fix for bug #392 - if we reach the end of a file and we are still in a quote or comment, most likely the user fucked up */
01136         if (in_comment || in_quote)
01137         {
01138                 errorstream << "Reached end of file whilst still inside a quoted section or tag. This is most likely an error or there \
01139                         is a newline missing from the end of the file: " << filename << ":" << linenumber << std::endl;
01140         }
01141 
01142         return true;
01143 }

bool ServerConfig::ParseLine ConfigDataHash target,
std::string line,
long &  linenumber,
std::ostringstream &  errorstream
[private]
 

This private method processes one line of configutation, appending errors to errorstream and setting error if an error has occured.

Definition at line 1150 of file configreader.cpp.

01151 {
01152         std::string tagname;
01153         std::string current_key;
01154         std::string current_value;
01155         KeyValList results;
01156         bool got_name;
01157         bool got_key;
01158         bool in_quote;
01159 
01160         got_name = got_key = in_quote = false;
01161 
01162         for(std::string::iterator c = line.begin(); c != line.end(); c++)
01163         {
01164                 if (!got_name)
01165                 {
01166                         /* We don't know the tag name yet. */
01167 
01168                         if (*c != ' ')
01169                         {
01170                                 if (*c != '<')
01171                                 {
01172                                         tagname += *c;
01173                                 }
01174                         }
01175                         else
01176                         {
01177                                 /* We got to a space, we should have the tagname now. */
01178                                 if(tagname.length())
01179                                 {
01180                                         got_name = true;
01181                                 }
01182                         }
01183                 }
01184                 else
01185                 {
01186                         /* We have the tag name */
01187                         if (!got_key)
01188                         {
01189                                 /* We're still reading the key name */
01190                                 if (*c != '=')
01191                                 {
01192                                         if (*c != ' ')
01193                                         {
01194                                                 current_key += *c;
01195                                         }
01196                                 }
01197                                 else
01198                                 {
01199                                         /* We got an '=', end of the key name. */
01200                                         got_key = true;
01201                                 }
01202                         }
01203                         else
01204                         {
01205                                 /* We have the key name, now we're looking for quotes and the value */
01206 
01207                                 /* Correctly handle escaped characters here.
01208                                  * See the XXX'ed section above.
01209                                  */
01210                                 if ((*c == '\\') && (in_quote))
01211                                 {
01212                                         c++;
01213                                         if (*c == 'n')
01214                                                 current_value += '\n';
01215                                         else
01216                                                 current_value += *c;
01217                                         continue;
01218                                 }
01219                                 else if ((*c == '\n') && (in_quote))
01220                                 {
01221                                         /* Got a 'real' \n, treat it as part of the value */
01222                                         current_value += '\n';
01223                                         linenumber++;
01224                                         continue;
01225                                 }
01226                                 else if ((*c == '\r') && (in_quote))
01227                                         /* Got a \r, drop it */
01228                                         continue;
01229 
01230                                 if (*c == '"')
01231                                 {
01232                                         if (!in_quote)
01233                                         {
01234                                                 /* We're not already in a quote. */
01235                                                 in_quote = true;
01236                                         }
01237                                         else
01238                                         {
01239                                                 /* Leaving quotes, we have the value */
01240                                                 results.push_back(KeyVal(current_key, current_value));
01241 
01242                                                 // std::cout << "<" << tagname << ":" << current_key << "> " << current_value << std::endl;
01243 
01244                                                 in_quote = false;
01245                                                 got_key = false;
01246 
01247                                                 if ((tagname == "include") && (current_key == "file"))
01248                                                 {
01249                                                         if (!this->DoInclude(target, current_value, errorstream))
01250                                                                 return false;
01251                                                 }
01252 
01253                                                 current_key.clear();
01254                                                 current_value.clear();
01255                                         }
01256                                 }
01257                                 else
01258                                 {
01259                                         if (in_quote)
01260                                         {
01261                                                 current_value += *c;
01262                                         }
01263                                 }
01264                         }
01265                 }
01266         }
01267 
01268         /* Finished parsing the tag, add it to the config hash */
01269         target.insert(std::pair<std::string, KeyValList > (tagname, results));
01270 
01271         return true;
01272 }

void ServerConfig::Read bool  bail,
userrec user
 

Read the entire configuration into memory and initialize this class.

All other methods should be used only by the core.

Definition at line 591 of file configreader.cpp.

References added_modules, InspIRCd::BindPorts(), CheckOnce(), config_data, InspIRCd::ConfigFileName, ConfValue(), ConfValueBool(), ConfValueEnum(), ConfValueInteger(), MultiConfig::datatype, InitialConfig::datatype, DEFAULT, InitialConfig::default_value, DoClass(), DoConnect(), DoELine(), DoKLine(), DoMaxBans(), DoModule(), DoneClassesAndTypes(), DoneConnect(), DoneELine(), DoneKLine(), DoneMaxBans(), DoneModule(), DoneQLine(), DoneULine(), DoneZLine(), DoQLine(), DoType(), DoULine(), DoZLine(), DT_ALLOW_NEWLINE, DT_BOOLEAN, DT_CHARPTR, DT_INTEGER, MultiConfig::finish_function, ValueItem::GetBool(), ValueItem::GetInteger(), CoreException::GetReason(), ValueItem::GetString(), include_stack, MultiConfig::init_function, InitClasses(), InitConnect(), InitMaxBans(), InitModule(), InitTypes(), InitULine(), InitXLine(), MultiConfig::items, MultiConfig::items_default, InspIRCd::LoadModule(), InspIRCd::Log(), MAXBUF, MAXCLIENTS_S, MOD_PATH, InspIRCd::ModuleError(), userrec::nick, NoValidation(), removed_modules, ReportConfigError(), ServerInstance, ValueContainer< T >::Set(), SOMAXCONN_S, MultiConfig::tag, InitialConfig::tag, InspIRCd::UnloadModule(), InitialConfig::val, ValidateDnsServer(), ValidateExemptChanOps(), ValidateLogLevel(), ValidateMaxConn(), ValidateMaxTargets(), ValidateMaxWho(), ValidateModeLists(), ValidateMotd(), ValidateNetBufferSize(), ValidateNotEmpty(), ValidateRules(), ValidateServerName(), ValidateSoftLimit(), ValidateWhoWas(), MultiConfig::validation_function, InitialConfig::value, InspIRCd::WriteOpers(), InspIRCd::WritePID(), and userrec::WriteServ().

Referenced by cmd_rehash::Handle(), InspIRCd::InspIRCd(), InspIRCd::Rehash(), and InspIRCd::RehashServer().

00592 {
00593         static char debug[MAXBUF];      /* Temporary buffer for debugging value */
00594         static char maxkeep[MAXBUF];    /* Temporary buffer for WhoWasMaxKeep value */
00595         static char hidemodes[MAXBUF];  /* Modes to not allow listing from users below halfop */
00596         static char exemptchanops[MAXBUF];      /* Exempt channel ops from these modes */
00597         int rem = 0, add = 0;           /* Number of modules added, number of modules removed */
00598         std::ostringstream errstr;      /* String stream containing the error output */
00599 
00600         /* These tags MUST occur and must ONLY occur once in the config file */
00601         static char* Once[] = { "server", "admin", "files", "power", "options", NULL };
00602 
00603         /* These tags can occur ONCE or not at all */
00604         InitialConfig Values[] = {
00605                 {"options",     "softlimit",    MAXCLIENTS_S,           new ValueContainerUInt (&this->SoftLimit),              DT_INTEGER, ValidateSoftLimit},
00606                 {"options",     "somaxconn",    SOMAXCONN_S,            new ValueContainerInt  (&this->MaxConn),                DT_INTEGER, ValidateMaxConn},
00607                 {"options",     "moronbanner",  "Youre banned!",        new ValueContainerChar (this->MoronBanner),             DT_CHARPTR, NoValidation},
00608                 {"server",      "name",         "",                     new ValueContainerChar (this->ServerName),              DT_CHARPTR, ValidateServerName},
00609                 {"server",      "description",  "Configure Me",         new ValueContainerChar (this->ServerDesc),              DT_CHARPTR, NoValidation},
00610                 {"server",      "network",      "Network",              new ValueContainerChar (this->Network),                 DT_CHARPTR, NoValidation},
00611                 {"admin",       "name",         "",                     new ValueContainerChar (this->AdminName),               DT_CHARPTR, NoValidation},
00612                 {"admin",       "email",        "Mis@configu.red",      new ValueContainerChar (this->AdminEmail),              DT_CHARPTR, NoValidation},
00613                 {"admin",       "nick",         "Misconfigured",        new ValueContainerChar (this->AdminNick),               DT_CHARPTR, NoValidation},
00614                 {"files",       "motd",         "",                     new ValueContainerChar (this->motd),                    DT_CHARPTR, ValidateMotd},
00615                 {"files",       "rules",        "",                     new ValueContainerChar (this->rules),                   DT_CHARPTR, ValidateRules},
00616                 {"power",       "diepass",      "",                     new ValueContainerChar (this->diepass),                 DT_CHARPTR, ValidateNotEmpty},
00617                 {"power",       "pause",        "",                     new ValueContainerInt  (&this->DieDelay),               DT_INTEGER, NoValidation},
00618                 {"power",       "restartpass",  "",                     new ValueContainerChar (this->restartpass),             DT_CHARPTR, ValidateNotEmpty},
00619                 {"options",     "prefixquit",   "",                     new ValueContainerChar (this->PrefixQuit),              DT_CHARPTR, NoValidation},
00620                 {"options",     "suffixquit",   "",                     new ValueContainerChar (this->SuffixQuit),              DT_CHARPTR, NoValidation},
00621                 {"options",     "fixedquit",    "",                     new ValueContainerChar (this->FixedQuit),               DT_CHARPTR, NoValidation},
00622                 {"options",     "loglevel",     "default",              new ValueContainerChar (debug),                         DT_CHARPTR, ValidateLogLevel},
00623                 {"options",     "netbuffersize","10240",                new ValueContainerInt  (&this->NetBufferSize),          DT_INTEGER, ValidateNetBufferSize},
00624                 {"options",     "maxwho",       "128",                  new ValueContainerInt  (&this->MaxWhoResults),          DT_INTEGER, ValidateMaxWho},
00625                 {"options",     "allowhalfop",  "0",                    new ValueContainerBool (&this->AllowHalfop),            DT_BOOLEAN, NoValidation},
00626                 {"dns",         "server",       "",                     new ValueContainerChar (this->DNSServer),               DT_CHARPTR, ValidateDnsServer},
00627                 {"dns",         "timeout",      "5",                    new ValueContainerInt  (&this->dns_timeout),            DT_INTEGER, NoValidation},
00628                 {"options",     "moduledir",    MOD_PATH,               new ValueContainerChar (this->ModPath),                 DT_CHARPTR, NoValidation},
00629                 {"disabled",    "commands",     "",                     new ValueContainerChar (this->DisabledCommands),        DT_CHARPTR, NoValidation},
00630                 {"options",     "userstats",    "",                     new ValueContainerChar (this->UserStats),               DT_CHARPTR, NoValidation},
00631                 {"options",     "customversion","",                     new ValueContainerChar (this->CustomVersion),           DT_CHARPTR, NoValidation},
00632                 {"options",     "hidesplits",   "0",                    new ValueContainerBool (&this->HideSplits),             DT_BOOLEAN, NoValidation},
00633                 {"options",     "hidebans",     "0",                    new ValueContainerBool (&this->HideBans),               DT_BOOLEAN, NoValidation},
00634                 {"options",     "hidewhois",    "",                     new ValueContainerChar (this->HideWhoisServer),         DT_CHARPTR, NoValidation},
00635                 {"options",     "hidekills",    "",                     new ValueContainerChar (this->HideKillsServer),         DT_CHARPTR, NoValidation},
00636                 {"options",     "operspywhois", "0",                    new ValueContainerBool (&this->OperSpyWhois),           DT_BOOLEAN, NoValidation},
00637                 {"options",     "nouserdns",    "0",                    new ValueContainerBool (&this->NoUserDns),              DT_BOOLEAN, NoValidation},
00638                 {"options",     "syntaxhints",  "0",                    new ValueContainerBool (&this->SyntaxHints),            DT_BOOLEAN, NoValidation},
00639                 {"options",     "cyclehosts",   "0",                    new ValueContainerBool (&this->CycleHosts),             DT_BOOLEAN, NoValidation},
00640                 {"options",     "ircumsgprefix","0",                    new ValueContainerBool (&this->UndernetMsgPrefix),      DT_BOOLEAN, NoValidation},
00641                 {"options",     "announceinvites", "1",                 new ValueContainerBool (&this->AnnounceInvites),        DT_BOOLEAN, NoValidation},
00642                 {"options",     "hostintopic",  "1",                    new ValueContainerBool (&this->FullHostInTopic),        DT_BOOLEAN, NoValidation},
00643                 {"options",     "hidemodes",    "",                     new ValueContainerChar (hidemodes),                     DT_CHARPTR, ValidateModeLists},
00644                 {"options",     "exemptchanops","",                     new ValueContainerChar (exemptchanops),                 DT_CHARPTR, ValidateExemptChanOps},
00645                 {"options",     "maxtargets",   "20",                   new ValueContainerUInt (&this->MaxTargets),             DT_INTEGER, ValidateMaxTargets},
00646                 {"options",     "defaultmodes", "nt",                   new ValueContainerChar (this->DefaultModes),            DT_CHARPTR, NoValidation},
00647                 {"pid",         "file",         "",                     new ValueContainerChar (this->PID),                     DT_CHARPTR, NoValidation},
00648                 {"whowas",      "groupsize",    "10",                   new ValueContainerInt  (&this->WhoWasGroupSize),        DT_INTEGER, NoValidation},
00649                 {"whowas",      "maxgroups",    "10240",                new ValueContainerInt  (&this->WhoWasMaxGroups),        DT_INTEGER, NoValidation},
00650                 {"whowas",      "maxkeep",      "3600",                 new ValueContainerChar (maxkeep),                       DT_CHARPTR, ValidateWhoWas},
00651                 {"die",         "value",        "",                     new ValueContainerChar (this->DieValue),                DT_CHARPTR, NoValidation},
00652                 {"channels",    "users",        "20",                   new ValueContainerUInt (&this->MaxChans),               DT_INTEGER, NoValidation},
00653                 {"channels",    "opers",        "60",                   new ValueContainerUInt (&this->OperMaxChans),           DT_INTEGER, NoValidation},
00654                 {NULL}
00655         };
00656 
00657         /* These tags can occur multiple times, and therefore they have special code to read them
00658          * which is different to the code for reading the singular tags listed above.
00659          */
00660         MultiConfig MultiValues[] = {
00661 
00662                 {"connect",
00663                                 {"allow",       "deny",         "password",     "timeout",      "pingfreq",     "flood",
00664                                 "threshold",    "sendq",        "recvq",        "localmax",     "globalmax",    "port",
00665                                 NULL},
00666                                 {"",            "",             "",             "",             "120",          "",
00667                                  "",            "",             "",             "3",            "3",            "0",
00668                                  NULL},
00669                                 {DT_CHARPTR,    DT_CHARPTR,     DT_CHARPTR,     DT_INTEGER,     DT_INTEGER,     DT_INTEGER,
00670                                  DT_INTEGER,    DT_INTEGER,     DT_INTEGER,     DT_INTEGER,     DT_INTEGER,     DT_INTEGER},
00671                                 InitConnect, DoConnect, DoneConnect},
00672 
00673                 {"uline",
00674                                 {"server",      "silent",       NULL},
00675                                 {"",            "0",            NULL},
00676                                 {DT_CHARPTR,    DT_BOOLEAN},
00677                                 InitULine,DoULine,DoneULine},
00678 
00679                 {"banlist",
00680                                 {"chan",        "limit",        NULL},
00681                                 {"",            "",             NULL},
00682                                 {DT_CHARPTR,    DT_INTEGER},
00683                                 InitMaxBans, DoMaxBans, DoneMaxBans},
00684 
00685                 {"module",
00686                                 {"name",        NULL},
00687                                 {"",            NULL},
00688                                 {DT_CHARPTR},
00689                                 InitModule, DoModule, DoneModule},
00690 
00691                 {"badip",
00692                                 {"reason",      "ipmask",       NULL},
00693                                 {"No reason",   "",             NULL},
00694                                 {DT_CHARPTR,    DT_CHARPTR},
00695                                 InitXLine, DoZLine, DoneZLine},
00696 
00697                 {"badnick",
00698                                 {"reason",      "nick",         NULL},
00699                                 {"No reason",   "",             NULL},
00700                                 {DT_CHARPTR,    DT_CHARPTR},
00701                                 InitXLine, DoQLine, DoneQLine},
00702 
00703                 {"badhost",
00704                                 {"reason",      "host",         NULL},
00705                                 {"No reason",   "",             NULL},
00706                                 {DT_CHARPTR,    DT_CHARPTR},
00707                                 InitXLine, DoKLine, DoneKLine},
00708 
00709                 {"exception",
00710                                 {"reason",      "host",         NULL},
00711                                 {"No reason",   "",             NULL},
00712                                 {DT_CHARPTR,    DT_CHARPTR},
00713                                 InitXLine, DoELine, DoneELine},
00714 
00715                 {"type",
00716                                 {"name",        "classes",      NULL},
00717                                 {"",            "",             NULL},
00718                                 {DT_CHARPTR,    DT_CHARPTR},
00719                                 InitTypes, DoType, DoneClassesAndTypes},
00720 
00721                 {"class",
00722                                 {"name",        "commands",     NULL},
00723                                 {"",            "",             NULL},
00724                                 {DT_CHARPTR,    DT_CHARPTR},
00725                                 InitClasses, DoClass, DoneClassesAndTypes},
00726 
00727                 {NULL}
00728         };
00729 
00730         include_stack.clear();
00731 
00732         /* Load and parse the config file, if there are any errors then explode */
00733 
00734         /* Make a copy here so if it fails then we can carry on running with an unaffected config */
00735         ConfigDataHash newconfig;
00736 
00737         if (this->LoadConf(newconfig, ServerInstance->ConfigFileName, errstr))
00738         {
00739                 /* If we succeeded, set the ircd config to the new one */
00740                 this->config_data = newconfig;
00741         }
00742         else
00743         {
00744                 ReportConfigError(errstr.str(), bail, user);
00745                 return;
00746         }
00747 
00748         /* The stuff in here may throw CoreException, be sure we're in a position to catch it. */
00749         try
00750         {
00751                 /* Check we dont have more than one of singular tags, or any of them missing
00752                  */
00753                 for (int Index = 0; Once[Index]; Index++)
00754                         if (!CheckOnce(Once[Index], bail, user))
00755                                 return;
00756 
00757                 /* Read the values of all the tags which occur once or not at all, and call their callbacks.
00758                  */
00759                 for (int Index = 0; Values[Index].tag; Index++)
00760                 {
00761                         char item[MAXBUF];
00762                         int dt = Values[Index].datatype;
00763                         bool allow_newlines =  ((dt & DT_ALLOW_NEWLINE) > 0);
00764                         dt &= ~DT_ALLOW_NEWLINE;
00765 
00766                         ConfValue(this->config_data, Values[Index].tag, Values[Index].value, Values[Index].default_value, 0, item, MAXBUF, allow_newlines);
00767                         ValueItem vi(item);
00768 
00769                         if (!Values[Index].validation_function(this, Values[Index].tag, Values[Index].value, vi))
00770                                 throw CoreException("One or more values in your configuration file failed to validate. Please see your ircd.log for more information.");
00771 
00772                         switch (dt)
00773                         {
00774                                 case DT_CHARPTR:
00775                                 {
00776                                         ValueContainerChar* vcc = (ValueContainerChar*)Values[Index].val;
00777                                         /* Make sure we also copy the null terminator */
00778                                         vcc->Set(vi.GetString(), strlen(vi.GetString()) + 1);
00779                                 }
00780                                 break;
00781                                 case DT_INTEGER:
00782                                 {
00783                                         int val = vi.GetInteger();
00784                                         ValueContainerInt* vci = (ValueContainerInt*)Values[Index].val;
00785                                         vci->Set(&val, sizeof(int));
00786                                 }
00787                                 break;
00788                                 case DT_BOOLEAN:
00789                                 {
00790                                         bool val = vi.GetBool();
00791                                         ValueContainerBool* vcb = (ValueContainerBool*)Values[Index].val;
00792                                         vcb->Set(&val, sizeof(bool));
00793                                 }
00794                                 break;
00795                                 default:
00796                                         /* You don't want to know what happens if someones bad code sends us here. */
00797                                 break;
00798                         }
00799 
00800                         /* We're done with this now */
00801                         delete Values[Index].val;
00802                 }
00803 
00804                 /* Read the multiple-tag items (class tags, connect tags, etc)
00805                  * and call the callbacks associated with them. We have three
00806                  * callbacks for these, a 'start', 'item' and 'end' callback.
00807                  */
00808                 for (int Index = 0; MultiValues[Index].tag; Index++)
00809                 {
00810                         MultiValues[Index].init_function(this, MultiValues[Index].tag);
00811 
00812                         int number_of_tags = ConfValueEnum(this->config_data, MultiValues[Index].tag);
00813 
00814                         for (int tagnum = 0; tagnum < number_of_tags; tagnum++)
00815                         {
00816                                 ValueList vl;
00817                                 for (int valuenum = 0; MultiValues[Index].items[valuenum]; valuenum++)
00818                                 {
00819                                         int dt = MultiValues[Index].datatype[valuenum];
00820                                         bool allow_newlines =  ((dt & DT_ALLOW_NEWLINE) > 0);
00821                                         dt &= ~DT_ALLOW_NEWLINE;
00822 
00823                                         switch (dt)
00824                                         {
00825                                                 case DT_CHARPTR:
00826                                                 {
00827                                                         char item[MAXBUF];
00828                                                         if (ConfValue(this->config_data, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, MAXBUF, allow_newlines))
00829                                                                 vl.push_back(ValueItem(item));
00830                                                         else
00831                                                                 vl.push_back(ValueItem(""));
00832                                                 }
00833                                                 break;
00834                                                 case DT_INTEGER:
00835                                                 {
00836                                                         int item = 0;
00837                                                         if (ConfValueInteger(this->config_data, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item))
00838                                                                 vl.push_back(ValueItem(item));
00839                                                         else
00840                                                                 vl.push_back(ValueItem(0));
00841                                                 }
00842                                                 break;
00843                                                 case DT_BOOLEAN:
00844                                                 {
00845                                                         bool item = ConfValueBool(this->config_data, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum);
00846                                                         vl.push_back(ValueItem(item));
00847                                                 }
00848                                                 break;
00849                                                 default:
00850                                                         /* Someone was smoking craq if we got here, and we're all gonna die. */
00851                                                 break;
00852                                         }
00853                                 }
00854 
00855                                 MultiValues[Index].validation_function(this, MultiValues[Index].tag, (char**)MultiValues[Index].items, vl, MultiValues[Index].datatype);
00856                         }
00857 
00858                         MultiValues[Index].finish_function(this, MultiValues[Index].tag);
00859                 }
00860 
00861         }
00862 
00863         catch (CoreException &ce)
00864         {
00865                 ReportConfigError(ce.GetReason(), bail, user);
00866                 return;
00867         }
00868 
00869         // write once here, to try it out and make sure its ok
00870         ServerInstance->WritePID(this->PID);
00871 
00872         ServerInstance->Log(DEFAULT,"Done reading configuration file.");
00873 
00874         /* If we're rehashing, let's load any new modules, and unload old ones
00875          */
00876         if (!bail)
00877         {
00878                 int found_ports = 0;
00879                 FailedPortList pl;
00880                 ServerInstance->BindPorts(false, found_ports, pl);
00881 
00882                 if (pl.size() && user)
00883                 {
00884                         user->WriteServ("NOTICE %s :*** Not all your client ports could be bound.", user->nick);
00885                         user->WriteServ("NOTICE %s :*** The following port(s) failed to bind:", user->nick);
00886                         int j = 1;
00887                         for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++)
00888                         {
00889                                 user->WriteServ("NOTICE %s :*** %d.   IP: %s     Port: %s", user->nick, j, i->first.empty() ? "<all>" : i->first.c_str(), i->second.c_str());
00890                         }
00891                 }
00892 
00893                 if (!removed_modules.empty())
00894                 {
00895                         for (std::vector<std::string>::iterator removing = removed_modules.begin(); removing != removed_modules.end(); removing++)
00896                         {
00897                                 if (ServerInstance->UnloadModule(removing->c_str()))
00898                                 {
00899                                         ServerInstance->WriteOpers("*** REHASH UNLOADED MODULE: %s",removing->c_str());
00900 
00901                                         if (user)
00902                                                 user->WriteServ("973 %s %s :Module %s successfully unloaded.",user->nick, removing->c_str(), removing->c_str());
00903 
00904                                         rem++;
00905                                 }
00906                                 else
00907                                 {
00908                                         if (user)
00909                                                 user->WriteServ("972 %s %s :Failed to unload module %s: %s",user->nick, removing->c_str(), removing->c_str(), ServerInstance->ModuleError());
00910                                 }
00911                         }
00912                 }
00913 
00914                 if (!added_modules.empty())
00915                 {
00916                         for (std::vector<std::string>::iterator adding = added_modules.begin(); adding != added_modules.end(); adding++)
00917                         {
00918                                 if (ServerInstance->LoadModule(adding->c_str()))
00919                                 {
00920                                         ServerInstance->WriteOpers("*** REHASH LOADED MODULE: %s",adding->c_str());
00921 
00922                                         if (user)
00923                                                 user->WriteServ("975 %s %s :Module %s successfully loaded.",user->nick, adding->c_str(), adding->c_str());
00924 
00925                                         add++;
00926                                 }
00927                                 else
00928                                 {
00929                                         if (user)
00930                                                 user->WriteServ("974 %s %s :Failed to load module %s: %s",user->nick, adding->c_str(), adding->c_str(), ServerInstance->ModuleError());
00931                                 }
00932                         }
00933                 }
00934 
00935                 ServerInstance->Log(DEFAULT,"Successfully unloaded %lu of %lu modules and loaded %lu of %lu modules.",(unsigned long)rem,(unsigned long)removed_modules.size(),(unsigned long)add,(unsigned long)added_modules.size());
00936         }
00937 
00938         if (user)
00939                 user->WriteServ("NOTICE %s :*** Successfully rehashed server.", user->nick);
00940         else
00941                 ServerInstance->WriteOpers("*** Successfully rehashed server.");
00942 }

bool ServerConfig::ReadFile file_cache F,
const char *  fname
 

Read a file into a file_cache object.

Definition at line 1487 of file configreader.cpp.

References InspIRCd::ConfigFileName, DEBUG, FileExists(), InspIRCd::Log(), MAXBUF, and ServerInstance.

Referenced by FileReader::LoadFile(), ValidateMotd(), and ValidateRules().

01488 {
01489         if (!fname || !*fname)
01490                 return false;
01491 
01492         FILE* file = NULL;
01493         char linebuf[MAXBUF];
01494 
01495         F.clear();
01496 
01497         if ((*fname != '/') && (*fname != '\\'))
01498         {
01499                 std::string::size_type pos;
01500                 std::string confpath = ServerInstance->ConfigFileName;
01501                 std::string newfile = fname;
01502 
01503                 if (((pos = confpath.rfind("/"))) != std::string::npos)
01504                         newfile = confpath.substr(0, pos) + std::string("/") + fname;
01505                 else if (((pos = confpath.rfind("\\"))) != std::string::npos)
01506                         newfile = confpath.substr(0, pos) + std::string("\\") + fname;
01507 
01508                 ServerInstance->Log(DEBUG, "Filename: %s", newfile.c_str());
01509 
01510                 if (!FileExists(newfile.c_str()))
01511                         return false;
01512                 file =  fopen(newfile.c_str(), "r");
01513         }
01514         else
01515         {
01516                 if (!FileExists(fname))
01517                         return false;
01518                 file =  fopen(fname, "r");
01519         }
01520 
01521         if (file)
01522         {
01523                 while (!feof(file))
01524                 {
01525                         if (fgets(linebuf, sizeof(linebuf), file))
01526                                 linebuf[strlen(linebuf)-1] = 0;
01527                         else
01528                                 *linebuf = 0;
01529 
01530                         F.push_back(*linebuf ? linebuf : " ");
01531                 }
01532 
01533                 fclose(file);
01534         }
01535         else
01536                 return false;
01537 
01538         return true;
01539 }

void ServerConfig::ReportConfigError const std::string errormessage,
bool  bail,
userrec user
 

Report a configuration error given in errormessage.

Parameters:
bail If this is set to true, the error is sent to the console, and the program exits
user If this is set to a non-null value, and bail is false, the errors are spooled to this user as SNOTICEs. If the parameter is NULL, the messages are spooled to all users via WriteOpers as SNOTICEs.

Definition at line 552 of file configreader.cpp.

References DEFAULT, InspIRCd::Exit(), EXIT_STATUS_CONFIG, InspIRCd::Log(), userrec::nick, ServerInstance, InspIRCd::WriteOpers(), and userrec::WriteServ().

Referenced by ConfigReader::DumpErrors(), and Read().

00553 {
00554         ServerInstance->Log(DEFAULT, "There were errors in your configuration file: %s", errormessage.c_str());
00555         if (bail)
00556         {
00557                 /* Unneeded because of the ServerInstance->Log() aboive? */
00558                 printf("There were errors in your configuration:\n%s\n\n",errormessage.c_str());
00559                 InspIRCd::Exit(EXIT_STATUS_CONFIG);
00560         }
00561         else
00562         {
00563                 std::string errors = errormessage;
00564                 std::string::size_type start;
00565                 unsigned int prefixlen;
00566                 start = 0;
00567                 /* ":ServerInstance->Config->ServerName NOTICE user->nick :" */
00568                 if (user)
00569                 {
00570                         prefixlen = strlen(this->ServerName) + strlen(user->nick) + 11;
00571                         user->WriteServ("NOTICE %s :There were errors in the configuration file:",user->nick);
00572                         while (start < errors.length())
00573                         {
00574                                 user->WriteServ("NOTICE %s :%s",user->nick, errors.substr(start, 510 - prefixlen).c_str());
00575                                 start += 510 - prefixlen;
00576                         }
00577                 }
00578                 else
00579                 {
00580                         ServerInstance->WriteOpers("There were errors in the configuration file:");
00581                         while (start < errors.length())
00582                         {
00583                                 ServerInstance->WriteOpers(errors.substr(start, 360).c_str());
00584                                 start += 360;
00585                         }
00586                 }
00587                 return;
00588         }
00589 }

void ServerConfig::Send005 userrec user  ) 
 

Send the 005 numerics (ISUPPORT) to a user.

Definition at line 144 of file configreader.cpp.

References InspIRCd::Config, isupport, userrec::nick, ServerInstance, and userrec::WriteServ().

Referenced by userrec::FullConnect(), cmd_version::Handle(), and ModuleSpanningTree::HandleVersion().

00145 {
00146         for (std::vector<std::string>::iterator line = ServerInstance->Config->isupport.begin(); line != ServerInstance->Config->isupport.end(); line++)
00147                 user->WriteServ("005 %s %s", user->nick, line->c_str());
00148 }

void ServerConfig::Update005  ) 
 

Update the 005 vector.

Definition at line 116 of file configreader.cpp.

References data005, isupport, and MAXBUF.

Referenced by InspIRCd::BuildISupport().

00117 {
00118         std::stringstream out(data005);
00119         std::string token;
00120         std::string line5;
00121         int token_counter = 0;
00122         isupport.clear();
00123         while (out >> token)
00124         {
00125                 line5 = line5 + token + " ";
00126                 token_counter++;
00127                 if (token_counter >= 13)
00128                 {
00129                         char buf[MAXBUF];
00130                         snprintf(buf, MAXBUF, "%s:are supported by this server", line5.c_str());
00131                         isupport.push_back(buf);
00132                         line5.clear();
00133                         token_counter = 0;
00134                 }
00135         }
00136         if (!line5.empty())
00137         {
00138                 char buf[MAXBUF];
00139                 snprintf(buf, MAXBUF, "%s:are supported by this server", line5.c_str());
00140                 isupport.push_back(buf);
00141         }
00142 }


Member Data Documentation

char ServerConfig::AdminEmail[MAXBUF]
 

Holds the email address of the admin, for output in the /ADMIN command.

Definition at line 290 of file configreader.h.

Referenced by TreeSocket::Admin(), cmd_admin::Handle(), and ServerConfig().

char ServerConfig::AdminName[MAXBUF]
 

Holds the admin's name, for output in the /ADMIN command.

Definition at line 285 of file configreader.h.

Referenced by TreeSocket::Admin(), cmd_admin::Handle(), and ServerConfig().

char ServerConfig::AdminNick[MAXBUF]
 

Holds the admin's nickname, for output in the /ADMIN command.

Definition at line 295 of file configreader.h.

Referenced by TreeSocket::Admin(), cmd_admin::Handle(), and ServerConfig().

bool ServerConfig::AllowHalfop
 

If this value is true, halfops have been enabled in the configuration file.

Definition at line 390 of file configreader.h.

Referenced by InspIRCd::BuildISupport(), ModeParser::BuildPrefixes(), TreeSocket::Capab(), ModeParser::ChanModes(), ModeParser::ChannelModeList(), cmd_uninvite::Handle(), cmd_tban::Handle(), ModeParser::ParaModeList(), ModeParser::Process(), and ServerConfig().

bool ServerConfig::AnnounceInvites
 

Announce invites to the channel with a server notice.

Definition at line 459 of file configreader.h.

Referenced by cmd_invite::Handle().

int ServerConfig::argc
 

Saved argc from startup.

Definition at line 590 of file configreader.h.

Referenced by cmd_rehash::Handle(), InspIRCd::InspIRCd(), and InspIRCd::Rehash().

char** ServerConfig::argv
 

Saved argv from startup.

Definition at line 586 of file configreader.h.

Referenced by GetFullProgDir(), cmd_rehash::Handle(), InspIRCd::InspIRCd(), InspIRCd::Rehash(), and InspIRCd::Restart().

ClassVector ServerConfig::Classes
 

The connect classes in use by the IRC server.

Definition at line 489 of file configreader.h.

Referenced by DoConnect(), DoStats(), userrec::GetClass(), and InitConnect().

ConfigDataHash ServerConfig::config_data
 

This holds all the information in the config file, it's indexed by tag name to a vector of key/values.

Definition at line 247 of file configreader.h.

Referenced by InspIRCd::BindPorts(), ConfigReader::ConfigReader(), DoStats(), cmd_oper::Handle(), InspIRCd::HostMatchesEveryone(), InspIRCd::IPMatchesEveryone(), InspIRCd::LoadAllModules(), InspIRCd::NickMatchesEveryone(), and Read().

char ServerConfig::CustomVersion[MAXBUF]
 

Custom version string, which if defined can replace the system info in VERSION.

Definition at line 539 of file configreader.h.

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

bool ServerConfig::CycleHosts
 

If set to true, users appear to quit then rejoin when their hosts change.

This keeps clients synchronized properly.

Definition at line 564 of file configreader.h.

Referenced by ServerConfig().

std::string ServerConfig::data005
 

The 005 tokens of this server (ISUPPORT) populated/repopulated upon loading or unloading modules.

Definition at line 518 of file configreader.h.

Referenced by InspIRCd::BuildISupport(), and Update005().

int ServerConfig::debugging
 

True if the DEBUG loglevel is selected.

Definition at line 437 of file configreader.h.

Referenced by ServerConfig(), and ValidateLogLevel().

char ServerConfig::DefaultModes[MAXBUF]
 

Default channel modes.

Definition at line 535 of file configreader.h.

Referenced by ServerConfig(), and chanrec::SetDefaultModes().

int ServerConfig::DieDelay
 

How many seconds to wait before exiting the program when /DIE is correctly issued.

Definition at line 446 of file configreader.h.

Referenced by cmd_die::Handle(), and ServerConfig().

char ServerConfig::diepass[MAXBUF]
 

The admin-configured /DIE password.

Definition at line 299 of file configreader.h.

Referenced by cmd_die::Handle(), and ServerConfig().

char ServerConfig::DieValue[MAXBUF]
 

The last string found within a <die> tag, or an empty string.

Definition at line 330 of file configreader.h.

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

char ServerConfig::DisabledCommands[MAXBUF]
 

This variable contains a space-seperated list of commands which are disabled by the administrator of the server for non-opers.

Definition at line 340 of file configreader.h.

Referenced by cmd_rehash::Handle(), InspIRCd::InspIRCd(), ModuleSpanningTree::OnRehash(), TreeSocket::RemoteRehash(), and ServerConfig().

int ServerConfig::dns_timeout
 

The number of seconds the DNS subsystem will wait before timing out any request.

Definition at line 406 of file configreader.h.

Referenced by userrec::AddClient(), userrec::CheckClass(), DNSRequest::DNSRequest(), InspIRCd::DoBackgroundUserStuff(), cmd_user::Handle(), cmd_nick::Handle(), and ServerConfig().

char ServerConfig::DNSServer[MAXBUF]
 

The DNS server to use for DNS queries.

Definition at line 334 of file configreader.h.

Referenced by DNS::GetResult(), DNS::Rehash(), and ServerConfig().

bool ServerConfig::ExemptChanOps[256]
 

If this is set to true, then channel operators are exempt from this channel mode.

Used for +Sc etc.

Definition at line 401 of file configreader.h.

Referenced by ValidateExemptChanOps().

char ServerConfig::FixedQuit[MAXBUF]
 

The fixed quit message in use, or an empty string.

Definition at line 325 of file configreader.h.

Referenced by cmd_quit::Handle(), and ServerConfig().

bool ServerConfig::forcedebug
 

If this value if true then all log messages will be output, regardless of the level given in the config file.

This is set with the -debug commandline option.

Definition at line 375 of file configreader.h.

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

bool ServerConfig::FullHostInTopic
 

If set to true, the full nick!user will be shown in the TOPIC command for who set the topic last.

If false, only the nick is shown.

Definition at line 574 of file configreader.h.

Referenced by cmd_topic::Handle().

char ServerConfig::global_implementation[255]
 

Global implementation list.

Definition at line 506 of file configreader.h.

Referenced by InspIRCd::AllModulesReportReady(), InspIRCd::InspIRCd(), InspIRCd::LoadModule(), and InspIRCd::UnloadModule().

bool ServerConfig::HideBans
 

True if we're going to hide ban reasons for non-opers (e.g.

G-Lines, K-Lines, Z-Lines)

Definition at line 455 of file configreader.h.

Referenced by XLineManager::apply_lines(), and ServerConfig().

char ServerConfig::HideKillsServer[MAXBUF]
 

Set to a non empty string to obfuscate nicknames prepended to a KILL.

Definition at line 472 of file configreader.h.

Referenced by cmd_kill::Handle(), and ServerConfig().

bool ServerConfig::HideModeLists[256]
 

If this is set to true, then mode lists (e.g MODE chan b) are hidden from unprivileged users.

Definition at line 396 of file configreader.h.

Referenced by ModeParser::Process(), and ValidateModeLists().

bool ServerConfig::HideSplits
 

True if we're going to hide netsplits as *.net *.split for non-opers.

Definition at line 450 of file configreader.h.

Referenced by TreeServer::QuitUsers(), and ServerConfig().

char ServerConfig::HideWhoisServer[MAXBUF]
 

Set to a non-empty string to obfuscate the server name of users in WHOIS.

Definition at line 468 of file configreader.h.

Referenced by do_whois(), cmd_whowas::Handle(), cmd_whois::Handle(), cmd_who::SendWhoLine(), and ServerConfig().

char ServerConfig::implement_lists[255][255]
 

Boolean sets of which modules implement which functions.

Definition at line 502 of file configreader.h.

Referenced by InspIRCd::AllModulesReportReady(), InspIRCd::InspIRCd(), InspIRCd::LoadModule(), InspIRCd::MoveTo(), and InspIRCd::UnloadModule().

std::vector<std::string> ServerConfig::include_stack [private]
 

This variable holds the names of all files included from the main one.

This is used to make sure that no files are recursively included.

Definition at line 224 of file configreader.h.

Referenced by ClearStack(), LoadConf(), and Read().

std::map<int,Module*> ServerConfig::IOHookModule
 

A list of ports claimed by IO Modules.

Definition at line 510 of file configreader.h.

Referenced by AddIOHook(), DelIOHook(), and GetIOHook().

std::vector<std::string> ServerConfig::isupport
 

isupport strings

Definition at line 522 of file configreader.h.

Referenced by Send005(), and Update005().

FILE* ServerConfig::log_file
 

The file handle of the logfile.

If this value is NULL, the log file is not open, probably due to a permissions error on startup (this should not happen in normal operation!).

Definition at line 360 of file configreader.h.

Referenced by InspIRCd::Log(), InspIRCd::OpenLog(), and ServerConfig().

int ServerConfig::LogLevel
 

The loglevel in use by the IRC server.

Definition at line 441 of file configreader.h.

Referenced by ServerConfig(), and ValidateLogLevel().

std::string ServerConfig::logpath
 

The path and filename of the ircd.log file.

Definition at line 531 of file configreader.h.

Referenced by cmd_rehash::Handle(), InspIRCd::InspIRCd(), InspIRCd::OpenLog(), and InspIRCd::Rehash().

std::map<std::string, int> ServerConfig::maxbans
 

Max banlist sizes for channels (the std::string is a glob).

Definition at line 547 of file configreader.h.

Referenced by DoMaxBans(), chanrec::GetMaxBans(), InitMaxBans(), and ServerConfig().

unsigned int ServerConfig::MaxChans
 

Max channels per user.

Definition at line 594 of file configreader.h.

Referenced by InspIRCd::BuildISupport(), chanrec::JoinUser(), and ServerConfig().

int ServerConfig::MaxConn
 

The value to be used for listen() backlogs as default.

Definition at line 417 of file configreader.h.

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

unsigned int ServerConfig::MaxTargets
 

Maximum number of targets for a multi target command such as PRIVMSG or KICK.

Definition at line 428 of file configreader.h.

Referenced by InspIRCd::BuildISupport(), CommandParser::LoopCall(), and ServerConfig().

int ServerConfig::MaxWhoResults
 

The maximum number of /WHO results allowed in any single /WHO command.

Definition at line 433 of file configreader.h.

Referenced by cmd_who::Handle(), and ServerConfig().

char ServerConfig::ModPath[1024]
 

The full path to the modules directory.

This is either set at compile time, or overridden in the configuration file via the <options> tag.

Definition at line 347 of file configreader.h.

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

std::vector<std::string> ServerConfig::module_names
 

A list of module names (names only, no paths) which are currently loaded by the server.

Definition at line 494 of file configreader.h.

Referenced by InspIRCd::Cleanup(), InspIRCd::EraseModule(), InspIRCd::GetModuleName(), cmd_modules::Handle(), InitModule(), InspIRCd::LoadAllModules(), InspIRCd::LoadModule(), TreeSocket::Modules(), InspIRCd::MoveAfter(), InspIRCd::MoveBefore(), InspIRCd::MoveTo(), ModuleHttpStats::OnEvent(), InspIRCd::PriorityAfter(), InspIRCd::PriorityBefore(), and InspIRCd::UnloadModule().

char ServerConfig::MoronBanner[MAXBUF]
 

Notice to give to users when they are Xlined.

Definition at line 269 of file configreader.h.

Referenced by userrec::AddClient(), XLineManager::apply_lines(), userrec::FullConnect(), and ModuleCgiIRC::Recheck().

file_cache ServerConfig::MOTD
 

The MOTD file, cached in a file_cache type.

Definition at line 476 of file configreader.h.

Referenced by DoStats(), TreeSocket::Motd(), userrec::ShowMOTD(), and ValidateMotd().

char ServerConfig::motd[MAXBUF]
 

The pathname and filename of the message of the day file, as defined by the administrator.

Definition at line 308 of file configreader.h.

Referenced by ServerConfig().

std::string ServerConfig::MyDir
 

Directory where the inspircd binary resides.

Definition at line 551 of file configreader.h.

Referenced by InspIRCd::OpenLog(), and InspIRCd::Restart().

char ServerConfig::MyExecutable[1024]
 

The full pathname to the executable, as given in argv[0] when the program starts.

Definition at line 352 of file configreader.h.

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

int ServerConfig::NetBufferSize
 

The size of the read() buffer in the user handling code, used to read data into a user's recvQ.

Definition at line 412 of file configreader.h.

Referenced by ModuleSSLGnuTLS::ModuleSSLGnuTLS(), ModuleSSLOpenSSL::ModuleSSLOpenSSL(), and ServerConfig().

char ServerConfig::Network[MAXBUF]
 

Definition at line 275 of file configreader.h.

Referenced by InspIRCd::BuildISupport(), do_whois(), CloakUser::DoRehash(), userrec::FullConnect(), ModuleBotMode::OnWhois(), and ServerConfig().

bool ServerConfig::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.

Definition at line 367 of file configreader.h.

Referenced by InspIRCd::DoOneIteration(), InspIRCd::InspIRCd(), InspIRCd::Log(), and ServerConfig().

bool ServerConfig::NoUserDns
 

If set to true, no user DNS lookups are to be performed.

Definition at line 555 of file configreader.h.

Referenced by cmd_nick::Handle(), and ServerConfig().

operclass_t ServerConfig::operclass
 

All oper class definitions from the config file.

Definition at line 582 of file configreader.h.

Referenced by DoClass(), userrec::HasPermission(), InitClasses(), and InspIRCd::InspIRCd().

unsigned int ServerConfig::OperMaxChans
 

Oper max channels per user.

Definition at line 598 of file configreader.h.

Referenced by chanrec::JoinUser(), and ServerConfig().

bool ServerConfig::OperSpyWhois
 

If this is enabled then operators will see invisible (+i) channels in /whois.

Definition at line 464 of file configreader.h.

Referenced by userrec::ChannelList(), and ServerConfig().

opertype_t ServerConfig::opertypes
 

All oper type definitions from the config file.

Definition at line 578 of file configreader.h.

Referenced by DoType(), userrec::HasPermission(), InitTypes(), and InspIRCd::InspIRCd().

char ServerConfig::PID[1024]
 

The full pathname and filename of the PID file as defined in the configuration.

Definition at line 485 of file configreader.h.

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

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

A list of the classes for listening client ports.

Definition at line 498 of file configreader.h.

Referenced by InspIRCd::BindPorts(), InspIRCd::Cleanup(), DoStats(), InspIRCd::InspIRCd(), ModuleXMLSocket::OnRehash(), ModuleSSLOpenSSL::OnRehash(), ModuleSSLGnuTLS::OnRehash(), ModuleXMLSocket::OnUnloadModule(), ModuleSSLOpenSSL::OnUnloadModule(), ModuleSSLGnuTLS::OnUnloadModule(), and DNS::PRNG().

char ServerConfig::PrefixQuit[MAXBUF]
 

The quit prefix in use, or an empty string.

Definition at line 317 of file configreader.h.

Referenced by cmd_quit::Handle(), and ServerConfig().

char ServerConfig::restartpass[MAXBUF]
 

The admin-configured /RESTART password.

Definition at line 303 of file configreader.h.

Referenced by cmd_restart::Handle(), and ServerConfig().

file_cache ServerConfig::RULES
 

The RULES file, cached in a file_cache type.

Definition at line 480 of file configreader.h.

Referenced by DoStats(), userrec::ShowRULES(), and ValidateRules().

char ServerConfig::rules[MAXBUF]
 

The pathname and filename of the rules file, as defined by the administrator.

Definition at line 313 of file configreader.h.

Referenced by ServerConfig().

char ServerConfig::ServerDesc[MAXBUF]
 

Holds the description of the local server as defined by the administrator.

Definition at line 280 of file configreader.h.

Referenced by TreeSocket::Capab(), InspIRCd::GetServerDescription(), cmd_links::Handle(), TreeSocket::Inbound_Server(), ModuleHttpStats::OnEvent(), ServerConfig(), and SpanningTreeUtilities::SpanningTreeUtilities().

InspIRCd* ServerConfig::ServerInstance [private]
 

Creator/owner pointer.

Definition at line 217 of file configreader.h.

Referenced by ConfValue(), DoInclude(), GetInstance(), Read(), ReadFile(), ReportConfigError(), and Send005().

char ServerConfig::ServerName[MAXBUF]
 

Holds the server name of the local server as defined by the administrator.

Definition at line 265 of file configreader.h.

Referenced by userrec::AddClient(), TreeSocket::Admin(), ListModeBase::DisplayList(), ModuleSpanningTree::DoPingChecks(), DoStats(), TreeSocket::ForceJoin(), TreeSocket::ForceTopic(), userrec::FullConnect(), InspIRCd::GetVersionString(), cmd_rsquit::Handle(), cmd_rconnect::Handle(), cmd_uninvite::Handle(), RemoveBase::Handle(), cmd_knock::Handle(), cmd_greloadmodule::Handle(), cmd_gunloadmodule::Handle(), cmd_gloadmodule::Handle(), cmd_alltime::Handle(), cmd_time::Handle(), cmd_privmsg::Handle(), cmd_ping::Handle(), cmd_notice::Handle(), cmd_map::Handle(), cmd_links::Handle(), cmd_kill::Handle(), cmd_invite::Handle(), cmd_admin::Handle(), ModuleSpanningTree::HandleAdmin(), ModuleSpanningTree::HandleModules(), ModuleSpanningTree::HandleMotd(), ModuleSpanningTree::HandleStats(), ModuleSpanningTree::HandleTime(), InspIRCd::InspIRCd(), TreeSocket::Modules(), TreeSocket::Motd(), cmd_rsquit::NoticeUser(), ModuleSpanningTree::OnEvent(), ModuleHttpStats::OnEvent(), ModuleSpanningTree::OnLine(), ModuleSQLLog::OnLoadModule(), DNSBLResolver::OnLookupComplete(), FilterBase::OnPreCommand(), ModuleAntiBear::OnPreCommand(), ModuleSpanningTree::OnRehash(), ModuleSafeList::OnRehash(), ModuleSpanningTree::OnStats(), ModuleZLib::OnStats(), ModuleSVSHold::OnStats(), ModuleFilterPCRE::OnStats(), ModuleFilter::OnStats(), ModuleDNSBL::OnStats(), ModuleCBan::OnStats(), ModuleSpanningTree::OnUserConnect(), ModuleSpanningTree::OnUserJoin(), ModuleJoinFlood::OnUserJoin(), ModuleSpanningTree::OnUserKick(), ModuleOverride::OnUserPreJoin(), FilterBase::OnUserPreNotice(), ModeParser::Process(), TreeSocket::ProcessLine(), ModuleSpanningTree::ProtoSendMetaData(), ModuleSpanningTree::ProtoSendMode(), SpanningTreeUtilities::ReadConfiguration(), ModuleSpanningTree::RemoteMessage(), TreeSocket::SendChannelModes(), TreeSocket::SendFJoins(), TreeSocket::SendXLines(), ServerConfig(), chanrec::ServerKickUser(), InspIRCd::ServerNoticeAll(), InspIRCd::ServerPrivmsgAll(), ModuleSpanningTree::ShowLinks(), userrec::ShowMOTD(), userrec::ShowRULES(), SpanningTreeUtilities::SpanningTreeUtilities(), userrec::SplitChanList(), XLineManager::stats_e(), XLineManager::stats_g(), XLineManager::stats_k(), XLineManager::stats_q(), XLineManager::stats_z(), userrec::userrec(), ValidateServerName(), chanrec::WriteChannelWithServ(), and userrec::WriteServ().

std::map<InspSocket*, Module*> ServerConfig::SocketIOHookModule
 

Definition at line 512 of file configreader.h.

Referenced by AddIOHook(), DelIOHook(), and GetIOHook().

unsigned int ServerConfig::SoftLimit
 

The soft limit value assigned to the irc server.

The IRC server will not allow more than this number of local users.

Definition at line 423 of file configreader.h.

Referenced by userrec::AddClient(), and ServerConfig().

char ServerConfig::SuffixQuit[MAXBUF]
 

The quit suffix in use, or an empty string.

Definition at line 321 of file configreader.h.

Referenced by cmd_quit::Handle(), and ServerConfig().

bool ServerConfig::SyntaxHints
 

If set to true, provide syntax hints for unknown commands.

Definition at line 559 of file configreader.h.

Referenced by CommandParser::ProcessCommand().

std::map<irc::string, bool> ServerConfig::ulines
 

List of u-lined servers.

Definition at line 543 of file configreader.h.

Referenced by DoULine(), InitULine(), InspIRCd::SilentULine(), and InspIRCd::ULine().

bool ServerConfig::UndernetMsgPrefix
 

If set to true, prefixed channel NOTICEs and PRIVMSGs will have the prefix added to the outgoing text for undernet style msg prefixing.

Definition at line 569 of file configreader.h.

Referenced by cmd_privmsg::Handle(), cmd_notice::Handle(), and ServerConfig().

char ServerConfig::UserStats[MAXBUF]
 

STATS characters in this list are available only to operators.

Definition at line 527 of file configreader.h.

Referenced by DoStats(), and ServerConfig().

int ServerConfig::WhoWasGroupSize
 

Max number of WhoWas entries per user.

Definition at line 251 of file configreader.h.

Referenced by cmd_whowas::AddToWhoWas(), DoStats(), cmd_whowas::Handle(), cmd_whowas::PruneWhoWas(), ServerConfig(), and ValidateWhoWas().

int ServerConfig::WhoWasMaxGroups
 

Max number of cumulative user-entries in WhoWas.

When max reached and added to, push out oldest entry FIFO style.

Definition at line 256 of file configreader.h.

Referenced by cmd_whowas::AddToWhoWas(), DoStats(), cmd_whowas::Handle(), cmd_whowas::PruneWhoWas(), ServerConfig(), and ValidateWhoWas().

int ServerConfig::WhoWasMaxKeep
 

Max seconds a user is kept in WhoWas before being pruned.

Definition at line 260 of file configreader.h.

Referenced by cmd_whowas::MaintainWhoWas(), cmd_whowas::PruneWhoWas(), ServerConfig(), and ValidateWhoWas().

bool ServerConfig::writelog
 

If this is true then log output will be written to the logfile.

This is the default. If you put -nolog on the commandline then the logfile will not be written. This is meant to be used in conjunction with -debug for debugging without filling up the hard disk.

Definition at line 385 of file configreader.h.

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


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