1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 19:14:47 +02:00

Get rid of the internal block wrapper.

This only existed for compatibility with old 2.0 modules and 2.1
has already broken compatibility with them.
This commit is contained in:
Sadie Powell
2025-04-19 12:47:52 +01:00
parent 452e62c050
commit d815906393
42 changed files with 61 additions and 67 deletions
-6
View File
@@ -18,8 +18,6 @@
namespace Configuration
{
namespace Internal
{
class CoreExport Block
{
friend class Configuration::Conf;
@@ -56,10 +54,6 @@ namespace Configuration
template<> CoreExport const Anope::string Block::Get(const Anope::string &tag, const Anope::string &def) const;
template<> CoreExport time_t Block::Get(const Anope::string &tag, const Anope::string &def) const;
template<> CoreExport bool Block::Get(const Anope::string &tag, const Anope::string &def) const;
} // namespace Internal
typedef const Internal::Block Block;
typedef Internal::Block MutableBlock;
/** Represents a configuration file
*/
+1 -1
View File
@@ -900,7 +900,7 @@ public:
for (int i = 0; i < conf.CountBlock("privilege"); ++i)
{
Configuration::Block &priv = conf.GetBlock("privilege", i);
const auto &priv = conf.GetBlock("privilege", i);
const Anope::string &pname = priv.Get<const Anope::string>("name");
+1 -1
View File
@@ -50,7 +50,7 @@ public:
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
Configuration::Block &block = Config->GetCommand(source);
const auto &block = Config->GetCommand(source);
const Anope::string &mode = block.Get<Anope::string>("mode", "BAN");
ChannelMode *cm = ModeManager::FindChannelModeByName(mode);
if (cm == NULL)
+1 -1
View File
@@ -503,7 +503,7 @@ public:
for (int i = 0; i < conf.CountBlock("privilege"); ++i)
{
Configuration::Block &priv = conf.GetBlock("privilege", i);
const auto &priv = conf.GetBlock("privilege", i);
const Anope::string &pname = priv.Get<const Anope::string>("name");
+2 -2
View File
@@ -325,12 +325,12 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &block = conf.GetModule(this);
const auto &block = conf.GetModule(this);
defaults.clear();
for (int i = 0; i < block.CountBlock("default"); ++i)
{
Configuration::Block &def = block.GetBlock("default", i);
const auto &def = block.GetBlock("default", i);
LogDefault ld;
+1 -1
View File
@@ -969,7 +969,7 @@ public:
for (int i = 0; i < conf.CountBlock("command"); ++i)
{
Configuration::Block &block = conf.GetBlock("command", i);
const auto &block = conf.GetBlock("command", i);
const Anope::string &cname = block.Get<const Anope::string>("name"),
&cmd = block.Get<const Anope::string>("command");
+1 -1
View File
@@ -205,7 +205,7 @@ public:
for (int i = 0; i < conf.CountBlock("command"); ++i)
{
Configuration::Block &block = conf.GetBlock("command", i);
const auto &block = conf.GetBlock("command", i);
if (block.Get<const Anope::string>("command") != "chanserv/set/misc")
continue;
+2 -2
View File
@@ -640,7 +640,7 @@ public:
for (int i = 0; i < conf.CountBlock("privilege"); ++i)
{
Configuration::Block &block = conf.GetBlock("privilege", i);
const auto &block = conf.GetBlock("privilege", i);
const Anope::string &pname = block.Get<const Anope::string>("name");
Privilege *p = PrivilegeManager::FindPrivilege(pname);
@@ -656,7 +656,7 @@ public:
for (int i = 0; i < conf.CountBlock("command"); ++i)
{
Configuration::Block &block = conf.GetBlock("command", i);
const auto &block = conf.GetBlock("command", i);
const Anope::string &cname = block.Get<const Anope::string>("name"),
&cserv = block.Get<const Anope::string>("command");
if (cname.empty() || cserv != "chanserv/xop")
+1 -1
View File
@@ -499,7 +499,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &block = conf.GetModule(this);
const auto &block = conf.GetModule(this);
prefix = block.Get<const Anope::string>("prefix", "anope_");
SmileysHappy = block.Get<const Anope::string>("SmileysHappy");
SmileysSad = block.Get<const Anope::string>("SmileysSad");
+1 -1
View File
@@ -1554,7 +1554,7 @@ public:
flags.clear();
for (int i = 0; i < Config->CountBlock("privilege"); ++i)
{
Configuration::Block &priv = Config->GetBlock("privilege", i);
const auto &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())
+1 -1
View File
@@ -173,7 +173,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &block = conf.GetModule(this);
const auto &block = conf.GetModule(this);
this->redis = ServiceReference<Provider>("Redis::Provider", block.Get<const Anope::string>("engine", "redis/main"));
}
+1 -1
View File
@@ -162,7 +162,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &block = conf.GetModule(this);
const auto &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");
+1 -1
View File
@@ -141,7 +141,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &block = conf.GetModule(this);
const auto &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_");
}
+2 -2
View File
@@ -1047,7 +1047,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &block = conf.GetModule(this);
const auto &block = conf.GetModule(this);
nameserver = block.Get<const Anope::string>("nameserver", "127.0.0.1");
timeout = block.Get<time_t>("timeout", "5");
@@ -1059,7 +1059,7 @@ public:
for (int i = 0; i < block.CountBlock("notify"); ++i)
{
Configuration::Block &n = block.GetBlock("notify", i);
const auto &n = block.GetBlock("notify", i);
Anope::string nip = n.Get<Anope::string>("ip");
short nport = n.Get<short>("port");
+4 -4
View File
@@ -114,7 +114,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &block = conf.GetModule(this);
const auto &block = conf.GetModule(this);
this->check_on_connect = block.Get<bool>("check_on_connect");
this->check_on_netburst = block.Get<bool>("check_on_netburst");
this->add_to_akill = block.Get<bool>("add_to_akill", "yes");
@@ -122,7 +122,7 @@ public:
this->blacklists.clear();
for (int i = 0; i < block.CountBlock("blacklist"); ++i)
{
Configuration::Block &bl = block.GetBlock("blacklist", i);
const auto &bl = block.GetBlock("blacklist", i);
Blacklist blacklist;
blacklist.name = bl.Get<Anope::string>("name");
@@ -133,7 +133,7 @@ public:
for (int j = 0; j < bl.CountBlock("reply"); ++j)
{
Configuration::Block &reply = bl.GetBlock("reply", j);
const auto &reply = bl.GetBlock("reply", j);
Blacklist::Reply r;
r.code = reply.Get<int>("code");
@@ -149,7 +149,7 @@ public:
this->exempts.clear();
for (int i = 0; i < block.CountBlock("exempt"); ++i)
{
Configuration::Block &bl = block.GetBlock("exempt", i);
const auto &bl = block.GetBlock("exempt", i);
this->exempts.insert(bl.Get<Anope::string>("ip"));
}
}
+2 -2
View File
@@ -546,7 +546,7 @@ public:
void OnReload(Configuration::Conf &config) override
{
Configuration::Block &conf = config.GetModule(this);
const auto &conf = config.GetModule(this);
for (std::map<Anope::string, LDAPService *>::iterator it = this->LDAPServices.begin(); it != this->LDAPServices.end();)
{
@@ -574,7 +574,7 @@ public:
for (int i = 0; i < conf.CountBlock("ldap"); ++i)
{
Configuration::Block &ldap = conf.GetBlock("ldap", i);
const auto &ldap = conf.GetBlock("ldap", i);
const Anope::string &connname = ldap.Get<const Anope::string>("name", "ldap/main");
+2 -2
View File
@@ -262,7 +262,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &config = conf.GetModule(this);
const auto &config = conf.GetModule(this);
for (std::map<Anope::string, MySQLService *>::iterator it = this->MySQLServices.begin(); it != this->MySQLServices.end();)
{
@@ -287,7 +287,7 @@ public:
for (int i = 0; i < config.CountBlock("mysql"); ++i)
{
Configuration::Block &block = config.GetBlock("mysql", i);
const auto &block = config.GetBlock("mysql", i);
const Anope::string &connname = block.Get<const Anope::string>("name", "mysql/main");
if (this->MySQLServices.find(connname) == this->MySQLServices.end())
+2 -2
View File
@@ -115,7 +115,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &config = conf.GetModule(this);
const auto &config = conf.GetModule(this);
for (std::map<Anope::string, SQLiteService *>::iterator it = this->SQLiteServices.begin(); it != this->SQLiteServices.end();)
{
@@ -139,7 +139,7 @@ public:
for (int i = 0; i < config.CountBlock("sqlite"); ++i)
{
Configuration::Block &block = config.GetBlock("sqlite", i);
const auto &block = config.GetBlock("sqlite", i);
Anope::string connname = block.Get<const Anope::string>("name", "sqlite/main");
if (this->SQLiteServices.find(connname) == this->SQLiteServices.end())
+2 -2
View File
@@ -329,7 +329,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &config = conf.GetModule(this);
const auto &config = conf.GetModule(this);
const Anope::string certfile = Anope::ExpandConfig(config.Get<const Anope::string>("cert", "fullchain.pem"));
const Anope::string keyfile = Anope::ExpandConfig(config.Get<const Anope::string>("key", "privkey.pem"));
@@ -365,7 +365,7 @@ public:
void OnPreServerConnect() override
{
Configuration::Block &config = Config->GetBlock("uplink", Anope::CurrentUplink);
const auto &config = Config->GetBlock("uplink", Anope::CurrentUplink);
if (config.Get<bool>("ssl"))
{
+2 -2
View File
@@ -146,7 +146,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &config = conf.GetModule(this);
const auto &config = conf.GetModule(this);
this->certfile = Anope::ExpandConfig(config.Get<const Anope::string>("cert", "fullchain.pem"));
this->keyfile = Anope::ExpandConfig(config.Get<const Anope::string>("key", "privkey.pem"));
@@ -213,7 +213,7 @@ public:
void OnPreServerConnect() override
{
Configuration::Block &config = Config->GetBlock("uplink", Anope::CurrentUplink);
const auto &config = Config->GetBlock("uplink", Anope::CurrentUplink);
if (config.Get<bool>("ssl"))
{
+1 -1
View File
@@ -109,7 +109,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &block = conf.GetModule(this);
const auto &block = conf.GetModule(this);
syncongroup = block.Get<bool>("syncongroup");
synconset = block.Get<bool>("synconset");
}
+2 -2
View File
@@ -362,12 +362,12 @@ public:
void OnReload(Configuration::Conf &config) override
{
Configuration::Block &conf = config.GetModule(this);
const auto &conf = config.GetModule(this);
std::set<Anope::string> existing;
for (int i = 0; i < conf.CountBlock("httpd"); ++i)
{
Configuration::Block &block = conf.GetBlock("httpd", i);
const auto &block = conf.GetBlock("httpd", i);
const Anope::string &hname = block.Get<const Anope::string>("name", "httpd/main");
+1 -1
View File
@@ -19,7 +19,7 @@ void IRC2SQL::OnShutdown()
void IRC2SQL::OnReload(Configuration::Conf &conf)
{
Configuration::Block &block = Config->GetModule(this);
const auto &block = Config->GetModule(this);
prefix = block.Get<const Anope::string>("prefix", "anope_");
GeoIPDB = block.Get<const Anope::string>("geoip_database");
ctcpuser = block.Get<bool>("ctcpuser", "no");
+1 -1
View File
@@ -220,7 +220,7 @@ public:
void OnReload(Configuration::Conf &config) override
{
Configuration::Block &conf = Config->GetModule(this);
const auto &conf = Config->GetModule(this);
basedn = conf.Get<const Anope::string>("basedn");
search_filter = conf.Get<const Anope::string>("search_filter");
+1 -1
View File
@@ -94,7 +94,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &config = Config->GetModule(this);
const auto &config = Config->GetModule(this);
this->binddn = config.Get<const Anope::string>("binddn");
this->password = config.Get<const Anope::string>("password");
+1 -1
View File
@@ -372,7 +372,7 @@ public:
void OnNickIdentify(User *u) override
{
Configuration::Block &block = Config->GetModule(this);
const auto &block = Config->GetModule(this);
if (block.Get<bool>("modeonid", "yes"))
{
+1 -1
View File
@@ -218,7 +218,7 @@ public:
for (int i = 0; i < conf.CountBlock("command"); ++i)
{
Configuration::Block &block = conf.GetBlock("command", i);
const auto &block = conf.GetBlock("command", i);
const Anope::string &cmd = block.Get<const Anope::string>("command");
+3 -3
View File
@@ -33,7 +33,7 @@ public:
return;
}
Configuration::MutableBlock *block = Config->GetMutableBlock(params[1]);
auto *block = Config->GetMutableBlock(params[1]);
if (!block)
block = &Config->GetModule(params[1]);
@@ -57,7 +57,7 @@ public:
for (unsigned i = 0; !show_blocks[i].empty(); ++i)
{
Configuration::Block &block = Config->GetBlock(show_blocks[i]);
const auto &block = Config->GetBlock(show_blocks[i]);
const Configuration::Block::item_map &items = block.GetItems();
ListFormatter lflist(source.GetAccount());
@@ -87,7 +87,7 @@ public:
for (int i = 0; i < Config->CountBlock("module"); ++i)
{
Configuration::Block &block = Config->GetBlock("module", i);
const auto &block = Config->GetBlock("module", i);
const Configuration::Block::item_map &items = block.GetItems();
if (items.size() <= 1)
+2 -2
View File
@@ -338,7 +338,7 @@ public:
DefconConfig dconfig;
{
Configuration::Block &block = conf.GetModule(this);
const auto &block = conf.GetModule(this);
dconfig.defaultlevel = block.Get<int>("defaultlevel");
dconfig.defcons[4] = block.Get<const Anope::string>("level4");
dconfig.defcons[3] = block.Get<const Anope::string>("level3");
@@ -355,7 +355,7 @@ public:
}
{
Configuration::Block &block = conf.GetModule("os_session");
const auto &block = conf.GetModule("os_session");
dconfig.max_session_kill = block.Get<int>("maxsessionkill");
dconfig.session_autokill_expiry = block.Get<time_t>("sessionautokillexpiry");
dconfig.sle_reason = block.Get<const Anope::string>("sessionlimitexceeded");
+1 -1
View File
@@ -780,7 +780,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &block = conf.GetModule(this);
const auto &block = conf.GetModule(this);
this->ttl = block.Get<time_t>("ttl");
this->user_drop_mark = block.Get<int>("user_drop_mark");
this->user_drop_time = block.Get<time_t>("user_drop_time");
+1 -1
View File
@@ -640,7 +640,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &block = Config->GetModule(this);
const auto &block = Config->GetModule(this);
session_limit = block.Get<int>("defaultsessionlimit");
max_session_kill = block.Get<int>("maxsessionkill");
+2 -2
View File
@@ -262,7 +262,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &config = Config->GetModule(this);
const auto &config = Config->GetModule(this);
Anope::string s_target_ip = config.Get<const Anope::string>("target_ip");
if (s_target_ip.empty())
@@ -304,7 +304,7 @@ public:
this->proxyscans.clear();
for (int i = 0; i < config.CountBlock("proxyscan"); ++i)
{
Configuration::Block &block = config.GetBlock("proxyscan", i);
const auto &block = config.GetBlock("proxyscan", i);
ProxyCheck p;
Anope::string token;
+2 -2
View File
@@ -537,12 +537,12 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &block = conf.GetModule(this);
const auto &block = conf.GetModule(this);
std::vector<Anope::string> new_services;
for (int i = 0; i < block.CountBlock("redis"); ++i)
{
Configuration::Block &redis = block.GetBlock("redis", i);
const auto &redis = block.GetBlock("redis", i);
const Anope::string &n = redis.Get<const Anope::string>("name"),
&ip = redis.Get<const Anope::string>("ip");
+1 -1
View File
@@ -69,7 +69,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &block = conf.GetModule(this);
const auto &block = conf.GetModule(this);
const Anope::string syntax = block.Get<const Anope::string>("syntax", "ecmascript");
if (syntax == "awk")
+1 -1
View File
@@ -169,7 +169,7 @@ public:
for (int i = 0; i < conf.CountBlock("command"); ++i)
{
Configuration::Block &block = conf.GetBlock("command", i);
const auto &block = conf.GetBlock("command", i);
if (!block.Get<bool>("rewrite"))
continue;
+1 -1
View File
@@ -120,7 +120,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &config = conf.GetModule(this);
const auto &config = conf.GetModule(this);
this->engine = config.Get<const Anope::string>("engine");
this->query = config.Get<const Anope::string>("query");
this->disable_reason = config.Get<const Anope::string>("disable_reason");
+1 -1
View File
@@ -22,7 +22,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &config = conf.GetModule(this);
const auto &config = conf.GetModule(this);
this->table = config.Get<const Anope::string>("table", "logs");
}
+1 -1
View File
@@ -152,7 +152,7 @@ public:
void OnReload(Configuration::Conf &conf) override
{
Configuration::Block &config = conf.GetModule(this);
const auto &config = conf.GetModule(this);
this->engine = config.Get<const Anope::string>("engine");
this->query = config.Get<const Anope::string>("query");
+1 -1
View File
@@ -58,7 +58,7 @@ public:
me = this;
Configuration::Block &block = Config->GetModule(this);
const auto &block = Config->GetModule(this);
provider_name = block.Get<const Anope::string>("server", "httpd/main");
template_base = Anope::ExpandData(block.Get<const Anope::string>("template_dir", "webcpanel/templates/default"));
page_title = block.Get<const Anope::string>("title", "Anope IRC Services");
+1 -1
View File
@@ -22,7 +22,7 @@
using Configuration::File;
using Configuration::Conf;
using Configuration::Internal::Block;
using Configuration::Block;
using Configuration::Uplink;
File ServicesConf("anope.conf", false); // Configuration file name
+3 -3
View File
@@ -249,7 +249,7 @@ static void write_pidfile()
static void setuidgid()
{
#ifndef _WIN32
Configuration::Block &options = Config->GetBlock("options");
const auto &options = Config->GetBlock("options");
uid_t uid = -1;
gid_t gid = -1;
@@ -500,7 +500,7 @@ bool Anope::Init(int ac, char **av)
}
/* Create me */
Configuration::Block &block = Config->GetBlock("serverinfo");
const auto &block = Config->GetBlock("serverinfo");
Me = new Server(NULL, block.Get<const Anope::string>("name"), 0, block.Get<const Anope::string>("description"), block.Get<const Anope::string>("id"));
for (const auto &[_, bi] : *BotListByNick)
{
@@ -526,7 +526,7 @@ bool Anope::Init(int ac, char **av)
if (!getuid() && !getgid())
{
/* If we are configured to setuid later, don't issue a warning */
Configuration::Block &options = Config->GetBlock("options");
const auto &options = Config->GetBlock("options");
if (options.Get<const Anope::string>("user").empty())
{
std::cerr << "WARNING: You are currently running Anope as the root superuser. Anope does not" << std::endl;
+2 -2
View File
@@ -74,7 +74,7 @@ bool Mail::Send(User *u, NickCore *nc, BotInfo *service, const Anope::string &su
if (!nc || !service || subject.empty() || message.empty())
return false;
Configuration::Block &b = Config->GetBlock("mail");
const auto &b = Config->GetBlock("mail");
if (!u)
{
@@ -113,7 +113,7 @@ bool Mail::Send(User *u, NickCore *nc, BotInfo *service, const Anope::string &su
bool Mail::Send(NickCore *nc, const Anope::string &subject, const Anope::string &message)
{
Configuration::Block &b = Config->GetBlock("mail");
const auto &b = Config->GetBlock("mail");
if (!b.Get<bool>("usemail") || b.Get<const Anope::string>("sendfrom").empty() || !nc || nc->email.empty() || subject.empty() || message.empty())
return false;