* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * InspIRCd: (C) 2002-2010 InspIRCd Development Team
* See: http://wiki.inspircd.org/Credits
*
* This program is free but copyrighted software; see
#include "socketengine.h"
#include "socket.h"
-/* Required forward definitions */
-class ServerConfig;
-class ServerLimits;
-class InspIRCd;
-class BufferedSocket;
-
-/** A cached text file stored with its contents as lines
- */
-typedef std::vector<std::string> file_cache;
-
-/** A configuration key and value pair
- */
-typedef std::pair<std::string, std::string> KeyVal;
-
-struct CoreExport ConfigTag : public refcountbase
+/** Structure representing a single <tag> in config */
+class CoreExport ConfigTag : public refcountbase
{
+ std::vector<KeyVal> items;
+ public:
const std::string tag;
const std::string src_name;
const int src_line;
- std::vector<KeyVal> items;
-
- ConfigTag(const std::string& Tag, const std::string& file, int line)
- : tag(Tag), src_name(file), src_line(line) {}
+ /** Get the value of an option, using def if it does not exist */
std::string getString(const std::string& key, const std::string& def = "");
+ /** Get the value of an option, using def if it does not exist */
long getInt(const std::string& key, long def = 0);
+ /** Get the value of an option, using def if it does not exist */
double getFloat(const std::string& key, double def = 0);
+ /** Get the value of an option, using def if it does not exist */
bool getBool(const std::string& key, bool def = false);
+ /** Get the value of an option
+ * @param key The option to get
+ * @param value The location to store the value (unmodified if does not exist)
+ * @param allow_newline Allow newlines in the option (normally replaced with spaces)
+ * @return true if the option exists
+ */
bool readString(const std::string& key, std::string& value, bool allow_newline = false);
std::string getTagLocation();
-};
-/** An entire config file, built up of KeyValLists
- */
-typedef std::multimap<std::string, reference<ConfigTag> > ConfigDataHash;
+ inline const std::vector<KeyVal>& getItems() const { return items; }
-typedef std::map<std::string, reference<ConfigTag> > TagIndex;
+ /** Create a new ConfigTag, giving access to the private KeyVal item list */
+ static ConfigTag* create(const std::string& Tag, const std::string& file, int line,
+ std::vector<KeyVal>*&items);
+ private:
+ ConfigTag(const std::string& Tag, const std::string& file, int line);
+};
/** Defines the server's length limits on various length-limited
* items such as topics, nicknames, channel names etc.
}
};
+struct CommandLineConf
+{
+ /** 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 nofork;
+
+ /** 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.
+ */
+ bool forcedebug;
+
+ /** 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.
+ */
+ bool writelog;
+
+ /** True if we have been told to run the testsuite from the commandline,
+ * rather than entering the mainloop.
+ */
+ bool TestSuite;
+
+ /** Saved argc from startup
+ */
+ int argc;
+
+ /** Saved argv from startup
+ */
+ char** argv;
+
+ std::string startup_log;
+};
+
+class CoreExport OperInfo : public refcountbase
+{
+ public:
+ std::set<std::string> AllowedOperCommands;
+ std::set<std::string> AllowedPrivs;
+
+ /** Allowed user modes from oper classes. */
+ std::bitset<64> AllowedUserModes;
+
+ /** Allowed channel modes from oper classes. */
+ std::bitset<64> AllowedChanModes;
+
+ /** <oper> block used for this oper-up. May be NULL. */
+ reference<ConfigTag> oper_block;
+ /** <type> block used for this oper-up. Valid for local users, may be NULL on remote */
+ reference<ConfigTag> type_block;
+ /** <class> blocks referenced from the <type> block. These define individual permissions */
+ std::vector<reference<ConfigTag> > class_blocks;
+ /** Name of the oper type; i.e. the one shown in WHOIS */
+ std::string name;
+
+ /** Get a configuration item, searching in the oper, type, and class blocks (in that order) */
+ std::string getConfig(const std::string& key);
+ void init();
+
+ inline const char* NameStr()
+ {
+ return irc::Spacify(name.c_str());
+ }
+};
+
/** 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
* @param tag The name of the tag to get
* @param offset get the Nth occurance of the tag
*/
- ConfigTag* ConfValue(const std::string& tag, int offset = 0);
+ ConfigTag* ConfValue(const std::string& tag);
+
+ ConfigTagList ConfTags(const std::string& tag);
/** Error stream, contains error output from any failed configuration parsing.
*/
*/
ServerLimits Limits;
+ /** Configuration parsed from the command line.
+ */
+ CommandLineConf cmdline;
+
/** Clones CIDR range for ipv4 (0-32)
* Defaults to 32 (checks clones on all IPs seperately)
*/
*/
int WhoWasMaxKeep;
- /** Both for set(g|u)id.
- */
- std::string SetUser;
- std::string SetGroup;
-
/** Holds the server name of the local server
* as defined by the administrator.
*/
/** This variable identifies which usermodes have been diabled.
*/
-
char DisabledUModes[64];
/** This variable identifies which chanmodes have been disabled.
/** The full path to the modules directory.
* This is either set at compile time, or
* overridden in the configuration file via
- * the <options> tag.
+ * the <path> tag.
*/
std::string ModPath;
- /** 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!).
- */
- FILE *log_file;
-
- /** 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 nofork;
-
- /** 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.
- */
- bool forcedebug;
-
- /** 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.
- */
- bool writelog;
-
/** If set to true, then all opers on this server are
* shown with a generic 'is an IRC operator' line rather
* than the oper type. Oper types are still used internally.
*/
bool RestrictBannedUsers;
- /** If this value is true, halfops have been
- * enabled in the configuration file.
- */
- bool AllowHalfop;
-
/** If this is set to true, then mode lists (e.g
* MODE #chan b) are hidden from unprivileged
* users.
*/
unsigned int MaxTargets;
- /** The maximum number of /WHO results allowed
- * in any single /WHO command.
- */
- int MaxWhoResults;
-
- /** True if the DEBUG loglevel is selected.
- */
- int debugging;
-
- /** How many seconds to wait before exiting
- * the program when /DIE is correctly issued.
- */
- int DieDelay;
-
/** True if we're going to hide netsplits as *.net *.split for non-opers
*/
bool HideSplits;
*/
std::string UserStats;
- /** The path and filename of the ircd.log file
- */
- std::string logpath;
-
/** Default channel modes
*/
std::string DefaultModes;
*/
std::map<std::string, int> maxbans;
- /** Directory where the inspircd binary resides
- */
- std::string MyDir;
-
/** If set to true, no user DNS lookups are to be performed
*/
bool NoUserDns;
*/
bool FullHostInTopic;
- /** All oper type definitions from the config file
- */
- TagIndex opertypes;
-
- /** All oper class definitions from the config file
+ /** Oper block and type index.
+ * For anonymous oper blocks (type only), prefix with a space.
*/
- TagIndex operclass;
-
- /** Saved argv from startup
- */
- char** argv;
-
- /** Saved argc from startup
- */
- int argc;
+ OperIndex oper_blocks;
/** Max channels per user
*/
*/
std::string sid;
- /** True if we have been told to run the testsuite from the commandline,
- * rather than entering the mainloop.
- */
- bool TestSuite;
-
/** Construct a new ServerConfig
*/
ServerConfig();
bool InvBypassModes;
};
+
+/** The background thread for config reading, so that reading from executable includes
+ * does not block.
+ */
+class CoreExport ConfigReaderThread : public Thread
+{
+ ServerConfig* Config;
+ volatile bool done;
+ public:
+ const std::string TheUserUID;
+ ConfigReaderThread(const std::string &useruid)
+ : Config(new ServerConfig), done(false), TheUserUID(useruid)
+ {
+ }
+
+ virtual ~ConfigReaderThread()
+ {
+ delete Config;
+ }
+
+ void Run();
+ /** Run in the main thread to apply the configuration */
+ void Finish();
+ bool IsDone() { return done; }
+};
+
#endif