From 94b3599a48f3b53683327be3703a8471f81b916b Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 9 Dec 2014 12:30:21 +0100 Subject: Initialize ServerConfig::EmptyTag using the init list --- src/configreader.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/configreader.cpp b/src/configreader.cpp index 54c32d846..df58ec812 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -29,7 +29,14 @@ #include "configparser.h" #include +static ConfigTag* CreateEmptyTag() +{ + std::vector* items; + return ConfigTag::create("empty", "", 0, items); +} + ServerConfig::ServerConfig() + : EmptyTag(CreateEmptyTag()) { RawLog = HideBans = HideSplits = UndernetMsgPrefix = false; WildcardIPv6 = InvBypassModes = true; @@ -41,9 +48,6 @@ ServerConfig::ServerConfig() OperMaxChans = 30; c_ipv4_range = 32; c_ipv6_range = 128; - - std::vector* items; - EmptyTag = ConfigTag::create("empty", "", 0, items); } ServerConfig::~ServerConfig() -- cgit v1.2.3 From 1c64da19e1f08e23fd7020427e89d1d5af35aa1c Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 9 Dec 2014 12:35:31 +0100 Subject: Add ServerLimits constructor that reads limits from a ConfigTag and use it --- include/configreader.h | 5 +++++ src/configreader.cpp | 27 ++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/include/configreader.h b/include/configreader.h index 342743991..66bb97ea0 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -124,6 +124,11 @@ class ServerLimits ServerLimits() : NickMax(31), ChanMax(64), MaxModes(20), IdentMax(12), MaxQuit(255), MaxTopic(307), MaxKick(255), MaxGecos(128), MaxAway(200), MaxLine(512), MaxHost(64) { } + + /** 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(ConfigTag* tag); }; struct CommandLineConf diff --git a/src/configreader.cpp b/src/configreader.cpp index df58ec812..49ef236d4 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -29,6 +29,21 @@ #include "configparser.h" #include +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* items; @@ -405,17 +420,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); -- cgit v1.2.3 From b74da78a617c4eeef6c14364ca5a0fef5460d504 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 9 Dec 2014 12:36:24 +0100 Subject: Pass the empty tag to Limits when constructing a ServerConfig, remove default ServerLimits constructor --- include/configreader.h | 8 -------- src/configreader.cpp | 1 + 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/include/configreader.h b/include/configreader.h index 66bb97ea0..88279004f 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -117,14 +117,6 @@ 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. - */ - ServerLimits() : NickMax(31), ChanMax(64), MaxModes(20), IdentMax(12), - MaxQuit(255), MaxTopic(307), MaxKick(255), MaxGecos(128), MaxAway(200), - MaxLine(512), MaxHost(64) { } - /** 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 */ diff --git a/src/configreader.cpp b/src/configreader.cpp index 49ef236d4..d52f3de13 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -52,6 +52,7 @@ static ConfigTag* CreateEmptyTag() ServerConfig::ServerConfig() : EmptyTag(CreateEmptyTag()) + , Limits(EmptyTag) { RawLog = HideBans = HideSplits = UndernetMsgPrefix = false; WildcardIPv6 = InvBypassModes = true; -- cgit v1.2.3