diff options
-rw-r--r-- | data/example.conf | 4 | ||||
-rw-r--r-- | src/config.cpp | 15 | ||||
-rw-r--r-- | src/uplink.cpp | 6 |
3 files changed, 21 insertions, 4 deletions
diff --git a/data/example.conf b/data/example.conf index 41a1a0163..b6e0231ce 100644 --- a/data/example.conf +++ b/data/example.conf @@ -238,13 +238,13 @@ serverinfo /* * The filename containing the Services process ID. The path is relative to the - * services root directory. If not given, defaults to "data/services.pid". + * services root directory. */ pid = "data/services.pid" /* * The filename containing the Message of the Day. The path is relative to the - * services root directory. If not given, defaults to "conf/services.motd". + * services root directory. */ motd = "conf/services.motd" } diff --git a/src/config.cpp b/src/config.cpp index 8ba56bda2..1000e6cf4 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -106,6 +106,12 @@ static void ValidateNotEmpty(const Anope::string &block, const Anope::string &na throw ConfigException("The value for <" + block + ":" + name + "> cannot be empty!"); } +static void ValidateNoSpaces(const Anope::string &block, const Anope::string &name, const Anope::string &value) +{ + if (value.find(' ') != Anope::string::npos) + throw ConfigException("The value for <" + block + ":" + name + "> may not contain spaces!"); +} + template<typename T> static void ValidateNotZero(const Anope::string &block, const Anope::string &name, T value) { if (!value) @@ -158,14 +164,18 @@ Conf::Conf() : Block("") throw ConfigException("<" + noreload[i].block + ":" + noreload[i].name + "> can not be modified once set"); } - Block *options = this->GetBlock("options"), *mail = this->GetBlock("mail"); + Block *serverinfo = this->GetBlock("serverinfo"), *options = this->GetBlock("options"), *mail = this->GetBlock("mail"); + + ValidateNotEmpty("serverinfo", "name", serverinfo->Get<const Anope::string>("name")); + ValidateNotEmpty("serverinfo", "description", serverinfo->Get<const Anope::string>("description")); + ValidateNotEmpty("serverinfo", "pid", serverinfo->Get<const Anope::string>("pid")); + ValidateNotEmpty("serverinfo", "motd", serverinfo->Get<const Anope::string>("motd")); ValidateNotZero("options", "releasetimeout", options->Get<time_t>("releasetimeout")); ValidateNotZero("options", "updatetimeout", options->Get<time_t>("updatetimeout")); ValidateNotZero("options", "expiretimeout", options->Get<time_t>("expiretimeout")); ValidateNotZero("options", "readtimeout", options->Get<time_t>("readtimeout")); ValidateNotZero("options", "warningtimeout", options->Get<time_t>("warningtimeout")); - ValidateNotZero("options", "timeoutcheck", options->Get<time_t>("timeoutcheck")); ValidateNotEmpty("options", "enforceruser", options->Get<const Anope::string>("enforceruser")); ValidateNotEmpty("options", "enforcerhost", options->Get<const Anope::string>("enforcerhost")); @@ -313,6 +323,7 @@ Conf::Conf() : Block("") ValidateNotEmpty("service", "user", user); ValidateNotEmpty("service", "host", host); ValidateNotEmpty("service", "gecos", gecos); + ValidateNoSpaces("service", "channels", channels); BotInfo *bi = BotInfo::Find(nick, true); if (!bi) diff --git a/src/uplink.cpp b/src/uplink.cpp index 9f2caa02d..871121cc9 100644 --- a/src/uplink.cpp +++ b/src/uplink.cpp @@ -38,6 +38,12 @@ class ReconnectTimer : public Timer void Uplink::Connect() { + if (Config->Uplinks.empty()) + { + Log() << "Warning: There are no configured uplinks."; + return; + } + if (static_cast<unsigned>(++Anope::CurrentUplink) >= Config->Uplinks.size()) Anope::CurrentUplink = 0; |