mirror of
https://github.com/anope/anope.git
synced 2026-07-06 13:53:13 +02:00
Return references instead of pointers from the config system.
We used to return NULL from these methods but now we return an empty block so this can never actually be null now.
This commit is contained in:
@@ -500,7 +500,7 @@ private:
|
||||
else
|
||||
{
|
||||
// Generate a new password as we can't use the old one.
|
||||
auto maxpasslen = Config->GetModule("nickserv")->Get<unsigned>("maxpasslen", "50");
|
||||
auto maxpasslen = Config->GetModule("nickserv").Get<unsigned>("maxpasslen", "50");
|
||||
Anope::Encrypt(Anope::Random(maxpasslen), nc->pass);
|
||||
Log(this) << "Unable to convert the password for " << nc->display << " as Anope does not support the format!";
|
||||
}
|
||||
@@ -1076,8 +1076,8 @@ private:
|
||||
if (!data->kill)
|
||||
return true; // Don't apply this.
|
||||
|
||||
auto kill = Config->GetModule("nickserv")->Get<time_t>("kill", "60s");
|
||||
auto killquick = Config->GetModule("nickserv")->Get<time_t>("killquick", "20s");
|
||||
auto kill = Config->GetModule("nickserv").Get<time_t>("kill", "60s");
|
||||
auto killquick = Config->GetModule("nickserv").Get<time_t>("killquick", "20s");
|
||||
auto secs = Anope::Convert<time_t>(value, kill);
|
||||
if (secs >= kill)
|
||||
nc->Extend<bool>("KILLPROTECT");
|
||||
@@ -1295,7 +1295,7 @@ private:
|
||||
|
||||
// If an Atheme account was awaiting confirmation but Anope is not
|
||||
// configured to use confirmation then autoconfirm it.
|
||||
const auto &nsregister = Config->GetModule("ns_register")->Get<const Anope::string>("registration");
|
||||
const auto &nsregister = Config->GetModule("ns_register").Get<const Anope::string>("registration");
|
||||
if (nsregister.equals_ci("none"))
|
||||
nc->Shrink<bool>("UNCONFIRMED");
|
||||
|
||||
@@ -1453,14 +1453,14 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void OnReload(Configuration::Conf *conf) override
|
||||
void OnReload(Configuration::Conf &conf) override
|
||||
{
|
||||
flags.clear();
|
||||
for (int i = 0; i < Config->CountBlock("privilege"); ++i)
|
||||
{
|
||||
Configuration::Block *priv = Config->GetBlock("privilege", i);
|
||||
const Anope::string &name = priv->Get<const Anope::string>("name");
|
||||
const Anope::string &value = priv->Get<const Anope::string>("flag");
|
||||
Configuration::Block &priv = Config->GetBlock("privilege", i);
|
||||
const Anope::string &name = priv.Get<const Anope::string>("name");
|
||||
const Anope::string &value = priv.Get<const Anope::string>("flag");
|
||||
if (!name.empty() && !value.empty())
|
||||
flags[name] = value[0];
|
||||
}
|
||||
@@ -1468,7 +1468,7 @@ public:
|
||||
|
||||
EventReturn OnLoadDatabase() override
|
||||
{
|
||||
const auto dbname = Anope::ExpandData(Config->GetModule(this)->Get<const Anope::string>("database", "atheme.db"));
|
||||
const auto dbname = Anope::ExpandData(Config->GetModule(this).Get<const Anope::string>("database", "atheme.db"));
|
||||
std::ifstream fd(dbname.str());
|
||||
if (!fd.is_open())
|
||||
{
|
||||
|
||||
@@ -109,7 +109,7 @@ class DBFlatFile final
|
||||
last_day = tm->tm_mday;
|
||||
|
||||
std::set<Anope::string> dbs;
|
||||
dbs.insert(Config->GetModule(this)->Get<const Anope::string>("database", "anope.db"));
|
||||
dbs.insert(Config->GetModule(this).Get<const Anope::string>("database", "anope.db"));
|
||||
|
||||
for (const auto &type_order : Serialize::Type::GetTypeOrder())
|
||||
{
|
||||
@@ -135,7 +135,7 @@ class DBFlatFile final
|
||||
Anope::string err = Anope::LastError();
|
||||
Log(this) << "Unable to back up database " << db << " (" << err << ")!";
|
||||
|
||||
if (!Config->GetModule(this)->Get<bool>("nobackupokay"))
|
||||
if (!Config->GetModule(this).Get<bool>("nobackupokay"))
|
||||
{
|
||||
Anope::Quitting = true;
|
||||
Anope::QuitReason = "Unable to back up database " + db + " (" + err + ")";
|
||||
@@ -146,7 +146,7 @@ class DBFlatFile final
|
||||
|
||||
backups[db].push_back(newname);
|
||||
|
||||
unsigned keepbackups = Config->GetModule(this)->Get<unsigned>("keepbackups");
|
||||
unsigned keepbackups = Config->GetModule(this).Get<unsigned>("keepbackups");
|
||||
if (keepbackups > 0 && backups[db].size() > keepbackups)
|
||||
{
|
||||
unlink(backups[db].front().c_str());
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
|
||||
Log(this) << "Error saving databases: " << buf;
|
||||
|
||||
if (!Config->GetModule(this)->Get<bool>("nobackupokay"))
|
||||
if (!Config->GetModule(this).Get<bool>("nobackupokay"))
|
||||
Anope::Quitting = true;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ public:
|
||||
{
|
||||
std::set<Anope::string> tried_dbs;
|
||||
|
||||
const auto db_name = Anope::ExpandData(Config->GetModule(this)->Get<const Anope::string>("database", "anope.db"));
|
||||
const auto db_name = Anope::ExpandData(Config->GetModule(this).Get<const Anope::string>("database", "anope.db"));
|
||||
|
||||
std::fstream fd(db_name.c_str(), std::ios_base::in | std::ios_base::binary);
|
||||
if (!fd.is_open())
|
||||
@@ -263,7 +263,7 @@ public:
|
||||
|
||||
int i = -1;
|
||||
#ifndef _WIN32
|
||||
if (!Anope::Quitting && Config->GetModule(this)->Get<bool>("fork"))
|
||||
if (!Anope::Quitting && Config->GetModule(this).Get<bool>("fork"))
|
||||
{
|
||||
i = fork();
|
||||
if (i > 0)
|
||||
@@ -290,7 +290,7 @@ public:
|
||||
if (s_type->GetOwner())
|
||||
db_name = Anope::ExpandData("module_" + s_type->GetOwner()->name + ".db");
|
||||
else
|
||||
db_name = Anope::ExpandData(Config->GetModule(this)->Get<const Anope::string>("database", "anope.db"));
|
||||
db_name = Anope::ExpandData(Config->GetModule(this).Get<const Anope::string>("database", "anope.db"));
|
||||
|
||||
std::fstream *fs = databases[s_type->GetOwner()] = new std::fstream((db_name + ".tmp").c_str(), std::ios_base::out | std::ios_base::trunc | std::ios_base::binary);
|
||||
|
||||
@@ -319,7 +319,7 @@ public:
|
||||
|
||||
for (auto &[mod, f] : databases)
|
||||
{
|
||||
const auto db_name = Anope::ExpandData((mod ? (mod->name + ".db") : Config->GetModule(this)->Get<const Anope::string>("database", "anope.db")));
|
||||
const auto db_name = Anope::ExpandData((mod ? (mod->name + ".db") : Config->GetModule(this).Get<const Anope::string>("database", "anope.db")));
|
||||
|
||||
if (!f->is_open() || !f->good())
|
||||
{
|
||||
@@ -363,7 +363,7 @@ public:
|
||||
if (stype->GetOwner())
|
||||
db_name = Anope::ExpandData("module_" + stype->GetOwner()->name + ".db");
|
||||
else
|
||||
db_name = Anope::ExpandData(Config->GetModule(this)->Get<const Anope::string>("database", "anope.db"));
|
||||
db_name = Anope::ExpandData(Config->GetModule(this).Get<const Anope::string>("database", "anope.db"));
|
||||
|
||||
std::fstream fd(db_name.c_str(), std::ios_base::in | std::ios_base::binary);
|
||||
if (!fd.is_open())
|
||||
|
||||
@@ -1296,7 +1296,7 @@ public:
|
||||
{
|
||||
|
||||
|
||||
hashm = Config->GetModule(this)->Get<const Anope::string>("hash");
|
||||
hashm = Config->GetModule(this).Get<const Anope::string>("hash");
|
||||
|
||||
if (hashm != "md5" && hashm != "oldmd5" && hashm != "sha1" && hashm != "plain" && hashm != "sha256")
|
||||
throw ModuleException("Invalid hash method");
|
||||
|
||||
@@ -171,10 +171,10 @@ public:
|
||||
this->updated_items.clear();
|
||||
}
|
||||
|
||||
void OnReload(Configuration::Conf *conf) override
|
||||
void OnReload(Configuration::Conf &conf) override
|
||||
{
|
||||
Configuration::Block *block = conf->GetModule(this);
|
||||
this->redis = ServiceReference<Provider>("Redis::Provider", block->Get<const Anope::string>("engine", "redis/main"));
|
||||
Configuration::Block &block = conf.GetModule(this);
|
||||
this->redis = ServiceReference<Provider>("Redis::Provider", block.Get<const Anope::string>("engine", "redis/main"));
|
||||
}
|
||||
|
||||
EventReturn OnLoadDatabase() override
|
||||
|
||||
@@ -158,12 +158,12 @@ public:
|
||||
this->imported = true;
|
||||
}
|
||||
|
||||
void OnReload(Configuration::Conf *conf) override
|
||||
void OnReload(Configuration::Conf &conf) override
|
||||
{
|
||||
Configuration::Block *block = conf->GetModule(this);
|
||||
this->sql = ServiceReference<Provider>("SQL::Provider", block->Get<const Anope::string>("engine"));
|
||||
this->prefix = block->Get<const Anope::string>("prefix", "anope_db_");
|
||||
this->import = block->Get<bool>("import");
|
||||
Configuration::Block &block = conf.GetModule(this);
|
||||
this->sql = ServiceReference<Provider>("SQL::Provider", block.Get<const Anope::string>("engine"));
|
||||
this->prefix = block.Get<const Anope::string>("prefix", "anope_db_");
|
||||
this->import = block.Get<bool>("import");
|
||||
}
|
||||
|
||||
void OnPostInit() override
|
||||
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Anope::CurTime - Config->GetBlock("options")->Get<time_t>("updatetimeout", "2m") > lastwarn)
|
||||
if (Anope::CurTime - Config->GetBlock("options").Get<time_t>("updatetimeout", "2m") > lastwarn)
|
||||
{
|
||||
Log() << "Unable to locate SQL reference, going to readonly...";
|
||||
Anope::ReadOnly = this->ro = true;
|
||||
@@ -138,11 +138,11 @@ public:
|
||||
init = false;
|
||||
}
|
||||
|
||||
void OnReload(Configuration::Conf *conf) override
|
||||
void OnReload(Configuration::Conf &conf) override
|
||||
{
|
||||
Configuration::Block *block = conf->GetModule(this);
|
||||
this->SQL = ServiceReference<Provider>("SQL::Provider", block->Get<const Anope::string>("engine"));
|
||||
this->prefix = block->Get<const Anope::string>("prefix", "anope_db_");
|
||||
Configuration::Block &block = conf.GetModule(this);
|
||||
this->SQL = ServiceReference<Provider>("SQL::Provider", block.Get<const Anope::string>("engine"));
|
||||
this->prefix = block.Get<const Anope::string>("prefix", "anope_db_");
|
||||
}
|
||||
|
||||
void OnSerializableConstruct(Serializable *obj) override
|
||||
|
||||
Reference in New Issue
Block a user