diff options
| author | Adam <Adam@anope.org> | 2013-05-05 01:55:04 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2013-05-05 01:55:04 -0400 |
| commit | 1d0bb9b26b7ad58ab0bf979ac046f4511b3bf12b (patch) | |
| tree | 4486f0784bdf050fd7eb225c0cb9df352ce1f45a /modules/extra | |
| parent | 781defb7076ddfddf723ca08cd0a518b6657b64f (diff) | |
Rework the config file reader to be much more flexible and move many configuration directives to the actual modules they are used in.
Diffstat (limited to 'modules/extra')
23 files changed, 170 insertions, 165 deletions
diff --git a/modules/extra/m_chanstats.cpp b/modules/extra/m_chanstats.cpp index caa20aacb..f5e20646b 100644 --- a/modules/extra/m_chanstats.cpp +++ b/modules/extra/m_chanstats.cpp @@ -1,5 +1,5 @@ #include "module.h" -#include "../extra/sql.h" +#include "sql.h" class MySQLInterface : public SQL::Interface { @@ -338,7 +338,7 @@ class MChanstats : public Module { Implementation i[] = { I_OnPrivmsg, - I_OnUserKicked, + I_OnPreUserKicked, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnTopicUpdated, @@ -349,14 +349,15 @@ class MChanstats : public Module ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { - prefix = reader.ReadValue("chanstats", "prefix", "anope_", 0); - SmileysHappy = reader.ReadValue("chanstats", "SmileysHappy", ":) :-) ;) :D :-D", 0); - SmileysSad = reader.ReadValue("chanstats", "SmileysSad", ":( :-( ;( ;-(", 0); - SmileysOther = reader.ReadValue("chanstats", "SmileysOther", ":/", 0); + Configuration::Block *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"); + SmileysOther = block->Get<const Anope::string &>("SmileysOther"); - Anope::string engine = reader.ReadValue("chanstats", "engine", "", 0); + Anope::string engine = block->Get<const Anope::string &>("engine"); this->sql = ServiceReference<SQL::Provider>("SQL::Provider", engine); if (sql) this->CheckTables(); @@ -399,24 +400,24 @@ class MChanstats : public Module this->RunQuery(query); } public: - void OnUserKicked(Channel *c, User *target, MessageSource &source, const Anope::string &kickmsg) anope_override + void OnPreUserKicked(MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) anope_override { - if (!c->ci || !c->ci->HasExt("STATS")) + if (!cu->chan->ci || !cu->chan->ci->HasExt("STATS")) return; query = "CALL " + prefix + "chanstats_proc_update(@channel@, @nick@, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0);"; - query.SetValue("channel", c->name); - query.SetValue("nick", GetDisplay(target)); + query.SetValue("channel", cu->chan->name); + query.SetValue("nick", GetDisplay(cu->user)); this->RunQuery(query); query = "CALL " + prefix + "chanstats_proc_update(@channel@, @nick@, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0);"; - query.SetValue("channel", c->name); + query.SetValue("channel", cu->chan->name); query.SetValue("nick", GetDisplay(source.GetUser())); this->RunQuery(query); } void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_override { - if (!c->ci || !c->ci->HasExt("STATS") || (msg[0] == Config->BSFantasyCharacter[0])) + if (!c->ci || !c->ci->HasExt("STATS")) return; size_t letters = msg.length(); diff --git a/modules/extra/m_httpd.cpp b/modules/extra/m_httpd.cpp index 5e643d942..87d1ad6a1 100644 --- a/modules/extra/m_httpd.cpp +++ b/modules/extra/m_httpd.cpp @@ -352,21 +352,24 @@ class HTTPD : public Module this->providers.clear(); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { std::set<Anope::string> existing; - for (int i = 0, num = reader.Enumerate("httpd"); i < num; ++i) + for (int i = 0; i < conf->CountBlock("httpd"); ++i) { - Anope::string hname = reader.ReadValue("httpd", "name", "httpd/main", i); + Configuration::Block *block = conf->GetBlock("httpd", i); + + + const Anope::string &hname = block->Get<const Anope::string &>("name", "httpd/main"); existing.insert(hname); - Anope::string ip = reader.ReadValue("httpd", "ip", "", i); - int port = reader.ReadInteger("httpd", "port", "8080", i, true); - int timeout = reader.ReadInteger("httpd", "timeout", "30", i, true); - bool ssl = reader.ReadFlag("httpd", "ssl", "no", i); - Anope::string ext_ip = reader.ReadValue("httpd", "extforward_ip", "", i); - Anope::string ext_header = reader.ReadValue("httpd", "extforward_header", "", i); + Anope::string ip = block->Get<const Anope::string &>("ip"); + int port = block->Get<int>("port", "8080"); + int timeout = block->Get<int>("timeout", "30"); + bool ssl = block->Get<bool>("ssl", "no"); + Anope::string ext_ip = block->Get<const Anope::string &>("extforward_ip"); + Anope::string ext_header = block->Get<const Anope::string &>("extforward_header"); if (ip.empty()) { diff --git a/modules/extra/m_ldap.cpp b/modules/extra/m_ldap.cpp index 3200d3e38..a6066c008 100644 --- a/modules/extra/m_ldap.cpp +++ b/modules/extra/m_ldap.cpp @@ -1,7 +1,7 @@ /* RequiredLibraries: ldap,lber */ #include "module.h" -#include "ldap.h" +#include "ldapapi.h" #include <ldap.h> static Pipe *me; @@ -423,7 +423,7 @@ class ModuleLDAP : public Module, public Pipe LDAPServices.clear(); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { int i, num; @@ -433,13 +433,9 @@ class ModuleLDAP : public Module, public Pipe LDAPService *s = it->second; ++it; - for (i = 0, num = reader.Enumerate("ldap"); i < num; ++i) - { - if (reader.ReadValue("ldap", "name", "main", i) == cname) - { + for (i = 0; i < Config->CountBlock("ldap"); ++i) + if (Config->GetBlock("ldap", i)->Get<const Anope::string &>("name", "ldap/main") == cname) break; - } - } if (i == num) { @@ -451,16 +447,16 @@ class ModuleLDAP : public Module, public Pipe } } - for (i = 0, num = reader.Enumerate("ldap"); i < num; ++i) + for (i = 0; i < Config->CountBlock("ldap"); ++i) { - Anope::string connname = reader.ReadValue("ldap", "name", "main", i); + const Anope::string &connname = Config->GetBlock("ldap", i)->Get<const Anope::string &>("name", "ldap/main"); if (this->LDAPServices.find(connname) == this->LDAPServices.end()) { - Anope::string server = reader.ReadValue("ldap", "server", "127.0.0.1", i); - int port = reader.ReadInteger("ldap", "port", "389", i, true); - Anope::string admin_binddn = reader.ReadValue("ldap", "admin_binddn", "", i); - Anope::string admin_password = reader.ReadValue("ldap", "admin_password", "", i); + const Anope::string &server = Config->GetBlock("ldap", i)->Get<const Anope::string &>("server", "127.0.0.1"); + int port = Config->GetBlock("ldap", i)->Get<int>("port", "389"); + const Anope::string &admin_binddn = Config->GetBlock("ldap", i)->Get<const Anope::string &>("admin_binddn"); + const Anope::string &admin_password = Config->GetBlock("ldap", i)->Get<const Anope::string &>("admin_password"); try { diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp index f39bb43e8..a8ece73ff 100644 --- a/modules/extra/m_ldap_authentication.cpp +++ b/modules/extra/m_ldap_authentication.cpp @@ -1,6 +1,6 @@ #include "module.h" #include "nickserv.h" -#include "ldap.h" +#include "ldapapi.h" static Module *me; @@ -104,14 +104,9 @@ class IdentifyInterface : public LDAPInterface if (na == NULL) { na = new NickAlias(ii->req->GetAccount(), new NickCore(ii->req->GetAccount())); - if (ii->user) - { - if (Config->NSAddAccessOnReg) - na->nc->AddAccess(ii->user->Mask()); - - if (NickServ) - ii->user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); - } + FOREACH_MOD(I_OnNickRegister, OnNickRegister(ii->user, na)); + if (ii->user && NickServ) + ii->user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); } // encrypt and store the password in the nickcore Anope::Encrypt(ii->req->GetPassword(), na->nc->pass); @@ -226,21 +221,22 @@ class NSIdentifyLDAP : public Module ModuleManager::SetPriority(this, PRIORITY_FIRST); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { + Configuration::Block *config = Config->GetModule(this); - basedn = reader.ReadValue("m_ldap_authentication", "basedn", "", 0); - search_filter = reader.ReadValue("m_ldap_authentication", "search_filter", "", 0); - object_class = reader.ReadValue("m_ldap_authentication", "object_class", "", 0); - username_attribute = reader.ReadValue("m_ldap_authentication", "username_attribute", "", 0); - this->password_attribute = reader.ReadValue("m_ldap_authentication", "password_attribute", "", 0); - email_attribute = reader.ReadValue("m_ldap_authentication", "email_attribute", "", 0); - this->disable_register_reason = reader.ReadValue("m_ldap_authentication", "disable_register_reason", "", 0); - this->disable_email_reason = reader.ReadValue("m_ldap_authentication", "disable_email_reason", "", 0); + basedn = conf->Get<const Anope::string &>("basedn"); + search_filter = conf->Get<const Anope::string &>("search_filter"); + object_class = conf->Get<const Anope::string &>("object_class"); + username_attribute = conf->Get<const Anope::string &>("username_attribute"); + this->password_attribute = conf->Get<const Anope::string &>("password_attribute"); + email_attribute = conf->Get<const Anope::string &>("email_attribute"); + this->disable_register_reason = conf->Get<const Anope::string &>("disable_register_reason"); + this->disable_email_reason = conf->Get<const Anope::string &>("disable_email_reason"); if (!email_attribute.empty()) /* Don't complain to users about how they need to update their email, we will do it for them */ - Config->NSForceEmail = false; + Config->GetBlock("nickserv")->Set("forceemail", "false"); } EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) anope_override @@ -297,7 +293,7 @@ class NSIdentifyLDAP : public Module } } - void OnNickRegister(NickAlias *na) anope_override + void OnNickRegister(User *, NickAlias *na) anope_override { if (!this->disable_register_reason.empty() || !this->ldap) return; diff --git a/modules/extra/m_ldap_oper.cpp b/modules/extra/m_ldap_oper.cpp index afe3fde48..4324a7bc0 100644 --- a/modules/extra/m_ldap_oper.cpp +++ b/modules/extra/m_ldap_oper.cpp @@ -1,5 +1,5 @@ #include "module.h" -#include "ldap.h" +#include "ldapapi.h" static std::set<Oper *> my_opers; static Anope::string opertype_attribute; @@ -93,13 +93,15 @@ class LDAPOper : public Module ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { - this->binddn = reader.ReadValue("m_ldap_oper", "binddn", "", 0); - this->password = reader.ReadValue("m_ldap_oper", "password", "", 0); - this->basedn = reader.ReadValue("m_ldap_oper", "basedn", "", 0); - this->filter = reader.ReadValue("m_ldap_oper", "filter", "", 0); - opertype_attribute = reader.ReadValue("m_ldap_oper", "opertype_attribute", "", 0); + Configuration::Block *config = Config->GetModule(this); + + this->binddn = config->Get<const Anope::string &>("binddn"); + this->password = config->Get<const Anope::string &>("password"); + this->basedn = config->Get<const Anope::string &>("basedn"); + this->filter = config->Get<const Anope::string &>("filter"); + opertype_attribute = config->Get<const Anope::string &>("opertype_attribute"); for (std::set<Oper *>::iterator it = my_opers.begin(), it_end = my_opers.end(); it != it_end; ++it) delete *it; diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp index c41ba37a8..372cb6982 100644 --- a/modules/extra/m_mysql.cpp +++ b/modules/extra/m_mysql.cpp @@ -188,8 +188,9 @@ class ModuleSQL : public Module, public Pipe delete DThread; } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { + Configuration::Block *config = Config->GetModule(this); int i, num; for (std::map<Anope::string, MySQLService *>::iterator it = this->MySQLServices.begin(); it != this->MySQLServices.end();) @@ -198,13 +199,9 @@ class ModuleSQL : public Module, public Pipe MySQLService *s = it->second; ++it; - for (i = 0, num = reader.Enumerate("mysql"); i < num; ++i) - { - if (reader.ReadValue("mysql", "name", "main", i) == cname) - { + for (i = 0; i < Config->CountBlock("mysql"); ++i) + if (Config->GetBlock("mysql", i)->Get<const Anope::string &>("name", "main") == cname) break; - } - } if (i == num) { @@ -215,17 +212,18 @@ class ModuleSQL : public Module, public Pipe } } - for (i = 0, num = reader.Enumerate("mysql"); i < num; ++i) + for (i = 0; i < Config->CountBlock("mysql"); ++i) { - Anope::string connname = reader.ReadValue("mysql", "name", "mysql/main", i); + Configuration::Block *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()) { - Anope::string database = reader.ReadValue("mysql", "database", "anope", i); - Anope::string server = reader.ReadValue("mysql", "server", "127.0.0.1", i); - Anope::string user = reader.ReadValue("mysql", "username", "anope", i); - Anope::string password = reader.ReadValue("mysql", "password", "", i); - int port = reader.ReadInteger("mysql", "port", "3306", i, true); + const Anope::string &database = block->Get<const Anope::string &>("database", "anope"); + const Anope::string &server = block->Get<const Anope::string &>("server", "127.0.0.1"); + const Anope::string &user = block->Get<const Anope::string &>("username", "anope"); + const Anope::string &password = block->Get<const Anope::string &>("password"); + int port = block->Get<int>("port", "3306"); try { diff --git a/modules/extra/m_proxyscan.cpp b/modules/extra/m_proxyscan.cpp index 9dd3f8884..c77f0f9cd 100644 --- a/modules/extra/m_proxyscan.cpp +++ b/modules/extra/m_proxyscan.cpp @@ -86,7 +86,7 @@ class ProxyConnect : public ConnectionSocket reason = reason.replace_all_cs("%p", stringify(this->conaddr.port())); Log(OperServ) << "PROXYSCAN: Open " << this->GetType() << " proxy found on " << this->conaddr.addr() << ":" << this->conaddr.port() << " (" << reason << ")"; - XLine *x = new XLine("*@" + this->conaddr.addr(), Config->OperServ, Anope::CurTime + this->proxy.duration, reason, XLineManager::GenerateUID()); + XLine *x = new XLine("*@" + this->conaddr.addr(), OperServ ? OperServ->nick : "", Anope::CurTime + this->proxy.duration, reason, XLineManager::GenerateUID()); if (add_to_akill && akills) { akills->AddXLine(x); @@ -253,34 +253,36 @@ class ModuleProxyScan : public Module delete this->listener; } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { - Anope::string s_target_ip = reader.ReadValue("m_proxyscan", "target_ip", "", 0); + Configuration::Block *config = Config->GetModule(this); + + Anope::string s_target_ip = config->Get<const Anope::string &>("target_ip"); if (s_target_ip.empty()) - throw ConfigException("m_proxyscan:target_ip may not be empty"); + throw ConfigException(this->name + " target_ip may not be empty"); - int s_target_port = reader.ReadInteger("m_proxyscan", "target_port", "-1", 0, true); + int s_target_port = config->Get<int>("target_port", "-1"); if (s_target_port <= 0) - throw ConfigException("m_proxyscan:target_port may not be empty and must be a positive number"); + throw ConfigException(this->name + " target_port may not be empty and must be a positive number"); - Anope::string s_listen_ip = reader.ReadValue("m_proxyscan", "listen_ip", "", 0); + Anope::string s_listen_ip = config->Get<const Anope::string &>("listen_ip"); if (s_listen_ip.empty()) - throw ConfigException("m_proxyscan:listen_ip may not be empty"); + throw ConfigException(this->name + " listen_ip may not be empty"); - int s_listen_port = reader.ReadInteger("m_proxyscan", "listen_port", "-1", 0, true); + int s_listen_port = config->Get<int>("listen_port", "-1"); if (s_listen_port <= 0) - throw ConfigException("m_proxyscan:listen_port may not be empty and must be a positive number"); + throw ConfigException(this->name + " listen_port may not be empty and must be a positive number"); target_ip = s_target_ip; target_port = s_target_port; this->listen_ip = s_listen_ip; this->listen_port = s_listen_port; - this->con_notice = reader.ReadValue("m_proxyscan", "connect_notice", "", 0); - this->con_source = reader.ReadValue("m_proxyscan", "connect_source", "", 0); - add_to_akill = reader.ReadFlag("m_proxyscan", "add_to_akill", "true", 0); - this->connectionTimeout.SetSecs(reader.ReadInteger("m_proxyscan", "timeout", "5", 0, true)); + this->con_notice = config->Get<const Anope::string &>("connect_notice"); + this->con_source = config->Get<const Anope::string &>("connect_source"); + add_to_akill = config->Get<bool>("add_to_akill", "true"); + this->connectionTimeout.SetSecs(config->Get<time_t>("timeout", "5s")); - ProxyCheckString = Config->NetworkName + " proxy check"; + ProxyCheckString = Config->GetBlock("networkinfo")->Get<const Anope::string &>("networkname") + " proxy check"; delete this->listener; this->listener = NULL; try @@ -293,12 +295,13 @@ class ModuleProxyScan : public Module } this->proxyscans.clear(); - for (int i = 0; i < reader.Enumerate("proxyscan"); ++i) + for (int i = 0; i < conf->CountBlock("proxyscan"); ++i) { + Configuration::Block *block = conf->GetBlock("proxyscan", i); ProxyCheck p; Anope::string token; - commasepstream sep(reader.ReadValue("proxyscan", "type", "", i)); + commasepstream sep(block->Get<const Anope::string &>("type")); while (sep.GetToken(token)) { if (!token.equals_ci("HTTP") && !token.equals_ci("SOCKS5")) @@ -308,7 +311,7 @@ class ModuleProxyScan : public Module if (p.types.empty()) continue; - commasepstream sep2(reader.ReadValue("proxyscan", "port", "", i)); + commasepstream sep2(block->Get<const Anope::string &>("port")); while (sep2.GetToken(token)) { try @@ -321,8 +324,8 @@ class ModuleProxyScan : public Module if (p.ports.empty()) continue; - p.duration = Anope::DoTime(reader.ReadValue("proxyscan", "time", "4h", i)); - p.reason = reader.ReadValue("proxyscan", "reason", "", i); + p.duration = block->Get<time_t>("time", "4h"); + p.reason = block->Get<const Anope::string &>("reason"); if (p.reason.empty()) continue; diff --git a/modules/extra/m_sql_authentication.cpp b/modules/extra/m_sql_authentication.cpp index 027b0bbcc..98fd4c2e9 100644 --- a/modules/extra/m_sql_authentication.cpp +++ b/modules/extra/m_sql_authentication.cpp @@ -2,6 +2,7 @@ #include "sql.h" static Module *me; +static ServiceReference<NickServService> nickserv("NickServService", "NickServ"); class SQLAuthenticationResult : public SQL::Interface { @@ -41,14 +42,9 @@ class SQLAuthenticationResult : public SQL::Interface if (na == NULL) { na = new NickAlias(req->GetAccount(), new NickCore(req->GetAccount())); - if (user) - { - if (Config->NSAddAccessOnReg) - na->nc->AddAccess(user->Mask()); - - if (NickServ) - user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); - } + FOREACH_MOD(I_OnNickRegister, OnNickRegister(user, na)); + if (user && nickserv) + user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); } if (!email.empty() && email != na->nc->email) @@ -80,18 +76,18 @@ class ModuleSQLAuthentication : public Module public: ModuleSQLAuthentication(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) { - me = this; Implementation i[] = { I_OnReload, I_OnPreCommand, I_OnCheckAuthentication }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { - this->engine = reader.ReadValue("m_sql_authentication", "engine", "", 0); - this->query = reader.ReadValue("m_sql_authentication", "query", "", 0); - this->disable_reason = reader.ReadValue("m_sql_authentication", "disable_reason", "", 0); + Configuration::Block *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"); this->SQL = ServiceReference<SQL::Provider>("SQL::Provider", this->engine); } diff --git a/modules/extra/m_sql_oper.cpp b/modules/extra/m_sql_oper.cpp index 4f982e1d8..480bcf5a0 100644 --- a/modules/extra/m_sql_oper.cpp +++ b/modules/extra/m_sql_oper.cpp @@ -101,10 +101,12 @@ class ModuleSQLOper : public Module ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { - this->engine = reader.ReadValue("m_sql_oper", "engine", "", 0); - this->query = reader.ReadValue("m_sql_oper", "query", "", 0); + Configuration::Block *config = conf->GetModule(this); + + this->engine = config->Get<const Anope::string &>("engine"); + this->query = config->Get<const Anope::string &>("query"); this->SQL = ServiceReference<SQL::Provider>("SQL::Provider", this->engine); } diff --git a/modules/extra/m_sqlite.cpp b/modules/extra/m_sqlite.cpp index 9626741a0..b0f947985 100644 --- a/modules/extra/m_sqlite.cpp +++ b/modules/extra/m_sqlite.cpp @@ -77,18 +77,19 @@ class ModuleSQLite : public Module SQLiteServices.clear(); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { - int i, num; + Configuration::Block *config = conf->GetModule(this); for (std::map<Anope::string, SQLiteService *>::iterator it = this->SQLiteServices.begin(); it != this->SQLiteServices.end();) { const Anope::string &cname = it->first; SQLiteService *s = it->second; + int i, num; ++it; - for (i = 0, num = reader.Enumerate("sqlite"); i < num; ++i) - if (reader.ReadValue("sqlite", "name", "sqlite/main", i) == cname) + for (i = 0, num = config->CountBlock("sqlite"); i < num; ++i) + if (config->GetBlock("sqlite", i)->Get<const Anope::string &>("name", "sqlite/main") == cname) break; if (i == num) @@ -100,13 +101,14 @@ class ModuleSQLite : public Module } } - for (i = 0, num = reader.Enumerate("sqlite"); i < num; ++i) + for (int i = 0; i < config->CountBlock("sqlite"); ++i) { - Anope::string connname = reader.ReadValue("sqlite", "name", "sqlite/main", i); + Configuration::Block *block = config->GetBlock("sqlite", i); + Anope::string connname = block->Get<const Anope::string &>("name", "sqlite/main"); if (this->SQLiteServices.find(connname) == this->SQLiteServices.end()) { - Anope::string database = Anope::DataDir + "/" + reader.ReadValue("sqlite", "database", "anope", i); + Anope::string database = Anope::DataDir + "/" + block->Get<const Anope::string &>("database", "anope"); try { diff --git a/modules/extra/m_ssl.cpp b/modules/extra/m_ssl.cpp index 95de6694a..3219830e7 100644 --- a/modules/extra/m_ssl.cpp +++ b/modules/extra/m_ssl.cpp @@ -136,10 +136,12 @@ class SSLModule : public Module SSL_CTX_free(server_ctx); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { - this->certfile = reader.ReadValue("ssl", "cert", "data/anope.crt", 0); - this->keyfile = reader.ReadValue("ssl", "key", "data/anope.key", 0); + Configuration::Block *config = conf->GetModule(this); + + this->certfile = config->Get<const Anope::string &>("cert", "data/anope.crt"); + this->keyfile = config->Get<const Anope::string &>("key", "data/anope.key"); if (Anope::IsFile(this->certfile.c_str())) { @@ -182,9 +184,9 @@ class SSLModule : public Module void OnPreServerConnect() anope_override { - ConfigReader reader; + Configuration::Block *config = Config->GetBlock("uplink", Anope::CurrentUplink); - if (reader.ReadFlag("uplink", "ssl", "no", Anope::CurrentUplink)) + if (config->Get<bool>("ssl")) { this->service.Init(UplinkSock); } diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp index 0ba748f0b..8016d620e 100644 --- a/modules/extra/m_xmlrpc_main.cpp +++ b/modules/extra/m_xmlrpc_main.cpp @@ -239,14 +239,15 @@ class MyXMLRPCEvent : public XMLRPCEvent void DoOperType(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) { - for (std::list<OperType *>::const_iterator it = Config->MyOperTypes.begin(), it_end = Config->MyOperTypes.end(); it != it_end; ++it) + for (unsigned i = 0; i < Config->MyOperTypes.size(); ++i) { + OperType *ot = Config->MyOperTypes[i]; Anope::string perms; - for (std::list<Anope::string>::const_iterator it2 = (*it)->GetPrivs().begin(), it2_end = (*it)->GetPrivs().end(); it2 != it2_end; ++it2) + for (std::list<Anope::string>::const_iterator it2 = ot->GetPrivs().begin(), it2_end = ot->GetPrivs().end(); it2 != it2_end; ++it2) perms += " " + *it2; - for (std::list<Anope::string>::const_iterator it2 = (*it)->GetCommands().begin(), it2_end = (*it)->GetCommands().end(); it2 != it2_end; ++it2) + for (std::list<Anope::string>::const_iterator it2 = ot->GetCommands().begin(), it2_end = ot->GetCommands().end(); it2 != it2_end; ++it2) perms += " " + *it2; - request.reply((*it)->GetName(), perms); + request.reply(ot->GetName(), perms); } } }; diff --git a/modules/extra/webcpanel/pages/chanserv/access.cpp b/modules/extra/webcpanel/pages/chanserv/access.cpp index 33250035e..0df2ecfc1 100644 --- a/modules/extra/webcpanel/pages/chanserv/access.cpp +++ b/modules/extra/webcpanel/pages/chanserv/access.cpp @@ -44,7 +44,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s params.push_back("DEL"); params.push_back(message.get_data["mask"]); - WebPanel::RunCommand(na->nc->display, na->nc, Config->ChanServ, "chanserv/access", params, replacements); + WebPanel::RunCommand(na->nc->display, na->nc, ::ChanServ->nick, "chanserv/access", params, replacements); } else if (message.post_data["mask"].empty() == false && message.post_data["access"].empty() == false && message.post_data["provider"].empty() == false) { @@ -75,8 +75,10 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s } } - if (ci->GetAccessCount() >= Config->CSAccessMax) - replacements["MESSAGES"] = "Sorry, you can only have " + stringify(Config->CSAccessMax) + " access entries on a channel."; + + unsigned access_max = Config->GetModule("chanserv")->Get<unsigned>("accessmax", "1024"); + if (access_max && ci->GetAccessCount() >= access_max) + replacements["MESSAGES"] = "Sorry, you can only have " + stringify(access_max) + " access entries on a channel."; else if (!denied) { ChanAccess *new_acc = a->Create(); diff --git a/modules/extra/webcpanel/pages/chanserv/akick.cpp b/modules/extra/webcpanel/pages/chanserv/akick.cpp index 95fb8fb30..06aede8e7 100644 --- a/modules/extra/webcpanel/pages/chanserv/akick.cpp +++ b/modules/extra/webcpanel/pages/chanserv/akick.cpp @@ -40,7 +40,7 @@ bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::st params.push_back("DEL"); params.push_back(message.get_data["mask"]); - WebPanel::RunCommand(na->nc->display, na->nc, Config->ChanServ, "chanserv/akick", params, replacements); + WebPanel::RunCommand(na->nc->display, na->nc, ::ChanServ->nick, "chanserv/akick", params, replacements); } else if (message.post_data["mask"].empty() == false) { @@ -51,7 +51,7 @@ bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::st if (message.post_data["reason"].empty() == false) params.push_back(message.get_data["reason"]); - WebPanel::RunCommand(na->nc->display, na->nc, Config->ChanServ, "chanserv/akick", params, replacements); + WebPanel::RunCommand(na->nc->display, na->nc, ::ChanServ->nick, "chanserv/akick", params, replacements); } replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname); diff --git a/modules/extra/webcpanel/pages/chanserv/drop.cpp b/modules/extra/webcpanel/pages/chanserv/drop.cpp index 5462aa131..f18700651 100644 --- a/modules/extra/webcpanel/pages/chanserv/drop.cpp +++ b/modules/extra/webcpanel/pages/chanserv/drop.cpp @@ -21,7 +21,7 @@ bool WebCPanel::ChanServ::Drop::OnRequest(HTTPProvider *server, const Anope::str std::vector<Anope::string> params; params.push_back(HTTPUtils::URLDecode(message.post_data["channel"])); - WebPanel::RunCommand(na->nc->display, na->nc, Config->ChanServ, "chanserv/drop", params, replacements); + WebPanel::RunCommand(na->nc->display, na->nc, ::ChanServ->nick, "chanserv/drop", params, replacements); } else replacements["MESSAGES"] = "Inv |
