diff options
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"] = "Invalid Confirmation"; } diff --git a/modules/extra/webcpanel/pages/confirm.cpp b/modules/extra/webcpanel/pages/confirm.cpp index 1f5d61cc1..ab86ee5c9 100644 --- a/modules/extra/webcpanel/pages/confirm.cpp +++ b/modules/extra/webcpanel/pages/confirm.cpp @@ -21,7 +21,7 @@ bool WebCPanel::Confirm::OnRequest(HTTPProvider *server, const Anope::string &pa if (!email.empty()) params.push_back(email); - WebPanel::RunCommand(user, NULL, Config->NickServ, "nickserv/register", params, replacements); + WebPanel::RunCommand(user, NULL, ::NickServ->nick, "nickserv/register", params, replacements); } TemplateFileServer page("confirm.html"); diff --git a/modules/extra/webcpanel/pages/hostserv/request.cpp b/modules/extra/webcpanel/pages/hostserv/request.cpp index 6335b1a56..30a396a9b 100644 --- a/modules/extra/webcpanel/pages/hostserv/request.cpp +++ b/modules/extra/webcpanel/pages/hostserv/request.cpp @@ -18,7 +18,7 @@ bool WebCPanel::HostServ::Request::OnRequest(HTTPProvider *server, const Anope:: std::vector<Anope::string> params; params.push_back(HTTPUtils::URLDecode(message.post_data["req"])); - WebPanel::RunCommand(na->nc->display, na->nc, Config->HostServ, "hostserv/request", params, replacements, "CMDR"); + WebPanel::RunCommand(na->nc->display, na->nc, ::HostServ->nick, "hostserv/request", params, replacements, "CMDR"); } if (na->HasVhost()) diff --git a/modules/extra/webcpanel/pages/memoserv/memos.cpp b/modules/extra/webcpanel/pages/memoserv/memos.cpp index 671820ced..9324bea56 100644 --- a/modules/extra/webcpanel/pages/memoserv/memos.cpp +++ b/modules/extra/webcpanel/pages/memoserv/memos.cpp @@ -57,7 +57,7 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st params.push_back(HTTPUtils::URLDecode(message.post_data["receiver"])); params.push_back(HTTPUtils::URLDecode(message.post_data["message"])); - WebPanel::RunCommand(na->nc->display, na->nc, Config->MemoServ, "memoserv/send", params, replacements, "CMDR"); + WebPanel::RunCommand(na->nc->display, na->nc, ::MemoServ->nick, "memoserv/send", params, replacements, "CMDR"); } if (message.get_data.count("del") > 0 && message.get_data.count("number") > 0) { @@ -66,7 +66,7 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st params.push_back(chname); params.push_back(message.get_data["number"]); - WebPanel::RunCommand(na->nc->display, na->nc, Config->MemoServ, "memoserv/del", params, replacements, "CMDR"); + WebPanel::RunCommand(na->nc->display, na->nc, ::MemoServ->nick, "memoserv/del", params, replacements, "CMDR"); } if (message.get_data.count("read") > 0 && message.get_data.count("number") > 0) { diff --git a/modules/extra/webcpanel/pages/nickserv/access.cpp b/modules/extra/webcpanel/pages/nickserv/access.cpp index de0e544f7..41dc0f429 100644 --- a/modules/extra/webcpanel/pages/nickserv/access.cpp +++ b/modules/extra/webcpanel/pages/nickserv/access.cpp @@ -19,7 +19,7 @@ bool WebCPanel::NickServ::Access::OnRequest(HTTPProvider *server, const Anope::s params.push_back("ADD"); params.push_back(message.post_data["access"]); - WebPanel::RunCommand(na->nc->display, na->nc, Config->NickServ, "nickserv/access", params, replacements); + WebPanel::RunCommand(na->nc->display, na->nc, ::NickServ->nick, "nickserv/access", params, replacements); } else if (message.get_data.count("del") > 0 && message.get_data.count("mask") > 0) { @@ -27,7 +27,7 @@ bool WebCPanel::NickServ::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->NickServ, "nickserv/access", params, replacements); + WebPanel::RunCommand(na->nc->display, na->nc, ::NickServ->nick, "nickserv/access", params, replacements); } for (unsigned i = 0; i < na->nc->access.size(); ++i) diff --git a/modules/extra/webcpanel/pages/nickserv/cert.cpp b/modules/extra/webcpanel/pages/nickserv/cert.cpp index fc13e2ce5..44849a302 100644 --- a/modules/extra/webcpanel/pages/nickserv/cert.cpp +++ b/modules/extra/webcpanel/pages/nickserv/cert.cpp @@ -19,7 +19,7 @@ bool WebCPanel::NickServ::Cert::OnRequest(HTTPProvider *server, const Anope::str params.push_back("ADD"); params.push_back(message.post_data["certfp"]); - WebPanel::RunCommand(na->nc->display, na->nc, Config->NickServ, "nickserv/cert", params, replacements); + WebPanel::RunCommand(na->nc->display, na->nc, ::NickServ->nick, "nickserv/cert", params, replacements); } else if (message.get_data.count("del") > 0 && message.get_data.count("mask") > 0) { @@ -27,7 +27,7 @@ bool WebCPanel::NickServ::Cert::OnRequest(HTTPProvider *server, const Anope::str params.push_back("DEL"); params.push_back(message.get_data["mask"]); - WebPanel::RunCommand(na->nc->display, na->nc, Config->NickServ, "nickserv/cert", params, replacements); + WebPanel::RunCommand(na->nc->display, na->nc, ::NickServ->nick, "nickserv/cert", params, replacements); } for (unsigned i = 0; i < na->nc->cert.size(); ++i) diff --git a/modules/extra/webcpanel/pages/operserv/akill.cpp b/modules/extra/webcpanel/pages/operserv/akill.cpp index 87b8f94fb..ae9824bce 100644 --- a/modules/extra/webcpanel/pages/operserv/akill.cpp +++ b/modules/extra/webcpanel/pages/operserv/akill.cpp @@ -34,7 +34,7 @@ bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::st cmdstr << " " << HTTPUtils::URLDecode(message.post_data["mask"]); cmdstr << " " << HTTPUtils::URLDecode(message.post_data["reason"]); params.push_back(cmdstr.str()); - WebPanel::RunCommand(na->nc->display, na->nc, Config->OperServ, "operserv/akill", params, replacements); + WebPanel::RunCommand(na->nc->display, na->nc, ::OperServ->nick, "operserv/akill", params, replacements); } if (message.get_data["del"] == "1" && message.get_data.count("number") > 0) @@ -42,7 +42,7 @@ bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::st std::vector<Anope::string> params; params.push_back("DEL"); params.push_back(HTTPUtils::URLDecode(message.get_data["number"])); - WebPanel::RunCommand(na->nc->display, na->nc, Config->OperServ, "operserv/akill", params, replacements); + WebPanel::RunCommand(na->nc->display, na->nc, ::OperServ->nick, "operserv/akill", params, replacements); } for (unsigned i = 0, end = akills->GetCount(); i < end; ++i) diff --git a/modules/extra/webcpanel/pages/register.cpp b/modules/extra/webcpanel/pages/register.cpp index 409069348..730db612d 100644 --- a/modules/extra/webcpanel/pages/register.cpp +++ b/modules/extra/webcpanel/pages/register.cpp @@ -13,7 +13,7 @@ bool WebCPanel::Register::OnRequest(HTTPProvider *server, const Anope::string &p replacements["TITLE"] = page_title; - if (!Config->NSForceEmail) + if (!Config->GetModule("nickserv")->Get<bool>("forceemail", "yes")) replacements["EMAIL_TYPE"] = "hidden"; TemplateFileServer page("register.html"); diff --git a/modules/extra/webcpanel/webcpanel.cpp b/modules/extra/webcpanel/webcpanel.cpp index e2a026559..ca0b2f93d 100644 --- a/modules/extra/webcpanel/webcpanel.cpp +++ b/modules/extra/webcpanel/webcpanel.cpp @@ -45,19 +45,19 @@ class ModuleWebCPanel : public Module panel(this, "webcpanel"), style_css("style.css", "/static/style.css", "text/css"), logo_png("logo.png", "/static/logo.png", "image/png"), favicon_ico("favicon.ico", "/favicon.ico", "image/x-icon"), index("/"), logout("/logout"), _register("/register"), confirm("/confirm"), - nickserv_info(Config->NickServ, "/nickserv/info"), nickserv_cert(Config->NickServ, "/nickserv/cert"), nickserv_access(Config->NickServ, "/nickserv/access"), nickserv_alist(Config->NickServ, "/nickserv/alist"), - chanserv_info(Config->ChanServ, "/chanserv/info"), chanserv_set(Config->ChanServ, "/chanserv/set"), chanserv_access(Config->ChanServ, "/chanserv/access"), chanserv_akick(Config->ChanServ, "/chanserv/akick"), - chanserv_drop(Config->ChanServ, "/chanserv/drop"), memoserv_memos(Config->MemoServ, "/memoserv/memos"), hostserv_request(Config->HostServ, "/hostserv/request"), operserv_akill(Config->OperServ, "/operserv/akill") + nickserv_info("NickServ", "/nickserv/info"), nickserv_cert("NickServ", "/nickserv/cert"), nickserv_access("NickServ", "/nickserv/access"), nickserv_alist("NickServ", "/nickserv/alist"), + chanserv_info("ChanServ", "/chanserv/info"), chanserv_set("ChanServ", "/chanserv/set"), chanserv_access("ChanServ", "/chanserv/access"), chanserv_akick("ChanServ", "/chanserv/akick"), + chanserv_drop("ChanServ", "/chanserv/drop"), memoserv_memos("MemoServ", "/memoserv/memos"), hostserv_request("HostServ", "/hostserv/request"), operserv_akill("OperServ", "/operserv/akill") { me = this; - ConfigReader reader; - provider_name = reader.ReadValue("webcpanel", "server", "httpd/main", 0); - template_name = reader.ReadValue("webcpanel", "template", "template", 0); + Configuration::Block *block = Config->GetModule(this); + provider_name = block->Get<const Anope::string &>("server", "httpd/main"); + template_name = block->Get<const Anope::string &>("template", "default"); template_base = Anope::DataDir + "/modules/webcpanel/templates/" + template_name; - page_title = reader.ReadValue("webcpanel", "title", "Anope IRC Services", 0); - use_ssl = reader.ReadFlag("webcpanel", "ssl", "no", 0); // This is dumb, is there a better way to do this? + page_title = block->Get<const Anope::string &>("title", "Anope IRC Services"); + use_ssl = block->Get<bool>("ssl", "no"); // This is dumb, is there a better way to do this? ServiceReference<HTTPProvider> provider("HTTPProvider", provider_name); if (!provider) @@ -72,10 +72,10 @@ class ModuleWebCPanel : public Module provider->RegisterPage(&this->_register); provider->RegisterPage(&this->confirm); - if (Config->NickServ.empty() == false) + if (NickServ) { Section s; - s.name = Config->NickServ; + s.name = NickServ->nick; SubSection ss; ss.name = "Information"; @@ -103,10 +103,11 @@ class ModuleWebCPanel : public Module panel.sections.push_back(s); } - if (Config->ChanServ.empty() == false) + + if (ChanServ) { Section s; - s.name = Config->ChanServ; + s.name = ChanServ->nick; SubSection ss; ss.name = "Channels"; @@ -137,10 +138,10 @@ class ModuleWebCPanel : public Module panel.sections.push_back(s); } - if (Config->MemoServ.empty() == false) + if (MemoServ) { Section s; - s.name = Config->MemoServ; + s.name = MemoServ->nick; SubSection ss; ss.name = "Memos"; @@ -151,10 +152,10 @@ class ModuleWebCPanel : public Module panel.sections.push_back(s); } - if (Config->HostServ.empty() == false) + if (HostServ) { Section s; - s.name = Config->HostServ; + s.name = HostServ->nick; SubSection ss; ss.name = "vHost Request"; @@ -165,10 +166,10 @@ class ModuleWebCPanel : public Module panel.sections.push_back(s); } - if (Config->OperServ.empty() == false) + if (OperServ) { Section s; - s.name = Config->OperServ; + s.name = OperServ->nick; SubSection ss; ss.name = "Akill"; |