]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Merge pull request #591 from SaberUK/master+config-tweaks
authorAttila Molnar <attilamolnar@hush.com>
Mon, 12 Aug 2013 16:20:46 +0000 (09:20 -0700)
committerAttila Molnar <attilamolnar@hush.com>
Mon, 12 Aug 2013 16:20:46 +0000 (09:20 -0700)
Various patches relating to configuration.

23 files changed:
docs/conf/inspircd.conf.example
docs/conf/modules.conf.example
include/configreader.h
include/users.h
src/channels.cpp
src/commands/cmd_hostname_lookup.cpp
src/commands/cmd_whowas.cpp
src/configparser.cpp
src/configreader.cpp
src/inspircd.cpp
src/logger.cpp
src/modmanager_dynamic.cpp
src/modules.cpp
src/modules/extra/m_ssl_gnutls.cpp
src/modules/extra/m_ssl_openssl.cpp
src/modules/m_blockcaps.cpp
src/modules/m_cgiirc.cpp
src/modules/m_connectban.cpp
src/modules/m_nationalchars.cpp
src/modules/m_xline_db.cpp
src/usermanager.cpp
src/users.cpp
src/xline.cpp

index 2c75ddc7c922d43d0ecf520152341db167f0a0c6..036a3ebfce4f05a765c465936c319e680894cea1 100644 (file)
          # maxconnwarn: Enable warnings when localmax or globalmax is hit (defaults to on)
          maxconnwarn="off"
 
-         # nouserdns: If enabled, no DNS lookups will be performed on connecting users
+         # resolvehostnames: If disabled, no DNS lookups will be performed on connecting users
          # in this class. This can save a lot of resources on very busy servers.
-         nouserdns="no"
+         resolvehostnames="yes"
 
          # usednsbl: Defines whether or not users in this class are subject to DNSBL. Default is yes.
          # This setting only has effect when m_dnsbl is loaded.
          # globalmax: Maximum global (network-wide) connections per IP.
          globalmax="3"
 
-         # nouserdns: If enabled, no DNS lookups will be performed on connecting users
+         # resolvehostnames: If disabled, no DNS lookups will be performed on connecting users
          # in this class. This can save a lot of resources on very busy servers.
-         nouserdns="no"
+         resolvehostnames="yes"
 
          # useident: Defines if users in this class must respond to a ident query or not.
          useident="no"
 
 # This file has all the information about oper classes, types and o:lines.
 # You *MUST* edit it.
-<include file="conf/examples/opers.conf.example">
+<include file="examples/opers.conf.example">
 
 # This file has all the information about server links and ulined servers.
 # You *MUST* edit it if you intend to link servers.
-<include file="conf/examples/links.conf.example">
+<include file="examples/links.conf.example">
 
 #-#-#-#-#-#-#-#-#-#-  MISCELLANEOUS CONFIGURATION  -#-#-#-#-#-#-#-#-#-#
 #                                                                     #
 #   motd - displayed on connect and when a user executes /MOTD
 #   rules - displayed when the user executes /RULES
 # Modules can also define their own files
-<files motd="conf/examples/motd.txt.example" rules="conf/examples/rules.txt.example">
+<files motd="examples/motd.txt.example" rules="examples/rules.txt.example">
 
 # Example of an executable file include. Note this will be read on rehash,
 # not when the command is run.
          # defaultmodes: What modes are set on a empty channel when a user
          # joins it and it is unregistered. This is similar to Asuka's
          # autochanmodes.
-         defaultmodes="nt"
+         defaultmodes="not"
 
-         # moronbanner: This is the text that is sent to a user when they are
+         # xlinemessage: This is the text that is sent to a user when they are
          # banned from the server.
-         moronbanner="You're banned! Email haha@abuse.com with the ERROR line below for help."
+         xlinemessage="You're banned! Email irc@example.com with the ERROR line below for help."
 
          # exemptchanops: exemptions for channel access restrictions based on prefix.
          exemptchanops="nonick:v flood:o"
           # (Commands like /notice, /privmsg, /kick, etc)
           maxtargets="20"
 
-          # customversion: Displays a custom string when a user /version's
-          # the ircd. This may be set for security reasons or vanity reasons.
+          # customversion: A custom message to be displayed in the comments field
+          # of the VERSION command response. This does not hide the InspIRCd version.
           customversion=""
 
           # operspywhois: show opers (users/auspex) the +s channels a user is in. Values:
         # maxaway: Maximum length of an away message.
         maxaway="200">
 
+#-#-#-#-#-#-#-#-#-#-#-#-# PATHS CONFIGURATION #-#-#-#-#-#-#-#-#-#-#-#-#
+#                                                                     #
+# This configuration tag defines the location that InspIRCd stores    #
+# various types of files such as configuration files, log files and   #
+# modules. You will probably not need to change these from the values #
+# set when InspIRCd was built unless you are using a binary package   #
+# where you do not have the ability to set build time configuration.  #
+#<path configdir="conf" datadir="data" logdir="logs" moduledir="modules">
 
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
 # Logging
 # provide almost all the features of InspIRCd. :)                     #
 #                                                                     #
 # The default does nothing -- we include it for simplicity for you.   #
-<include file="conf/examples/modules.conf.example">
+<include file="examples/modules.conf.example">
 
 # Here are some pre-built modules.conf files that closely match the
 # default configurations of some popular IRCd's. You still may want to
 # recommended that you make your own modules file based on modules.conf.example.
 
 # Settings similar to UnrealIRCd defaults.
-#<include file="conf/examples/modules/unrealircd.conf.example">
+#<include file="examples/modules/unrealircd.conf.example">
 
 # Settings similar to Charybdis IRCd defaults.
-#<include file="conf/examples/modules/charybdis.conf.example">
+#<include file="examples/modules/charybdis.conf.example">
 
 
 #########################################################################
index 7e1a9f5add99a83f689dc43cefa6988c03f317e0..228d96312936702e79b9527b5f8626ec85e233b2 100644 (file)
 # specify some censor tags. See also:                                 #
 # http://wiki.inspircd.org/Modules/censor                             #
 #
-#<include file="conf/examples/censor.conf.example">
+#<include file="examples/censor.conf.example">
 
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
 # CGI:IRC module: Adds support for automatic host changing in CGI:IRC
 # specfiy below the path to the filter.conf file, or define some      #
 # <filter> tags.                                                      #
 #                                                                     #
-#<include file="conf/examples/filter.conf.example">
+#<include file="examples/filter.conf.example">
 
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
 # Gecosban: Implements extended ban r:, which stops anyone matching
 # specify below the path to the helpop.conf file, or if you like to   #
 # make a mess, define your helpop tags in this conf.                  #
 #                                                                     #
-#<include file="conf/examples/inspircd.helpop-full.example">
+#<include file="examples/inspircd.helpop-full.example">
 
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
 # HIDECHANS module: Allows opers to hide their channels list from non-
 #                 Read the comment above <connect:allowmotdcolors> in #
 #                 inspircd.conf.example for details.                  #
 #                                                                     #
-#<opermotd file="conf/examples/opermotd.txt.example" onoper="yes" processcolors="false">
+#<opermotd file="examples/opermotd.txt.example" onoper="yes" processcolors="false">
 
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
 # Override module: Adds support for oper override
index 33456d84b63a9bea91d006e60eb0efe8b7b98c4a..bf5acbbc8a5f0333b559ed504139899211f7ebe3 100644 (file)
@@ -44,7 +44,7 @@ class CoreExport ConfigTag : public refcountbase
        /** 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);
+       long getInt(const std::string& key, long def = 0, long min = LONG_MIN, long max = LONG_MAX);
        /** 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 */
@@ -184,6 +184,32 @@ class CoreExport ServerConfig
        void CrossCheckConnectBlocks(ServerConfig* current);
 
  public:
+       class ServerPaths
+       {
+        public:
+               /** Config path */
+               std::string Config;
+
+               /** Data path */
+               std::string Data;
+
+               /** Log path */
+               std::string Log;
+
+               /** Module path */
+               std::string Module;
+
+               ServerPaths()
+                       : Config(CONFIG_PATH)
+                       , Data(DATA_PATH)
+                       , Log(LOG_PATH)
+                       , Module(MOD_PATH) { }
+
+               std::string PrependConfig(const std::string& fn) const { return ServerConfig::ExpandPath(Config, fn); }
+               std::string PrependData(const std::string& fn) const { return ServerConfig::ExpandPath(Data, fn); }
+               std::string PrependLog(const std::string& fn) const { return ServerConfig::ExpandPath(Log, fn); }
+               std::string PrependModule(const std::string& fn) const { return ServerConfig::ExpandPath(Module, fn); }
+       };
 
        /** Get a configuration tag
         * @param tag The name of the tag to get
@@ -220,6 +246,9 @@ class CoreExport ServerConfig
         */
        ServerLimits Limits;
 
+       /** Locations of various types of file (config, module, etc). */
+       ServerPaths Paths;
+
        /** Configuration parsed from the command line.
         */
        CommandLineConf cmdline;
@@ -239,9 +268,9 @@ class CoreExport ServerConfig
         */
        std::string ServerName;
 
-       /** Notice to give to users when they are Xlined
+       /** Notice to give to users when they are banned by an XLine
         */
-       std::string MoronBanner;
+       std::string XLineMessage;
 
        /* Holds the network name the local server
         * belongs to. This is an arbitary field defined
@@ -333,13 +362,6 @@ class CoreExport ServerConfig
         */
        char DisabledCModes[64];
 
-       /** The full path to the modules directory.
-        * This is either set at compile time, or
-        * overridden in the configuration file via
-        * the \<path> tag.
-        */
-       std::string ModPath;
-
        /** 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.
@@ -508,7 +530,7 @@ class CoreExport ServerConfig
 
        /** Returns true if the given string starts with a windows drive letter
         */
-       bool StartsWithWindowsDriveLetter(const std::string &path);
+       static bool StartsWithWindowsDriveLetter(const std::string& path);
 
        bool ApplyDisabledCommands(const std::string& data);
 
@@ -523,7 +545,13 @@ class CoreExport ServerConfig
         * @return True if the file exists and is readable.
         */
        static bool FileExists(const char* file);
-       
+
+       /** Expands a path fragment to a full path.
+        * @param base The base path to expand from
+        * @param fragment The path fragment to expand on top of base.
+        */
+       static std::string ExpandPath(const std::string& base, const std::string& fragment);
+
        /** Escapes a value for storage in a configuration key.
         * @param str The string to escape.
         * @param xml Are we using the XML config format?
index aaf9b5cda3b22d9de0696c51c8aff10957f6cb75..aa11a2b82ac5b2adb52452cc17691002c5899f67 100644 (file)
@@ -133,7 +133,7 @@ struct CoreExport ConnectClass : public refcountbase
 
        /** If set to true, no user DNS lookups are to be performed
         */
-       bool nouserdns;
+       bool resolvehostnames;
 
        /** Create a new connect class with no settings.
         */
index d82ad6c233b4345d838d61b41113df96c72c503d..c7913606f44ecdbce5907d66d88897c9a8d40575 100644 (file)
@@ -162,6 +162,9 @@ void Channel::SetDefaultModes()
                ModeHandler* mode = ServerInstance->Modes->FindMode(*n, MODETYPE_CHANNEL);
                if (mode)
                {
+                       if (mode->GetPrefixRank())
+                               continue;
+
                        if (mode->GetNumParams(true))
                                list.GetToken(parameter);
                        else
@@ -223,7 +226,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co
 
        if (!chan)
        {
-               privs = "o";
+               privs = ServerInstance->Config->DefaultModes.substr(0, ServerInstance->Config->DefaultModes.find(' '));
 
                if (override == false)
                {
@@ -343,7 +346,7 @@ void Channel::ForceJoin(User* user, const std::string* privs, bool bursting, boo
                for (std::string::const_iterator i = privs->begin(); i != privs->end(); ++i)
                {
                        ModeHandler* mh = ServerInstance->Modes->FindMode(*i, MODETYPE_CHANNEL);
-                       if (mh)
+                       if (mh && mh->GetPrefixRank())
                        {
                                std::string nick = user->nick;
                                /* Set, and make sure that the mode handler knows this mode was now set */
index 1352f0e786b0f24a595340f5158d0880d091f52e..f352443d0a501f5926d1223e1a91ab5b65309ca4 100644 (file)
@@ -199,7 +199,7 @@ class ModuleHostnameLookup : public Module
 
        void OnUserInit(LocalUser *user)
        {
-               if (!DNS || user->MyClass->nouserdns)
+               if (!DNS || !user->MyClass->resolvehostnames)
                {
                        user->WriteNotice("*** Skipping host resolution (disabled by server administrator)");
                        return;
index 28daf7311f01562b33c5a3872028cd99e932dfa0..8a1c9a820e7378d797a7f261a7a96eb1f2511f67 100644 (file)
@@ -342,12 +342,10 @@ class ModuleWhoWas : public Module
        void OnRehash(User* user)
        {
                ConfigTag* tag = ServerInstance->Config->ConfValue("whowas");
-               int NewGroupSize = tag->getInt("groupsize");
-               int NewMaxGroups = tag->getInt("maxgroups");
+               int NewGroupSize = tag->getInt("groupsize", 10, 0, 10000);
+               int NewMaxGroups = tag->getInt("maxgroups", 10240, 0, 1000000);
                int NewMaxKeep = InspIRCd::Duration(tag->getString("maxkeep"));
 
-               RangeCheck(NewGroupSize, 0, 10000, 10, "<whowas:groupsize>");
-               RangeCheck(NewMaxGroups, 0, 1000000, 10240, "<whowas:maxgroups>");
                RangeCheck(NewMaxKeep, 3600, INT_MAX, 3600, "<whowas:maxkeep>");
 
                if ((NewGroupSize == cmd.WhoWasGroupSize) && (NewMaxGroups == cmd.WhoWasMaxGroups) && (NewMaxKeep == cmd.WhoWasMaxKeep))
index 3289cf396bdff40832291d58f8cecf05ed59f3f1..1783e901e8f8a23f725a537479fab617a36b2c8e 100644 (file)
@@ -323,9 +323,10 @@ void ParseStack::DoReadFile(const std::string& key, const std::string& name, int
        if (exec && (flags & FLAG_NO_EXEC))
                throw CoreException("Invalid <execfiles> tag in file included with noexec=\"yes\"");
 
-       FileWrapper file(exec ? popen(name.c_str(), "r") : fopen(name.c_str(), "r"), exec);
+       std::string path = ServerInstance->Config->Paths.PrependConfig(name);
+       FileWrapper file(exec ? popen(name.c_str(), "r") : fopen(path.c_str(), "r"), exec);
        if (!file)
-               throw CoreException("Could not read \"" + name + "\" for \"" + key + "\" file");
+               throw CoreException("Could not read \"" + path + "\" for \"" + key + "\" file");
 
        file_cache& cache = FilesOutput[key];
        cache.clear();
@@ -345,23 +346,24 @@ void ParseStack::DoReadFile(const std::string& key, const std::string& name, int
 
 bool ParseStack::ParseFile(const std::string& name, int flags, const std::string& mandatory_tag)
 {
-       ServerInstance->Logs->Log("CONFIG", LOG_DEBUG, "Reading file %s", name.c_str());
+       std::string path = ServerInstance->Config->Paths.PrependConfig(name);
+       ServerInstance->Logs->Log("CONFIG", LOG_DEBUG, "Reading file %s", path.c_str());
        for (unsigned int t = 0; t < reading.size(); t++)
        {
                if (std::string(name) == reading[t])
                {
-                       throw CoreException("File " + name + " is included recursively (looped inclusion)");
+                       throw CoreException("File " + path + " is included recursively (looped inclusion)");
                }
        }
 
        /* It's not already included, add it to the list of files we've loaded */
 
-       FileWrapper file(fopen(name.c_str(), "r"));
+       FileWrapper file(fopen(path.c_str(), "r"));
        if (!file)
-               throw CoreException("Could not read \"" + name + "\" for include");
+               throw CoreException("Could not read \"" + path + "\" for include");
 
-       reading.push_back(name);
-       Parser p(*this, flags, file, name, mandatory_tag);
+       reading.push_back(path);
+       Parser p(*this, flags, file, path, mandatory_tag);
        bool ok = p.outer_parse();
        reading.pop_back();
        return ok;
@@ -420,7 +422,7 @@ std::string ConfigTag::getString(const std::string& key, const std::string& def)
        return res;
 }
 
-long ConfigTag::getInt(const std::string &key, long def)
+long ConfigTag::getInt(const std::string &key, long def, long min, long max)
 {
        std::string result;
        if(!readString(key, result))
@@ -434,15 +436,21 @@ long ConfigTag::getInt(const std::string &key, long def)
        switch (toupper(*res_tail))
        {
                case 'K':
-                       res= res* 1024;
+                       res = res * 1024;
                        break;
                case 'M':
-                       res= res* 1024 * 1024;
+                       res = res * 1024 * 1024;
                        break;
                case 'G':
-                       res= res* 1024 * 1024 * 1024;
+                       res = res * 1024 * 1024 * 1024;
                        break;
        }
+       if (res < min || res > max)
+       {
+               ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "WARNING: <%s:%s> value of %ld is not between %ld and %ld; set to %ld.",
+                       tag.c_str(), key.c_str(), res, min, max, def);
+               res = def;
+       }
        return res;
 }
 
index 047a2b5cdcc9b214f08879c65c5210deaf2aacce..af7a8ca59889f5fdad9ddbfba4acc39ebf12cbe7 100644 (file)
@@ -44,16 +44,6 @@ ServerConfig::ServerConfig()
        c_ipv6_range = 128;
 }
 
-template<typename T, typename V>
-static void range(T& value, V min, V max, V def, const char* msg)
-{
-       if (value >= (T)min && value <= (T)max)
-               return;
-       ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "WARNING: %s value of %ld is not between %ld and %ld; set to %ld.",
-               msg, (long)value, (long)min, (long)max, (long)def);
-       value = def;
-}
-
 static void ValidHost(const std::string& p, const std::string& msg)
 {
        int num_dots = 0;
@@ -309,7 +299,7 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
                        me->maxchans = tag->getInt("maxchans", me->maxchans);
                        me->maxconnwarn = tag->getBool("maxconnwarn", me->maxconnwarn);
                        me->limit = tag->getInt("limit", me->limit);
-                       me->nouserdns = tag->getBool("nouserdns", me->nouserdns);
+                       me->resolvehostnames = tag->getBool("resolvehostnames", me->resolvehostnames);
 
                        ClassMap::iterator oldMask = oldBlocksByMask.find(typeMask);
                        if (oldMask != oldBlocksByMask.end())
@@ -350,7 +340,7 @@ static const DeprecatedConfig ChangedConfig[] = {
        { "module",      "name",        "m_chanprotect.so", "has been replaced with m_customprefix as of 2.2" },
        { "module",      "name",        "m_halfop.so",      "has been replaced with m_customprefix as of 2.2" },
        { "options",     "cyclehosts",  "",                 "has been replaced with m_hostcycle as of 2.2" },
-       { "performance", "nouserdns",   "",                 "has been moved to <connect:nouserdns> as of 2.2" }
+       { "performance", "nouserdns",   "",                 "has been moved to <connect:resolvehostnames> as of 2.2" }
 };
 
 void ServerConfig::Fill()
@@ -359,9 +349,10 @@ void ServerConfig::Fill()
        ConfigTag* security = ConfValue("security");
        if (sid.empty())
        {
-               ServerName = ConfValue("server")->getString("name");
-               sid = ConfValue("server")->getString("id");
+               ServerName = ConfValue("server")->getString("name", "irc.example.com");
                ValidHost(ServerName, "<server:name>");
+
+               sid = ConfValue("server")->getString("id");
                if (!sid.empty() && !InspIRCd::IsSID(sid))
                        throw CoreException(sid + " is not a valid server ID. A server ID must be 3 characters long, with the first character a digit and the next two characters a digit or letter.");
        }
@@ -383,22 +374,21 @@ void ServerConfig::Fill()
        PrefixPart = options->getString("prefixpart");
        SuffixPart = options->getString("suffixpart");
        FixedPart = options->getString("fixedpart");
-       SoftLimit = ConfValue("performance")->getInt("softlimit", ServerInstance->SE->GetMaxFds());
+       SoftLimit = ConfValue("performance")->getInt("softlimit", ServerInstance->SE->GetMaxFds(), 10, ServerInstance->SE->GetMaxFds());
        CCOnConnect = ConfValue("performance")->getBool("clonesonconnect", true);
        MaxConn = ConfValue("performance")->getInt("somaxconn", SOMAXCONN);
-       MoronBanner = options->getString("moronbanner", "You're banned!");
+       XLineMessage = options->getString("xlinemessage", options->getString("moronbanner", "You're banned!"));
        ServerDesc = ConfValue("server")->getString("description", "Configure Me");
        Network = ConfValue("server")->getString("network", "Network");
        AdminName = ConfValue("admin")->getString("name", "");
        AdminEmail = ConfValue("admin")->getString("email", "null@example.com");
        AdminNick = ConfValue("admin")->getString("nick", "admin");
-       ModPath = ConfValue("path")->getString("moduledir", MOD_PATH);
-       NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240);
+       NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240, 1024, 65534);
        dns_timeout = ConfValue("dns")->getInt("timeout", 5);
        DisabledCommands = ConfValue("disabled")->getString("commands", "");
        DisabledDontExist = ConfValue("disabled")->getBool("fakenonexistant");
        UserStats = security->getString("userstats");
-       CustomVersion = security->getString("customversion", Network + " IRCd");
+       CustomVersion = security->getString("customversion");
        HideSplits = security->getBool("hidesplits");
        HideBans = security->getBool("hidebans");
        HideWhoisServer = security->getString("hidewhois");
@@ -409,8 +399,8 @@ void ServerConfig::Fill()
        CycleHostsFromUser = options->getBool("cyclehostsfromuser");
        UndernetMsgPrefix = options->getBool("ircumsgprefix");
        FullHostInTopic = options->getBool("hostintopic");
-       MaxTargets = security->getInt("maxtargets", 20);
-       DefaultModes = options->getString("defaultmodes", "nt");
+       MaxTargets = security->getInt("maxtargets", 20, 1, 31);
+       DefaultModes = options->getString("defaultmodes", "not");
        PID = ConfValue("pid")->getString("file");
        MaxChans = ConfValue("channels")->getInt("users", 20);
        OperMaxChans = ConfValue("channels")->getInt("opers", 60);
@@ -426,16 +416,16 @@ void ServerConfig::Fill()
        Limits.MaxGecos = ConfValue("limits")->getInt("maxgecos", 128);
        Limits.MaxAway = ConfValue("limits")->getInt("maxaway", 200);
        Limits.MaxLine = ConfValue("limits")->getInt("maxline", 512);
+       Paths.Config = ConfValue("path")->getString("configdir", CONFIG_PATH);
+       Paths.Data = ConfValue("path")->getString("datadir", DATA_PATH);
+       Paths.Log = ConfValue("path")->getString("logdir", LOG_PATH);
+       Paths.Module = ConfValue("path")->getString("moduledir", MOD_PATH);
        InvBypassModes = options->getBool("invitebypassmodes", true);
        NoSnoticeStack = options->getBool("nosnoticestack", false);
 
        if (Network.find(' ') != std::string::npos)
                throw CoreException(Network + " is not a valid network name. A network name must not contain spaces.");
 
-       range(SoftLimit, 10, ServerInstance->SE->GetMaxFds(), ServerInstance->SE->GetMaxFds(), "<performance:softlimit>");
-       range(MaxTargets, 1, 31, 20, "<security:maxtargets>");
-       range(NetBufferSize, 1024, 65534, 10240, "<performance:netbuffersize>");
-
        std::string defbind = options->getString("defaultbind");
        if (assign(defbind) == "ipv4")
        {
@@ -461,6 +451,10 @@ void ServerConfig::Fill()
                std::string server;
                if (!tag->readString("server", server))
                        throw CoreException("<uline> tag missing server at " + tag->getTagLocation());
+
+               if (ServerName == server)
+                       throw CoreException("Servers should not uline themselves (at " + tag->getTagLocation() + ")");
+
                ulines[assign(server)] = tag->getBool("silent");
        }
 
@@ -565,7 +559,7 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
                                        {
                                                errstr << ' ' << ChangedConfig[index].key << "=\"" << ChangedConfig[index].value << "\"";
                                        }
-                                       errstr << "> - " << ChangedConfig[index].reason << " (at " << i->second->getTagLocation() << ")\n";
+                                       errstr << "> - " << ChangedConfig[index].reason << " (at " << i->second->getTagLocation() << ")" << std::endl;
                                }
                        }
                }
@@ -588,6 +582,11 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
        if (valid)
                ServerInstance->WritePID(this->PID);
 
+       ConfigTagList binds = ConfTags("bind");
+       if (binds.first == binds.second)
+                errstr << "Possible configuration error: you have not defined any <bind> blocks." << std::endl
+                        << "You will need to do this if you want clients to be able to connect!" << std::endl;
+
        if (old)
        {
                // On first run, ports are bound later on
@@ -795,6 +794,15 @@ std::string ServerConfig::Escape(const std::string& str, bool xml)
        return escaped;
 }
 
+std::string ServerConfig::ExpandPath(const std::string& base, const std::string& fragment)
+{
+       // The fragment is an absolute path, don't modify it.
+       if (fragment[0] == '/' || ServerConfig::StartsWithWindowsDriveLetter(fragment))
+               return fragment;
+
+       return base + '/' + fragment;
+}
+
 const char* ServerConfig::CleanFilename(const char* name)
 {
        const char* p = name + strlen(name);
index 59c65b931d34d6617b66e997695eef139c9def08..f2095c4a2d17bdd9b5bb1d091a0b4676ebf2670d 100644 (file)
@@ -207,7 +207,7 @@ void InspIRCd::WritePID(const std::string &filename)
 #ifndef _WIN32
        std::string fname(filename);
        if (fname.empty())
-               fname = DATA_PATH "/inspircd.pid";
+               fname = ServerInstance->Config->Paths.PrependData("inspircd.pid");
        std::ofstream outfile(fname.c_str());
        if (outfile.is_open())
        {
index 47c726c51b648ec35ed177f2d27654235fb04675..61ac517c70342938cceab95175a1bf89378b1305 100644 (file)
@@ -112,7 +112,7 @@ void LogManager::OpenFileLogs()
                        loglevel = LOG_NONE;
                }
                FileWriter* fw;
-               std::string target = tag->getString("target");
+               std::string target = ServerInstance->Config->Paths.PrependLog(tag->getString("target"));
                std::map<std::string, FileWriter*>::iterator fwi = logmap.find(target);
                if (fwi == logmap.end())
                {
index 92a7e0a32580cfb01b3d798abcf93f4d1aa1cd60..750a1c448002c8cc17b416cdf7618b8e8160ab22 100644 (file)
@@ -37,7 +37,7 @@ bool ModuleManager::Load(const std::string& filename, bool defer)
        if (filename.find('/') != std::string::npos)
                return false;
 
-       const std::string moduleFile = ServerInstance->Config->ModPath + "/" + filename;
+       const std::string moduleFile = ServerInstance->Config->Paths.PrependModule(filename);
 
        if (!ServerConfig::FileExists(moduleFile.c_str()))
        {
@@ -190,7 +190,7 @@ void ModuleManager::LoadAll()
        std::cout << std::endl << "Loading core commands";
        fflush(stdout);
 
-       DIR* library = opendir(ServerInstance->Config->ModPath.c_str());
+       DIR* library = opendir(ServerInstance->Config->Paths.Module.c_str());
        if (library)
        {
                dirent* entry = NULL;
index 5fc8ffc471bddb6ea0ad99b7573b07d6cbd4f08f..47c99408838ee58136c549f164f6283ee856a8d6 100644 (file)
@@ -577,7 +577,8 @@ FileReader::FileReader(const std::string& filename)
 void FileReader::Load(const std::string& filename)
 {
        // If the file is stored in the file cache then we used that version instead.
-       ConfigFileCache::iterator it = ServerInstance->Config->Files.find(filename);
+       std::string realName = ServerInstance->Config->Paths.PrependConfig(filename);
+       ConfigFileCache::iterator it = ServerInstance->Config->Files.find(realName);
        if (it != ServerInstance->Config->Files.end())
        {
                this->lines = it->second;
@@ -586,7 +587,7 @@ void FileReader::Load(const std::string& filename)
        {
                lines.clear();
 
-               std::ifstream stream(filename.c_str());
+               std::ifstream stream(realName.c_str());
                if (!stream.is_open())
                        throw CoreException(filename + " does not exist or is not readable!");
 
index a3502a57b2211005454c5d36ff18e3764bfe76c2..28755f05e42d2483cc7dcb7996b61d14f01d8f8a 100644 (file)
@@ -684,10 +684,10 @@ class ModuleSSLGnuTLS : public Module
 
                ConfigTag* Conf = ServerInstance->Config->ConfValue("gnutls");
 
-               cafile = Conf->getString("cafile", CONFIG_PATH "/ca.pem");
-               crlfile = Conf->getString("crlfile", CONFIG_PATH "/crl.pem");
-               certfile = Conf->getString("certfile", CONFIG_PATH "/cert.pem");
-               keyfile = Conf->getString("keyfile", CONFIG_PATH "/key.pem");
+               cafile = ServerInstance->Config->Paths.PrependConfig(Conf->getString("cafile", "ca.pem"));
+               crlfile = ServerInstance->Config->Paths.PrependConfig(Conf->getString("crlfile", "crl.pem"));
+               certfile = ServerInstance->Config->Paths.PrependConfig(Conf->getString("certfile", "cert.pem"));
+               keyfile = ServerInstance->Config->Paths.PrependConfig(Conf->getString("keyfile", "key.pem"));
                int dh_bits = Conf->getInt("dhbits");
                std::string hashname = Conf->getString("hash", "md5");
 
index 29f574fd0b0dcf6d11116c94c229c7007784dba8..c94527ab07e2f63c00422404b9f6ee19dd462e4b 100644 (file)
@@ -558,10 +558,10 @@ class ModuleSSLOpenSSL : public Module
 
                ConfigTag* conf = ServerInstance->Config->ConfValue("openssl");
 
-               cafile   = conf->getString("cafile", CONFIG_PATH "/ca.pem");
-               certfile = conf->getString("certfile", CONFIG_PATH "/cert.pem");
-               keyfile  = conf->getString("keyfile", CONFIG_PATH "/key.pem");
-               dhfile   = conf->getString("dhfile", CONFIG_PATH "/dhparams.pem");
+               cafile   = ServerInstance->Config->Paths.PrependConfig(conf->getString("cafile", "ca.pem"));
+               certfile = ServerInstance->Config->Paths.PrependConfig(conf->getString("certfile", "cert.pem"));
+               keyfile  = ServerInstance->Config->Paths.PrependConfig(conf->getString("keyfile", "key.pem"));
+               dhfile   = ServerInstance->Config->Paths.PrependConfig(conf->getString("dhfile", "dhparams.pem"));
                std::string hash = conf->getString("hash", "md5");
 
                iohook.digest = EVP_get_digestbyname(hash.c_str());
index 8e7d76f4aa2568dfc5eda20821b8eb7b91aa049f..f80c6d16dc2c53bef549b4767027794cfa431fa7 100644 (file)
@@ -104,22 +104,12 @@ public:
        void ReadConf()
        {
                ConfigTag* tag = ServerInstance->Config->ConfValue("blockcaps");
-               percent = tag->getInt("percent", 100);
-               minlen = tag->getInt("minlen", 1);
+               percent = tag->getInt("percent", 100, 1, 100);
+               minlen = tag->getInt("minlen", 1, 1, ServerInstance->Config->Limits.MaxLine);
                std::string hmap = tag->getString("capsmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
                memset(capsmap, 0, sizeof(capsmap));
                for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
                        capsmap[(unsigned char)*n] = 1;
-               if (percent < 1 || percent > 100)
-               {
-                       ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "<blockcaps:percent> out of range, setting to default of 100.");
-                       percent = 100;
-               }
-               if (minlen < 1 || minlen > ServerInstance->Config->Limits.MaxLine)
-               {
-                       ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "<blockcaps:minlen> out of range, setting to default of 1.");
-                       minlen = 1;
-               }
        }
 
        Version GetVersion() CXX11_OVERRIDE
index 65671632d9502aca3bb6213b93ecc3e6ee6dfd36..2352fa2171ef0a99fb2e9de88d5bfa859b56fe69 100644 (file)
@@ -206,7 +206,7 @@ class ModuleCgiIRC : public Module
                RecheckClass(user);
 
                // Don't create the resolver if the core couldn't put the user in a connect class or when dns is disabled
-               if (user->quitting || !DNS || user->MyClass->nouserdns)
+               if (user->quitting || !DNS || !user->MyClass->resolvehostnames)
                        return;
 
                CGIResolver* r = new CGIResolver(*this->DNS, this, cmd.notify, newip, user, (was_pass ? "PASS" : "IDENT"), waiting);
index c730602a15705529ff8b96aefbf8bb3e6a799ce4..36e10ec5b99e8247ffbd6a43fb571bdbfee77fba 100644 (file)
@@ -43,18 +43,9 @@ class ModuleConnectBan : public Module
        {
                ConfigTag* tag = ServerInstance->Config->ConfValue("connectban");
 
-               ipv4_cidr = tag->getInt("ipv4cidr", 32);
-               if (ipv4_cidr == 0)
-                       ipv4_cidr = 32;
-
-               ipv6_cidr = tag->getInt("ipv6cidr", 128);
-               if (ipv6_cidr == 0)
-                       ipv6_cidr = 128;
-
-               threshold = tag->getInt("threshold", 10);
-               if (threshold == 0)
-                       threshold = 10;
-
+               ipv4_cidr = tag->getInt("ipv4cidr", 32, 1, 32);
+               ipv6_cidr = tag->getInt("ipv6cidr", 128, 1, 128);
+               threshold = tag->getInt("threshold", 10, 1);
                banduration = InspIRCd::Duration(tag->getString("duration", "10m"));
                if (banduration == 0)
                        banduration = 10*60;
index 10347ac67534a83d58b0c5c28b270d28da2857c3..99e525398ba00075e0fd15a37bc23619c9b9f99f 100644 (file)
@@ -298,7 +298,7 @@ class ModuleNationalChars : public Module
        /*so Bynets Unreal distribution stuff*/
        void loadtables(std::string filename, unsigned char ** tables, unsigned char cnt, char faillimit)
        {
-               std::ifstream ifs(filename.c_str());
+               std::ifstream ifs(ServerInstance->Config->Paths.PrependConfig(filename).c_str());
                if (ifs.fail())
                {
                        ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "loadtables() called for missing file: %s", filename.c_str());
index df6f4c10c5e54e704362692dab16114546f7aba1..63eb6d3ee7bb36c2e050d17b198eace1d38ef288 100644 (file)
@@ -36,7 +36,7 @@ class ModuleXLineDB : public Module
                 *              ...and so is discarding all current in-memory XLines for the ones in the database.
                 */
                ConfigTag* Conf = ServerInstance->Config->ConfValue("xlinedb");
-               xlinedbpath = Conf->getString("filename", DATA_PATH "/xline.db");
+               xlinedbpath = ServerInstance->Config->Paths.PrependData(Conf->getString("filename", "xline.db"));
 
                // Read xlines before attaching to events
                ReadDatabase();
index 605bc1f698657e032d15cf979ebbefc45bc44d83..538feaade093e2d1bc2cb36e3eb3c6002b7c97ea 100644 (file)
@@ -129,8 +129,8 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
                {
                        /* user banned */
                        ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Positive hit for " + New->GetIPString());
-                       if (!ServerInstance->Config->MoronBanner.empty())
-                               New->WriteNotice("*** " +  ServerInstance->Config->MoronBanner);
+                       if (!ServerInstance->Config->XLineMessage.empty())
+                               New->WriteNotice("*** " +  ServerInstance->Config->XLineMessage);
                        this->QuitUser(New, b->Reason);
                        return;
                }
index b49587b389935f2042aa810fa348ebeac0e87af6..21079f0cc2e7adc12b114e404ae8ed8138a6314b 100644 (file)
@@ -1308,7 +1308,7 @@ ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask)
        : config(tag), type(t), fakelag(true), name("unnamed"), registration_timeout(0), host(mask),
        pingtime(0), softsendqmax(0), hardsendqmax(0), recvqmax(0),
        penaltythreshold(0), commandrate(0), maxlocal(0), maxglobal(0), maxconnwarn(true), maxchans(0),
-       limit(0), nouserdns(false)
+       limit(0), resolvehostnames(true)
 {
 }
 
@@ -1318,7 +1318,7 @@ ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask, cons
        softsendqmax(parent.softsendqmax), hardsendqmax(parent.hardsendqmax), recvqmax(parent.recvqmax),
        penaltythreshold(parent.penaltythreshold), commandrate(parent.commandrate),
        maxlocal(parent.maxlocal), maxglobal(parent.maxglobal), maxconnwarn(parent.maxconnwarn), maxchans(parent.maxchans),
-       limit(parent.limit), nouserdns(parent.nouserdns)
+       limit(parent.limit), resolvehostnames(parent.resolvehostnames)
 {
 }
 
@@ -1341,5 +1341,5 @@ void ConnectClass::Update(const ConnectClass* src)
        maxconnwarn = src->maxconnwarn;
        maxchans = src->maxchans;
        limit = src->limit;
-       nouserdns = src->nouserdns;
+       resolvehostnames = src->resolvehostnames;
 }
index 44ae1e98ecbf980ba12e415bdf77bfdbe4705591..bc8e596bd376a6cbf38ca647e82f378aafcf69ab 100644 (file)
@@ -533,8 +533,8 @@ void XLine::DefaultApply(User* u, const std::string &line, bool bancache)
 {
        const std::string banReason = line + "-Lined: " + reason;
 
-       if (!ServerInstance->Config->MoronBanner.empty())
-               u->WriteNotice("*** " + ServerInstance->Config->MoronBanner);
+       if (!ServerInstance->Config->XLineMessage.empty())
+               u->WriteNotice("*** " + ServerInstance->Config->XLineMessage);
 
        if (ServerInstance->Config->HideBans)
                ServerInstance->Users->QuitUser(u, line + "-Lined", banReason.c_str());