mirror of
https://github.com/anope/anope.git
synced 2026-06-25 02:46:37 +02:00
Rewrote the config reader to better handle invalid configs.
This prevents Anope from exploding when /os reload has errors.
This commit is contained in:
@@ -26,18 +26,18 @@ class CommandNSResetPass : public Command
|
||||
{
|
||||
NickAlias *na;
|
||||
|
||||
if (Config.RestrictMail && !u->Account()->HasCommand("nickserv/resetpass"))
|
||||
notice_lang(Config.s_NickServ, u, ACCESS_DENIED);
|
||||
if (Config->RestrictMail && !u->Account()->HasCommand("nickserv/resetpass"))
|
||||
notice_lang(Config->s_NickServ, u, ACCESS_DENIED);
|
||||
if (!(na = findnick(params[0])))
|
||||
notice_lang(Config.s_NickServ, u, NICK_X_NOT_REGISTERED, params[0].c_str());
|
||||
notice_lang(Config->s_NickServ, u, NICK_X_NOT_REGISTERED, params[0].c_str());
|
||||
else if (na->HasFlag(NS_FORBIDDEN))
|
||||
notice_lang(Config.s_NickServ, u, NICK_X_FORBIDDEN, na->nick.c_str());
|
||||
notice_lang(Config->s_NickServ, u, NICK_X_FORBIDDEN, na->nick.c_str());
|
||||
else
|
||||
{
|
||||
if (SendResetEmail(u, na))
|
||||
{
|
||||
Alog() << Config.s_NickServ << ": " << u->GetMask() << " used RESETPASS on " << na->nick << " (" << na->nc->display << ")";
|
||||
notice_lang(Config.s_NickServ, u, NICK_RESETPASS_COMPLETE, na->nick.c_str());
|
||||
Alog() << Config->s_NickServ << ": " << u->GetMask() << " used RESETPASS on " << na->nick << " (" << na->nc->display << ")";
|
||||
notice_lang(Config->s_NickServ, u, NICK_RESETPASS_COMPLETE, na->nick.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,18 +46,18 @@ class CommandNSResetPass : public Command
|
||||
|
||||
bool OnHelp(User *u, const Anope::string &subcommand)
|
||||
{
|
||||
notice_help(Config.s_NickServ, u, NICK_HELP_RESETPASS);
|
||||
notice_help(Config->s_NickServ, u, NICK_HELP_RESETPASS);
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnSyntaxError(User *u, const Anope::string &subcommand)
|
||||
{
|
||||
syntax_error(Config.s_NickServ, u, "RESETPASS", NICK_RESETPASS_SYNTAX);
|
||||
syntax_error(Config->s_NickServ, u, "RESETPASS", NICK_RESETPASS_SYNTAX);
|
||||
}
|
||||
|
||||
void OnServHelp(User *u)
|
||||
{
|
||||
notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_RESETPASS);
|
||||
notice_lang(Config->s_NickServ, u, NICK_HELP_CMD_RESETPASS);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ class NSResetPass : public Module
|
||||
public:
|
||||
NSResetPass(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
|
||||
{
|
||||
if (!Config.UseMail)
|
||||
if (!Config->UseMail)
|
||||
throw ModuleException("Not using mail.");
|
||||
|
||||
this->SetAuthor("Anope");
|
||||
@@ -81,7 +81,7 @@ class NSResetPass : public Module
|
||||
|
||||
EventReturn OnPreCommand(User *u, BotInfo *service, const Anope::string &command, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (service == findbot(Config.s_NickServ) && command.equals_ci("CONFIRM") && !params.empty())
|
||||
if (service == findbot(Config->s_NickServ) && command.equals_ci("CONFIRM") && !params.empty())
|
||||
{
|
||||
NickAlias *na = findnick(u->nick);
|
||||
|
||||
@@ -93,7 +93,7 @@ class NSResetPass : public Module
|
||||
{
|
||||
na->nc->Shrink("ns_resetpass_code");
|
||||
na->nc->Shrink("ns_resetpass_time");
|
||||
notice_lang(Config.s_NickServ, u, NICK_CONFIRM_EXPIRED);
|
||||
notice_lang(Config->s_NickServ, u, NICK_CONFIRM_EXPIRED);
|
||||
return EVENT_STOP;
|
||||
}
|
||||
|
||||
@@ -111,19 +111,19 @@ class NSResetPass : public Module
|
||||
ircdproto->SetAutoIdentificationToken(u);
|
||||
FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(u));
|
||||
|
||||
Alog() << Config.s_NickServ << ": " << u->GetMask() << " used CONFIRM with RESETPASS to forcefully identify to " << na->nick;
|
||||
notice_lang(Config.s_NickServ, u, NICK_CONFIRM_SUCCESS, Config.s_NickServ.c_str());
|
||||
Alog() << Config->s_NickServ << ": " << u->GetMask() << " used CONFIRM with RESETPASS to forcefully identify to " << na->nick;
|
||||
notice_lang(Config->s_NickServ, u, NICK_CONFIRM_SUCCESS, Config->s_NickServ.c_str());
|
||||
|
||||
if (ircd->vhost)
|
||||
do_on_id(u);
|
||||
if (Config.NSModeOnID)
|
||||
if (Config->NSModeOnID)
|
||||
do_setmodes(u);
|
||||
check_memos(u);
|
||||
}
|
||||
else
|
||||
{
|
||||
Alog() << Config.s_NickServ << ": Invalid CONFIRM passcode for " << na->nick << " from " << u->GetMask();
|
||||
notice_lang(Config.s_NickServ, u, NICK_CONFIRM_INVALID);
|
||||
Alog() << Config->s_NickServ << ": Invalid CONFIRM passcode for " << na->nick << " from " << u->GetMask();
|
||||
notice_lang(Config->s_NickServ, u, NICK_CONFIRM_INVALID);
|
||||
bad_password(u);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ static bool SendResetEmail(User *u, NickAlias *na)
|
||||
for (idx = 0; idx < 20; ++idx)
|
||||
passcode += chars[1 + static_cast<int>((static_cast<float>(max - min)) * getrandom16() / 65536.0) + min];
|
||||
|
||||
snprintf(message, sizeof(message), getstring(na, NICK_RESETPASS_MESSAGE), na->nick.c_str(), Config.s_NickServ.c_str(), passcode.c_str(), Config.NetworkName.c_str());
|
||||
snprintf(message, sizeof(message), getstring(na, NICK_RESETPASS_MESSAGE), na->nick.c_str(), Config->s_NickServ.c_str(), passcode.c_str(), Config->NetworkName.c_str());
|
||||
|
||||
na->nc->Shrink("ns_resetpass_code");
|
||||
na->nc->Shrink("ns_resetpass_time");
|
||||
@@ -163,7 +163,7 @@ static bool SendResetEmail(User *u, NickAlias *na)
|
||||
na->nc->Extend("ns_resetpass_code", new ExtensibleItemRegular<Anope::string>(passcode));
|
||||
na->nc->Extend("ns_resetpass_time", new ExtensibleItemRegular<time_t>(time(NULL)));
|
||||
|
||||
return Mail(u, na->nc, Config.s_NickServ, subject, message);
|
||||
return Mail(u, na->nc, Config->s_NickServ, subject, message);
|
||||
}
|
||||
|
||||
MODULE_INIT(NSResetPass)
|
||||
|
||||
Reference in New Issue
Block a user