summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-12-18 23:40:15 +0100
committerAttila Molnar <attilamolnar@hush.com>2014-12-18 23:40:15 +0100
commit6d25ad273c7fd1d21b9c392678f3472eb53c6e83 (patch)
tree02f05befd019952698ad143b6065390daf826b6d
parent8f13eddcd3f23a2c47e88e176f2e5032f8227450 (diff)
parentb74da78a617c4eeef6c14364ca5a0fef5460d504 (diff)
Merge branch 'master+serverlimits'
-rw-r--r--include/configreader.h9
-rw-r--r--src/configreader.cpp38
2 files changed, 27 insertions, 20 deletions
diff --git a/include/configreader.h b/include/configreader.h
index 342743991..88279004f 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -117,13 +117,10 @@ class ServerLimits
/** Maximum hostname length */
size_t MaxHost;
- /** Creating the class initialises it to the defaults
- * as in 1.1's ./configure script. Reading other values
- * from the config will change these values.
+ /** Read all limits from a config tag. Limits which aren't specified in the tag are set to a default value.
+ * @param tag Configuration tag to read the limits from
*/
- ServerLimits() : NickMax(31), ChanMax(64), MaxModes(20), IdentMax(12),
- MaxQuit(255), MaxTopic(307), MaxKick(255), MaxGecos(128), MaxAway(200),
- MaxLine(512), MaxHost(64) { }
+ ServerLimits(ConfigTag* tag);
};
struct CommandLineConf
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 54c32d846..d52f3de13 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -29,7 +29,30 @@
#include "configparser.h"
#include <iostream>
+ServerLimits::ServerLimits(ConfigTag* tag)
+ : NickMax(tag->getInt("maxnick", 32))
+ , ChanMax(tag->getInt("maxchan", 64))
+ , MaxModes(tag->getInt("maxmodes", 20))
+ , IdentMax(tag->getInt("maxident", 11))
+ , MaxQuit(tag->getInt("maxquit", 255))
+ , MaxTopic(tag->getInt("maxtopic", 307))
+ , MaxKick(tag->getInt("maxkick", 255))
+ , MaxGecos(tag->getInt("maxgecos", 128))
+ , MaxAway(tag->getInt("maxaway", 200))
+ , MaxLine(tag->getInt("maxline", 512))
+ , MaxHost(tag->getInt("maxhost", 64))
+{
+}
+
+static ConfigTag* CreateEmptyTag()
+{
+ std::vector<KeyVal>* items;
+ return ConfigTag::create("empty", "<auto>", 0, items);
+}
+
ServerConfig::ServerConfig()
+ : EmptyTag(CreateEmptyTag())
+ , Limits(EmptyTag)
{
RawLog = HideBans = HideSplits = UndernetMsgPrefix = false;
WildcardIPv6 = InvBypassModes = true;
@@ -41,9 +64,6 @@ ServerConfig::ServerConfig()
OperMaxChans = 30;
c_ipv4_range = 32;
c_ipv6_range = 128;
-
- std::vector<KeyVal>* items;
- EmptyTag = ConfigTag::create("empty", "<auto>", 0, items);
}
ServerConfig::~ServerConfig()
@@ -401,17 +421,7 @@ void ServerConfig::Fill()
OperMaxChans = ConfValue("channels")->getInt("opers");
c_ipv4_range = ConfValue("cidr")->getInt("ipv4clone", 32);
c_ipv6_range = ConfValue("cidr")->getInt("ipv6clone", 128);
- Limits.NickMax = ConfValue("limits")->getInt("maxnick", 32);
- Limits.ChanMax = ConfValue("limits")->getInt("maxchan", 64);
- Limits.MaxModes = ConfValue("limits")->getInt("maxmodes", 20);
- Limits.IdentMax = ConfValue("limits")->getInt("maxident", 11);
- Limits.MaxHost = ConfValue("limits")->getInt("maxhost", 64);
- Limits.MaxQuit = ConfValue("limits")->getInt("maxquit", 255);
- Limits.MaxTopic = ConfValue("limits")->getInt("maxtopic", 307);
- Limits.MaxKick = ConfValue("limits")->getInt("maxkick", 255);
- Limits.MaxGecos = ConfValue("limits")->getInt("maxgecos", 128);
- Limits.MaxAway = ConfValue("limits")->getInt("maxaway", 200);
- Limits.MaxLine = ConfValue("limits")->getInt("maxline", 512);
+ Limits = ServerLimits(ConfValue("limits"));
Paths.Config = ConfValue("path")->getString("configdir", INSPIRCD_CONFIG_PATH);
Paths.Data = ConfValue("path")->getString("datadir", INSPIRCD_DATA_PATH);
Paths.Log = ConfValue("path")->getString("logdir", INSPIRCD_LOG_PATH);