]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/configreader.h
Add <oper:autologin> to allow SSL fingerprint-based automatic oper login
[user/henk/code/inspircd.git] / include / configreader.h
index 54d9f7053d41b329102500bfe7192e66a7b30088..c63b4677903d8e0b97bb3b1d3cdde27c429d392c 100644 (file)
@@ -2,7 +2,7 @@
  *       | 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;
-
 /** Structure representing a single <tag> in config */
 class CoreExport ConfigTag : public refcountbase
 {
@@ -65,6 +51,8 @@ class CoreExport ConfigTag : public refcountbase
 
        std::string getTagLocation();
 
+       inline const std::vector<KeyVal>& getItems() const { return items; }
+
        /** 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);
@@ -72,10 +60,6 @@ class CoreExport ConfigTag : public refcountbase
        ConfigTag(const std::string& Tag, const std::string& file, int line);
 };
 
-/** An entire config file, built up of KeyValLists
- */
-typedef std::multimap<std::string, reference<ConfigTag> > ConfigDataHash;
-
 /** Defines the server's length limits on various length-limited
  * items such as topics, nicknames, channel names etc.
  */
@@ -199,11 +183,6 @@ class CoreExport OperInfo : public refcountbase
        }
 };
 
-typedef std::map<std::string, reference<ConfigTag> > TagIndex;
-typedef std::map<std::string, reference<OperInfo> > OperIndex;
-typedef ConfigDataHash::iterator ConfigIter;
-typedef std::pair<ConfigDataHash::iterator, ConfigDataHash::iterator> ConfigTagList;
-
 /** 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
@@ -240,6 +219,11 @@ class CoreExport ServerConfig
         */
        ConfigDataHash config_data;
 
+       /** This holds all extra files that have been read in the configuration
+        * (for example, MOTD and RULES files are stored here)
+        */
+       ConfigFileCache Files;
+
        /** Length limits, see definition of ServerLimits class
         */
        ServerLimits Limits;
@@ -352,11 +336,6 @@ class CoreExport ServerConfig
         */
        std::string FixedPart;
 
-       /** The last string found within a <die> tag, or
-        * an empty string.
-        */
-       std::string DieValue;
-
        /** The DNS server to use for DNS queries
         */
        std::string DNSServer;
@@ -397,11 +376,6 @@ class CoreExport ServerConfig
         */
        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.
@@ -435,16 +409,6 @@ class CoreExport ServerConfig
         */
        unsigned int MaxTargets;
 
-       /** The maximum number of /WHO results allowed
-        * in any single /WHO command.
-        */
-       int MaxWhoResults;
-
-       /** 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;
@@ -471,14 +435,6 @@ class CoreExport ServerConfig
         */
        std::string HideKillsServer;
 
-       /** The MOTD file, cached in a file_cache type.
-        */
-       file_cache MOTD;
-
-       /** The RULES file, cached in a file_cache type.
-        */
-       file_cache RULES;
-
        /** The full pathname and filename of the PID
         * file as defined in the configuration.
         */
@@ -591,10 +547,6 @@ class CoreExport ServerConfig
 
        void Fill();
 
-       /** Read a file into a file_cache object
-        */
-       bool ReadFile(file_cache &F, const std::string& fname);
-
        /* Returns true if the given string starts with a windows drive letter
         */
        bool StartsWithWindowsDriveLetter(const std::string &path);
@@ -619,4 +571,29 @@ class CoreExport ServerConfig
 
 };
 
+/** 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