From f9911dde529adf3dc03f4f14bbd70756ac2f665c Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 2 Mar 2025 14:51:02 +0000 Subject: 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. --- modules/extra/enc_argon2.cpp | 16 ++++++++-------- modules/extra/ldap.cpp | 22 +++++++++++----------- modules/extra/mysql.cpp | 28 ++++++++++++++-------------- modules/extra/sqlite.cpp | 16 ++++++++-------- modules/extra/ssl_gnutls.cpp | 14 +++++++------- modules/extra/ssl_openssl.cpp | 18 +++++++++--------- modules/extra/xmlrpc.cpp | 4 ++-- 7 files changed, 59 insertions(+), 59 deletions(-) (limited to 'modules/extra') diff --git a/modules/extra/enc_argon2.cpp b/modules/extra/enc_argon2.cpp index 8d6f27d9b..81d052c0c 100644 --- a/modules/extra/enc_argon2.cpp +++ b/modules/extra/enc_argon2.cpp @@ -154,15 +154,15 @@ public: }); } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - const auto *block = Config->GetModule(this); - this->defaultprovider = GetAlgorithm(block->Get("algorithm", "argon2id")); - Argon2Context::memory_cost = block->Get("memory_cost", "131072"); - Argon2Context::time_cost = block->Get("time_cost", "3"); - Argon2Context::parallelism = block->Get("parallelism", "1"); - Argon2Context::hash_length = block->Get("hash_length", "32"); - Argon2Context::salt_length = block->Get("salt_length", "32"); + const auto &block = Config->GetModule(this); + this->defaultprovider = GetAlgorithm(block.Get("algorithm", "argon2id")); + Argon2Context::memory_cost = block.Get("memory_cost", "131072"); + Argon2Context::time_cost = block.Get("time_cost", "3"); + Argon2Context::parallelism = block.Get("parallelism", "1"); + Argon2Context::hash_length = block.Get("hash_length", "32"); + Argon2Context::salt_length = block.Get("salt_length", "32"); } EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) override diff --git a/modules/extra/ldap.cpp b/modules/extra/ldap.cpp index ecc48767a..f8ef205a5 100644 --- a/modules/extra/ldap.cpp +++ b/modules/extra/ldap.cpp @@ -544,9 +544,9 @@ public: LDAPServices.clear(); } - void OnReload(Configuration::Conf *config) override + void OnReload(Configuration::Conf &config) override { - Configuration::Block *conf = config->GetModule(this); + Configuration::Block &conf = config.GetModule(this); for (std::map::iterator it = this->LDAPServices.begin(); it != this->LDAPServices.end();) { @@ -556,11 +556,11 @@ public: ++it; - for (i = 0; i < conf->CountBlock("ldap"); ++i) - if (conf->GetBlock("ldap", i)->Get("name", "ldap/main") == cname) + for (i = 0; i < conf.CountBlock("ldap"); ++i) + if (conf.GetBlock("ldap", i).Get("name", "ldap/main") == cname) break; - if (i == conf->CountBlock("ldap")) + if (i == conf.CountBlock("ldap")) { Log(LOG_NORMAL, "ldap") << "LDAP: Removing server connection " << cname; @@ -572,17 +572,17 @@ public: } } - for (int i = 0; i < conf->CountBlock("ldap"); ++i) + for (int i = 0; i < conf.CountBlock("ldap"); ++i) { - Configuration::Block *ldap = conf->GetBlock("ldap", i); + Configuration::Block &ldap = conf.GetBlock("ldap", i); - const Anope::string &connname = ldap->Get("name", "ldap/main"); + const Anope::string &connname = ldap.Get("name", "ldap/main"); if (this->LDAPServices.find(connname) == this->LDAPServices.end()) { - const Anope::string &server = ldap->Get("server", "127.0.0.1"); - const Anope::string &admin_binddn = ldap->Get("admin_binddn"); - const Anope::string &admin_password = ldap->Get("admin_password"); + const Anope::string &server = ldap.Get("server", "127.0.0.1"); + const Anope::string &admin_binddn = ldap.Get("admin_binddn"); + const Anope::string &admin_password = ldap.Get("admin_password"); try { diff --git a/modules/extra/mysql.cpp b/modules/extra/mysql.cpp index 65fe6d5c4..0d39c87a4 100644 --- a/modules/extra/mysql.cpp +++ b/modules/extra/mysql.cpp @@ -260,9 +260,9 @@ public: delete DThread; } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - Configuration::Block *config = conf->GetModule(this); + Configuration::Block &config = conf.GetModule(this); for (std::map::iterator it = this->MySQLServices.begin(); it != this->MySQLServices.end();) { @@ -272,11 +272,11 @@ public: ++it; - for (i = 0; i < config->CountBlock("mysql"); ++i) - if (config->GetBlock("mysql", i)->Get("name", "mysql/main") == cname) + for (i = 0; i < Config->CountBlock("mysql"); ++i) + if (config.GetBlock("mysql", i).Get("name", "mysql/main") == cname) break; - if (i == config->CountBlock("mysql")) + if (i == Config->CountBlock("mysql")) { Log(LOG_NORMAL, "mysql") << "MySQL: Removing server connection " << cname; @@ -285,19 +285,19 @@ public: } } - for (int i = 0; i < config->CountBlock("mysql"); ++i) + for (int i = 0; i < Config->CountBlock("mysql"); ++i) { - Configuration::Block *block = config->GetBlock("mysql", i); - const Anope::string &connname = block->Get("name", "mysql/main"); + Configuration::Block &block = config.GetBlock("mysql", i); + const Anope::string &connname = block.Get("name", "mysql/main"); if (this->MySQLServices.find(connname) == this->MySQLServices.end()) { - const Anope::string &database = block->Get("database", "anope"); - const Anope::string &server = block->Get("server", "127.0.0.1"); - const Anope::string &user = block->Get("username", "anope"); - const Anope::string &password = block->Get("password"); - unsigned int port = block->Get("port", "3306"); - const Anope::string &socket = block->Get("socket"); + const Anope::string &database = block.Get("database", "anope"); + const Anope::string &server = block.Get("server", "127.0.0.1"); + const Anope::string &user = block.Get("username", "anope"); + const Anope::string &password = block.Get("password"); + unsigned int port = block.Get("port", "3306"); + const Anope::string &socket = block.Get("socket"); try { diff --git a/modules/extra/sqlite.cpp b/modules/extra/sqlite.cpp index d234066a0..36bafae4c 100644 --- a/modules/extra/sqlite.cpp +++ b/modules/extra/sqlite.cpp @@ -113,9 +113,9 @@ public: SQLiteServices.clear(); } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - Configuration::Block *config = conf->GetModule(this); + Configuration::Block &config = conf.GetModule(this); for (std::map::iterator it = this->SQLiteServices.begin(); it != this->SQLiteServices.end();) { @@ -124,8 +124,8 @@ public: int i, num; ++it; - for (i = 0, num = config->CountBlock("sqlite"); i < num; ++i) - if (config->GetBlock("sqlite", i)->Get("name", "sqlite/main") == cname) + for (i = 0, num = Config->CountBlock("sqlite"); i < num; ++i) + if (config.GetBlock("sqlite", i).Get("name", "sqlite/main") == cname) break; if (i == num) @@ -137,14 +137,14 @@ public: } } - for (int i = 0; i < config->CountBlock("sqlite"); ++i) + for (int i = 0; i < Config->CountBlock("sqlite"); ++i) { - Configuration::Block *block = config->GetBlock("sqlite", i); - Anope::string connname = block->Get("name", "sqlite/main"); + Configuration::Block &block = config.GetBlock("sqlite", i); + Anope::string connname = block.Get("name", "sqlite/main"); if (this->SQLiteServices.find(connname) == this->SQLiteServices.end()) { - auto database = Anope::ExpandData(block->Get("database", "anope")); + auto database = Anope::ExpandData(block.Get("database", "anope")); try { auto *ss = new SQLiteService(this, connname, database); diff --git a/modules/extra/ssl_gnutls.cpp b/modules/extra/ssl_gnutls.cpp index f8ef18f16..5e9147d5c 100644 --- a/modules/extra/ssl_gnutls.cpp +++ b/modules/extra/ssl_gnutls.cpp @@ -327,13 +327,13 @@ public: } } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - Configuration::Block *config = conf->GetModule(this); + Configuration::Block &config = conf.GetModule(this); - const Anope::string certfile = Anope::ExpandConfig(config->Get("cert", "fullchain.pem")); - const Anope::string keyfile = Anope::ExpandConfig(config->Get("key", "privkey.pem")); - const Anope::string dhfile = Anope::ExpandConfig(config->Get("dh", "dhparams.pem")); + const Anope::string certfile = Anope::ExpandConfig(config.Get("cert", "fullchain.pem")); + const Anope::string keyfile = Anope::ExpandConfig(config.Get("key", "privkey.pem")); + const Anope::string dhfile = Anope::ExpandConfig(config.Get("dh", "dhparams.pem")); CheckFile(certfile); CheckFile(keyfile); @@ -365,9 +365,9 @@ public: void OnPreServerConnect() override { - Configuration::Block *config = Config->GetBlock("uplink", Anope::CurrentUplink); + Configuration::Block &config = Config->GetBlock("uplink", Anope::CurrentUplink); - if (config->Get("ssl")) + if (config.Get("ssl")) { this->service.Init(UplinkSock); } diff --git a/modules/extra/ssl_openssl.cpp b/modules/extra/ssl_openssl.cpp index 28e734e44..50ac75466 100644 --- a/modules/extra/ssl_openssl.cpp +++ b/modules/extra/ssl_openssl.cpp @@ -144,12 +144,12 @@ public: SSL_CTX_free(server_ctx); } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - Configuration::Block *config = conf->GetModule(this); + Configuration::Block &config = conf.GetModule(this); - this->certfile = Anope::ExpandConfig(config->Get("cert", "fullchain.pem")); - this->keyfile = Anope::ExpandConfig(config->Get("key", "privkey.pem")); + this->certfile = Anope::ExpandConfig(config.Get("cert", "fullchain.pem")); + this->keyfile = Anope::ExpandConfig(config.Get("key", "privkey.pem")); if (Anope::IsFile(this->certfile)) { @@ -177,7 +177,7 @@ public: } // Allow disabling old versions of TLS - if (config->Get("tlsv10", "false")) + if (config.Get("tlsv10", "false")) { SSL_CTX_clear_options(client_ctx, SSL_OP_NO_TLSv1); SSL_CTX_clear_options(server_ctx, SSL_OP_NO_TLSv1); @@ -188,7 +188,7 @@ public: SSL_CTX_set_options(server_ctx, SSL_OP_NO_TLSv1); } - if (config->Get("tlsv11", "true")) + if (config.Get("tlsv11", "true")) { SSL_CTX_clear_options(client_ctx, SSL_OP_NO_TLSv1_1); SSL_CTX_clear_options(server_ctx, SSL_OP_NO_TLSv1_1); @@ -199,7 +199,7 @@ public: SSL_CTX_set_options(server_ctx, SSL_OP_NO_TLSv1_1); } - if (config->Get("tlsv12", "true")) + if (config.Get("tlsv12", "true")) { SSL_CTX_clear_options(client_ctx, SSL_OP_NO_TLSv1_2); SSL_CTX_clear_options(server_ctx, SSL_OP_NO_TLSv1_2); @@ -213,9 +213,9 @@ public: void OnPreServerConnect() override { - Configuration::Block *config = Config->GetBlock("uplink", Anope::CurrentUplink); + Configuration::Block &config = Config->GetBlock("uplink", Anope::CurrentUplink); - if (config->Get("ssl")) + if (config.Get("ssl")) { this->service.Init(UplinkSock); } diff --git a/modules/extra/xmlrpc.cpp b/modules/extra/xmlrpc.cpp index 00b7d92ac..7652fc4d3 100644 --- a/modules/extra/xmlrpc.cpp +++ b/modules/extra/xmlrpc.cpp @@ -279,12 +279,12 @@ public: xmlrpc_term(); } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { if (httpref) httpref->UnregisterPage(&xmlrpcinterface); - this->httpref = ServiceReference("HTTPProvider", conf->GetModule(this)->Get("server", "httpd/main")); + this->httpref = ServiceReference("HTTPProvider", conf.GetModule(this).Get("server", "httpd/main")); if (!httpref) throw ConfigException("Unable to find http reference, is httpd loaded?"); -- cgit