1
0
mirror of https://github.com/anope/anope.git synced 2026-07-04 17:53:12 +02:00

More validation stuff from fgs

This commit is contained in:
Adam
2013-07-21 18:29:35 -04:00
parent 604da89813
commit 779f3788c9
3 changed files with 27 additions and 14 deletions
+6
View File
@@ -128,6 +128,12 @@ class CommandNSRegister : public Command
return;
}
if (nsregister.equals_ci("mail") && email.empty())
{
source.Reply(_("You must specify an email address."));
return;
}
time_t nickregdelay = Config->GetModule(this->owner)->Get<time_t>("nickregdelay");
time_t reg_delay = Config->GetModule("nickserv")->Get<time_t>("regdelay");
if (u && !u->HasMode("OPER") && nickregdelay && Anope::CurTime - u->timestamp < nickregdelay)
+1 -1
View File
@@ -324,7 +324,7 @@ class NickServCore : public Module, public NickServService
if (!modesonid.empty())
u->SetModes(NickServ, "%s", modesonid.c_str());
if (block->Get<bool>("forceemail") && u->Account()->email.empty())
if (block->Get<bool>("forceemail", "yes") && u->Account()->email.empty())
{
u->SendMessage(NickServ, _("You must now supply an e-mail for your nick.\n"
"This e-mail will allow you to retrieve your password in\n"
+20 -13
View File
@@ -145,26 +145,26 @@ Conf::Conf() : Block("")
{
Anope::string block;
Anope::string name;
Anope::string def;
} noreload[] = {
{"serverinfo", "name", ""},
{"serverinfo", "description", ""},
{"serverinfo", "localhost", ""},
{"serverinfo", "id", ""},
{"serverinfo", "pid", ""},
{"networkinfo", "nicklen", "31"},
{"networkinfo", "userlen", "10"},
{"networkinfo", "hostlen", "64"},
{"networkinfo", "chanlen", "32"},
{"options", "passlen", "32"},
{"serverinfo", "name"},
{"serverinfo", "description"},
{"serverinfo", "localhost"},
{"serverinfo", "id"},
{"serverinfo", "pid"},
{"networkinfo", "nicklen"},
{"networkinfo", "userlen"},
{"networkinfo", "hostlen"},
{"networkinfo", "chanlen"},
{"options", "passlen"},
};
for (unsigned i = 0; i < sizeof(noreload) / sizeof(noreload[0]); ++i)
if (this->GetBlock(noreload[i].block)->Get<const Anope::string>(noreload[i].name, noreload[i].def) != Config->GetBlock(noreload[i].block)->Get<const Anope::string>(noreload[i].name, noreload[i].def))
if (this->GetBlock(noreload[i].block)->Get<const Anope::string>(noreload[i].name) != Config->GetBlock(noreload[i].block)->Get<const Anope::string>(noreload[i].name))
throw ConfigException("<" + noreload[i].block + ":" + noreload[i].name + "> can not be modified once set");
}
Block *serverinfo = this->GetBlock("serverinfo"), *options = this->GetBlock("options"), *mail = this->GetBlock("mail");
Block *serverinfo = this->GetBlock("serverinfo"), *options = this->GetBlock("options"),
*mail = this->GetBlock("mail"), *networkinfo = this->GetBlock("networkinfo");
ValidateNotEmpty("serverinfo", "name", serverinfo->Get<const Anope::string>("name"));
ValidateNotEmpty("serverinfo", "description", serverinfo->Get<const Anope::string>("description"));
@@ -176,11 +176,17 @@ Conf::Conf() : Block("")
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", "passlen", options->Get<time_t>("passlen"));
ValidateNotEmpty("options", "enforceruser", options->Get<const Anope::string>("enforceruser"));
ValidateNotEmpty("options", "enforcerhost", options->Get<const Anope::string>("enforcerhost"));
ValidateNotEmpty("options", "guestnickprefix", options->Get<const Anope::string>("guestnickprefix"));
ValidateNotZero("networkinfo", "nicklen", networkinfo->Get<unsigned>("nicklen"));
ValidateNotZero("networkinfo", "userlen", networkinfo->Get<unsigned>("userlen"));
ValidateNotZero("networkinfo", "hostlen", networkinfo->Get<unsigned>("hostlen"));
ValidateNotZero("networkinfo", "chanlen", networkinfo->Get<unsigned>("chanlen"));
spacesepstream(options->Get<const Anope::string>("ulineservers")).GetTokens(this->Ulines);
if (mail->Get<bool>("usemail"))
@@ -212,6 +218,7 @@ Conf::Conf() : Block("")
const Anope::string &password = uplink->Get<const Anope::string>("password");
ValidateNotEmpty("uplink", "host", host);
ValidateNotZero("uplink", "port", port);
ValidateNotEmpty("uplink", "password", password);
this->Uplinks.push_back(Uplink(host, port, password, ipv6));