From a59d08fffd3dc8a9850ce34c9928fb6382b9b37f Mon Sep 17 00:00:00 2001 From: danieldg Date: Sun, 18 Oct 2009 16:01:33 +0000 Subject: Remove VF_SERVICEPROVIDER, prevent heap allocation of ConfigReader git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11904 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/bancache.h | 4 +-- include/base.h | 14 ++++++++ include/command_parse.h | 2 +- include/commands/cmd_whowas.h | 4 +-- include/configreader.h | 2 +- include/modules.h | 25 +++++++-------- include/xline.h | 4 +-- src/logger.cpp | 4 +-- src/modules/extra/m_mysql.cpp | 56 ++++++++++++++++---------------- src/modules/extra/m_pgsql.cpp | 2 +- src/modules/extra/m_regex_pcre.cpp | 2 +- src/modules/extra/m_regex_posix.cpp | 2 +- src/modules/extra/m_regex_tre.cpp | 2 +- src/modules/extra/m_sqlite3.cpp | 2 +- src/modules/m_censor.cpp | 10 +++--- src/modules/m_conn_join.cpp | 5 ++- src/modules/m_connflood.cpp | 15 ++++----- src/modules/m_dccallow.cpp | 22 ++++++------- src/modules/m_deaf.cpp | 8 ++--- src/modules/m_denychans.cpp | 40 ++++++++++------------- src/modules/m_dnsbl.cpp | 28 ++++++++-------- src/modules/m_httpd.cpp | 2 +- src/modules/m_md5.cpp | 4 +-- src/modules/m_nationalchars.cpp | 9 +++--- src/modules/m_operjoin.cpp | 21 ++++++------ src/modules/m_operlevels.cpp | 38 +++++++--------------- src/modules/m_opermodes.cpp | 47 ++++++++++----------------- src/modules/m_opermotd.cpp | 13 +++----- src/modules/m_randquote.cpp | 11 +++---- src/modules/m_regex_glob.cpp | 2 +- src/modules/m_restrictchans.cpp | 20 +++++------- src/modules/m_ripemd160.cpp | 2 +- src/modules/m_securelist.cpp | 9 +++--- src/modules/m_sha256.cpp | 4 +-- src/modules/m_spanningtree/utils.cpp | 62 +++++++++++++++++------------------- src/modules/m_sqlutils.cpp | 2 +- src/modules/m_sslinfo.cpp | 2 +- src/modules/m_vhost.cpp | 21 ++++++------ 38 files changed, 232 insertions(+), 290 deletions(-) diff --git a/include/bancache.h b/include/bancache.h index c9c469e4f..952a1453a 100644 --- a/include/bancache.h +++ b/include/bancache.h @@ -21,7 +21,7 @@ * entries expire every few hours, which is a reasonable expiry for any reasonable * sized network. */ -class CoreExport BanCacheHit : public classbase +class CoreExport BanCacheHit { public: /** Type of cached ban @@ -66,7 +66,7 @@ typedef nspace::hash_map > /** A manager for ban cache, which allocates and deallocates and checks cached bans. */ -class CoreExport BanCacheManager : public classbase +class CoreExport BanCacheManager { private: BanCacheHash* BanHash; diff --git a/include/base.h b/include/base.h index 624e2174f..856cd64c2 100644 --- a/include/base.h +++ b/include/base.h @@ -47,6 +47,20 @@ class CoreExport classbase void operator=(const classbase&); }; +/** The base class for inspircd classes that provide a wrapping interface, and + * should only exist while being used. Prevents heap allocation. + */ +class CoreExport interfacebase +{ + public: + interfacebase() {} + private: + interfacebase(const interfacebase&); + void operator=(const interfacebase&); + void* operator new(size_t); + void operator delete(void*); +}; + /** The base class for inspircd classes that support reference counting. * Any objects that do not have a well-defined lifetime should inherit from * this, and should be assigned to a reference object to establish their diff --git a/include/command_parse.h b/include/command_parse.h index 35f5a7b0e..814cdb27a 100644 --- a/include/command_parse.h +++ b/include/command_parse.h @@ -23,7 +23,7 @@ typedef std::map SharedObjectList; * call command handlers by name, and chop up comma seperated * parameters into multiple calls. */ -class CoreExport CommandParser : public classbase +class CoreExport CommandParser { private: /** Parameter buffer diff --git a/include/commands/cmd_whowas.h b/include/commands/cmd_whowas.h index 12c9eae9a..71c635b39 100644 --- a/include/commands/cmd_whowas.h +++ b/include/commands/cmd_whowas.h @@ -94,7 +94,7 @@ class CommandWhowas : public Command /** Used to hold WHOWAS information */ -class WhoWasGroup : public classbase +class WhoWasGroup { public: /** Real host @@ -116,7 +116,7 @@ class WhoWasGroup : public classbase */ time_t signon; - /** Initialize this WhoQasFroup with a user + /** Initialize this WhoWasFroup with a user */ WhoWasGroup(User* user); /** Destructor diff --git a/include/configreader.h b/include/configreader.h index 553f49d60..402f984e8 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -117,7 +117,7 @@ class ServerLimits * and storage of the configuration data needed to run the ircd, such as * the servername, connect classes, /ADMIN data, MOTDs and filenames etc. */ -class CoreExport ServerConfig : public classbase +class CoreExport ServerConfig { private: void CrossCheckOperClassType(); diff --git a/include/modules.h b/include/modules.h index 96506f598..ad9cf05b8 100644 --- a/include/modules.h +++ b/include/modules.h @@ -33,10 +33,9 @@ enum ModuleFlags { VF_NONE = 0, // module is not special at all VF_STATIC = 1, // module is static, cannot be /unloadmodule'd VF_VENDOR = 2, // module is a vendor module (came in the original tarball, not 3rd party) - VF_SERVICEPROVIDER = 4, // module provides a service to other modules (can be a dependency) - VF_COMMON = 8, // module needs to be common on all servers in a network to link - VF_OPTCOMMON = 16, // module should be common on all servers for unsurprising behavior - VF_CORE = 32 // module is a core command, can be assumed loaded on all servers + VF_COMMON = 4, // module needs to be common on all servers in a network to link + VF_OPTCOMMON = 8, // module should be common on all servers for unsurprising behavior + VF_CORE = 16 // module is a core command, can be assumed loaded on all servers }; /** Used with SendToMode() @@ -74,26 +73,26 @@ struct ModResult { int res; ModResult() : res(0) {} explicit ModResult(int r) : res(r) {} - bool operator==(const ModResult& r) const + inline bool operator==(const ModResult& r) const { return res == r.res; } - bool operator!=(const ModResult& r) const + inline bool operator!=(const ModResult& r) const { return res != r.res; } - bool operator!() const + inline bool operator!() const { return !res; } - bool check(bool def) const + inline bool check(bool def) const { return (res == 1 || (res == 0 && def)); } /** * Merges two results, preferring ALLOW to DENY */ - ModResult operator+(const ModResult& r) const + inline ModResult operator+(const ModResult& r) const { if (res == r.res || r.res == 0) return *this; @@ -107,7 +106,7 @@ struct ModResult { /** If you change the module API in any way, increment this value. * This MUST be a pure integer, with no parenthesis */ -#define API_VERSION 134 +#define API_VERSION 135 class ServerConfig; @@ -314,7 +313,7 @@ class CoreExport Event : public classbase void Send(); }; -/** Priority types which can be returned from Module::Prioritize() +/** Priority types which can be used by Module::Prioritize() */ enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER }; @@ -1297,7 +1296,7 @@ class CoreExport Module : public classbase * Constructing the class using one parameter allows you to specify a path to your own configuration * file, otherwise, inspircd.conf is read. */ -class CoreExport ConfigReader : public classbase +class CoreExport ConfigReader : public interfacebase { protected: /** Error code @@ -1461,7 +1460,7 @@ typedef IntModuleList::iterator EventHandlerIter; /** ModuleManager takes care of all things module-related * in the core. */ -class CoreExport ModuleManager : public classbase +class CoreExport ModuleManager { private: /** Holds a string describing the last module error to occur diff --git a/include/xline.h b/include/xline.h index 7ac4aa7f1..e349c28d7 100644 --- a/include/xline.h +++ b/include/xline.h @@ -366,7 +366,7 @@ typedef std::pair IdentHostPair; * does not have to know the specifics of the internals of an XLine class * and/or how to call its constructor. */ -class CoreExport XLineFactory : public classbase +class CoreExport XLineFactory { protected: @@ -436,7 +436,7 @@ typedef XLineLookup::iterator LookupIter; * or any other line created by a module. It also manages XLineFactory classes which * can generate a specialized XLine for use by another module. */ -class CoreExport XLineManager : public classbase +class CoreExport XLineManager { protected: /** Used to hold XLines which have not yet been applied. diff --git a/src/logger.cpp b/src/logger.cpp index c9b1cf9e4..be28bf836 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -68,7 +68,7 @@ void LogManager::OpenFileLogs() { return; } - ConfigReader* Conf = new ConfigReader; + ConfigReader Conf; std::map logmap; std::map::iterator i; for (int index = 0;; ++index) @@ -106,7 +106,7 @@ void LogManager::OpenFileLogs() loglevel = NONE; } FileWriter* fw; - std::string target = Conf->ReadValue("log", "target", index); + std::string target = Conf.ReadValue("log", "target", index); if ((i = logmap.find(target)) == logmap.end()) { FILE* f = fopen(target.c_str(), "a"); diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 90a2d95dc..47de25ee4 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -87,8 +87,6 @@ unsigned long count(const char * const str, char a) class ModuleSQL : public Module { public: - - ConfigReader *Conf; int currid; bool rehashing; DispatcherThread* Dispatcher; @@ -549,30 +547,31 @@ bool HasHost(const SQLhost &host) return false; } -bool HostInConf(ConfigReader* conf, const SQLhost &h) +bool HostInConf(const SQLhost &h) { - for(int i = 0; i < conf->Enumerate("database"); i++) + ConfigReader conf; + for(int i = 0; i < conf.Enumerate("database"); i++) { SQLhost host; - host.id = conf->ReadValue("database", "id", i); - host.host = conf->ReadValue("database", "hostname", i); - host.port = conf->ReadInteger("database", "port", i, true); - host.name = conf->ReadValue("database", "name", i); - host.user = conf->ReadValue("database", "username", i); - host.pass = conf->ReadValue("database", "password", i); - host.ssl = conf->ReadFlag("database", "ssl", i); + host.id = conf.ReadValue("database", "id", i); + host.host = conf.ReadValue("database", "hostname", i); + host.port = conf.ReadInteger("database", "port", i, true); + host.name = conf.ReadValue("database", "name", i); + host.user = conf.ReadValue("database", "username", i); + host.pass = conf.ReadValue("database", "password", i); + host.ssl = conf.ReadFlag("database", "ssl", i); if (h == host) return true; } return false; } -void ClearOldConnections(ConfigReader* conf) +void ClearOldConnections() { ConnMap::iterator i,safei; for (i = Connections.begin(); i != Connections.end(); i++) { - if (!HostInConf(conf, i->second->GetConfHost())) + if (!HostInConf(i->second->GetConfHost())) { delete i->second; safei = i; @@ -611,21 +610,22 @@ void ConnectDatabases(ModuleSQL* Parent) } } -void LoadDatabases(ConfigReader* conf, ModuleSQL* Parent) +void LoadDatabases(ModuleSQL* Parent) { + ConfigReader conf; Parent->ConnMutex.Lock(); - ClearOldConnections(conf); - for (int j =0; j < conf->Enumerate("database"); j++) + ClearOldConnections(); + for (int j =0; j < conf.Enumerate("database"); j++) { SQLhost host; - host.id = conf->ReadValue("database", "id", j); - host.host = conf->ReadValue("database", "hostname", j); - host.port = conf->ReadInteger("database", "port", j, true); - host.name = conf->ReadValue("database", "name", j); - host.user = conf->ReadValue("database", "username", j); - host.pass = conf->ReadValue("database", "password", j); - host.ssl = conf->ReadFlag("database", "ssl", j); - std::string initquery = conf->ReadValue("database", "initialquery", j); + host.id = conf.ReadValue("database", "id", j); + host.host = conf.ReadValue("database", "hostname", j); + host.port = conf.ReadInteger("database", "port", j, true); + host.name = conf.ReadValue("database", "name", j); + host.user = conf.ReadValue("database", "username", j); + host.pass = conf.ReadValue("database", "password", j); + host.ssl = conf.ReadFlag("database", "ssl", j); + std::string initquery = conf.ReadValue("database", "initialquery", j); if (HasHost(host)) continue; @@ -683,7 +683,6 @@ ModuleSQL::ModuleSQL() : rehashing(false) { ServerInstance->Modules->UseInterface("SQLutils"); - Conf = new ConfigReader; currid = 0; Dispatcher = new DispatcherThread(this); @@ -706,7 +705,6 @@ ModuleSQL::~ModuleSQL() { delete Dispatcher; ClearAllConnections(); - delete Conf; ServerInstance->Modules->UnpublishInterface("SQL", this); ServerInstance->Modules->UnpublishFeature("SQL"); ServerInstance->Modules->DoneWithInterface("SQLutils"); @@ -756,12 +754,12 @@ void ModuleSQL::OnRehash(User* user) Version ModuleSQL::GetVersion() { - return Version("SQL Service Provider module for all other m_sql* modules", VF_VENDOR | VF_SERVICEPROVIDER); + return Version("SQL Service Provider module for all other m_sql* modules", VF_VENDOR); } void DispatcherThread::Run() { - LoadDatabases(Parent->Conf, Parent); + LoadDatabases(Parent); SQLConnection* conn = NULL; @@ -771,7 +769,7 @@ void DispatcherThread::Run() if (Parent->rehashing) { Parent->rehashing = false; - LoadDatabases(Parent->Conf, Parent); + LoadDatabases(Parent); } conn = NULL; diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 5d2fe106b..b5beea0b0 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -954,7 +954,7 @@ class ModulePgSQL : public Module virtual Version GetVersion() { - return Version("PostgreSQL Service Provider module for all other m_sql* modules, uses v2 of the SQL API", VF_VENDOR|VF_SERVICEPROVIDER); + return Version("PostgreSQL Service Provider module for all other m_sql* modules, uses v2 of the SQL API", VF_VENDOR); } }; diff --git a/src/modules/extra/m_regex_pcre.cpp b/src/modules/extra/m_regex_pcre.cpp index 8f2284ce6..9e8aff159 100644 --- a/src/modules/extra/m_regex_pcre.cpp +++ b/src/modules/extra/m_regex_pcre.cpp @@ -76,7 +76,7 @@ public: virtual Version GetVersion() { - return Version("Regex Provider Module for PCRE", VF_COMMON | VF_VENDOR | VF_SERVICEPROVIDER); + return Version("Regex Provider Module for PCRE", VF_COMMON | VF_VENDOR); } virtual ~ModuleRegexPCRE() diff --git a/src/modules/extra/m_regex_posix.cpp b/src/modules/extra/m_regex_posix.cpp index 1bcd32187..ea016ae64 100644 --- a/src/modules/extra/m_regex_posix.cpp +++ b/src/modules/extra/m_regex_posix.cpp @@ -85,7 +85,7 @@ public: virtual Version GetVersion() { - return Version("Regex Provider Module for POSIX Regular Expressions", VF_COMMON | VF_VENDOR | VF_SERVICEPROVIDER); + return Version("Regex Provider Module for POSIX Regular Expressions", VF_COMMON | VF_VENDOR); } virtual ~ModuleRegexPOSIX() diff --git a/src/modules/extra/m_regex_tre.cpp b/src/modules/extra/m_regex_tre.cpp index ef0ed91a4..01c6ebf4a 100644 --- a/src/modules/extra/m_regex_tre.cpp +++ b/src/modules/extra/m_regex_tre.cpp @@ -82,7 +82,7 @@ public: virtual Version GetVersion() { - return Version("Regex Provider Module for TRE Regular Expressions", VF_COMMON | VF_VENDOR | VF_SERVICEPROVIDER); + return Version("Regex Provider Module for TRE Regular Expressions", VF_COMMON | VF_VENDOR); } virtual ~ModuleRegexTRE() diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp index aba3c0930..234f89ea2 100644 --- a/src/modules/extra/m_sqlite3.cpp +++ b/src/modules/extra/m_sqlite3.cpp @@ -723,7 +723,7 @@ class ModuleSQLite3 : public Module virtual Version GetVersion() { - return Version("sqlite3 provider", VF_VENDOR | VF_SERVICEPROVIDER); + return Version("sqlite3 provider", VF_VENDOR); } }; diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index 398241475..faf2a4200 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -114,17 +114,15 @@ class ModuleCensor : public Module * reload our config file on rehash - we must destroy and re-allocate the classes * to call the constructor again and re-read our data. */ - ConfigReader* MyConf = new ConfigReader; + ConfigReader MyConf; censors.clear(); - for (int index = 0; index < MyConf->Enumerate("badword"); index++) + for (int index = 0; index < MyConf.Enumerate("badword"); index++) { - irc::string pattern = (MyConf->ReadValue("badword","text",index)).c_str(); - irc::string replace = (MyConf->ReadValue("badword","replace",index)).c_str(); + irc::string pattern = (MyConf.ReadValue("badword","text",index)).c_str(); + irc::string replace = (MyConf.ReadValue("badword","replace",index)).c_str(); censors[pattern] = replace; } - - delete MyConf; } virtual Version GetVersion() diff --git a/src/modules/m_conn_join.cpp b/src/modules/m_conn_join.cpp index b1f12e1eb..ef834e55a 100644 --- a/src/modules/m_conn_join.cpp +++ b/src/modules/m_conn_join.cpp @@ -57,12 +57,11 @@ class ModuleConnJoin : public Module virtual void OnRehash(User* user) { - ConfigReader* conf = new ConfigReader; - JoinChan = conf->ReadValue("autojoin", "channel", 0); + ConfigReader conf; + JoinChan = conf.ReadValue("autojoin", "channel", 0); Joinchans.clear(); if (!JoinChan.empty()) tokenize(JoinChan,Joinchans); - delete conf; } virtual ~ModuleConnJoin() diff --git a/src/modules/m_connflood.cpp b/src/modules/m_connflood.cpp index ae9fcf0e5..b2aaab45a 100644 --- a/src/modules/m_connflood.cpp +++ b/src/modules/m_connflood.cpp @@ -24,9 +24,6 @@ private: time_t first; std::string quitmsg; - ConfigReader* conf; - - public: ModuleConnFlood() { @@ -47,15 +44,15 @@ public: void InitConf() { /* read configuration variables */ - conf = new ConfigReader; + ConfigReader conf; /* throttle configuration */ - seconds = conf->ReadInteger("connflood", "seconds", 0, true); - maxconns = conf->ReadInteger("connflood", "maxconns", 0, true); - timeout = conf->ReadInteger("connflood", "timeout", 0, true); - quitmsg = conf->ReadValue("connflood", "quitmsg", 0); + seconds = conf.ReadInteger("connflood", "seconds", 0, true); + maxconns = conf.ReadInteger("connflood", "maxconns", 0, true); + timeout = conf.ReadInteger("connflood", "timeout", 0, true); + quitmsg = conf.ReadValue("connflood", "quitmsg", 0); /* seconds to wait when the server just booted */ - boot_wait = conf->ReadInteger("connflood", "bootwait", 0, true); + boot_wait = conf.ReadInteger("connflood", "bootwait", 0, true); first = ServerInstance->Time(); } diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index d4be35ceb..fb05283fc 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -15,8 +15,6 @@ /* $ModDesc: Povides support for the /DCCALLOW command */ -static ConfigReader *Conf; - class BannedFileList { public: @@ -140,7 +138,8 @@ class CommandDccallow : public Command } std::string mask = std::string(target->nick)+"!"+std::string(target->ident)+"@"+std::string(target->dhost); - std::string default_length = Conf->ReadValue("dccallow", "length", 0); + ConfigReader Conf; + std::string default_length = Conf.ReadValue("dccallow", "length", 0); long length; if (parameters.size() < 2) @@ -242,7 +241,6 @@ class ModuleDCCAllow : public Module ModuleDCCAllow() : cmd(this) { - Conf = new ConfigReader; ext = new SimpleExtItem("dccallow", this); ServerInstance->Extensions.Register(ext); ServerInstance->AddCommand(&cmd); @@ -254,8 +252,6 @@ class ModuleDCCAllow : public Module virtual void OnRehash(User* user) { - delete Conf; - Conf = new ConfigReader; ReadFileConf(); } @@ -325,11 +321,12 @@ class ModuleDCCAllow : public Module irc::string type = tokens[1].c_str(); - bool blockchat = Conf->ReadFlag("dccallow", "blockchat", 0); + ConfigReader Conf; + bool blockchat = Conf.ReadFlag("dccallow", "blockchat", 0); if (type == "SEND") { - std::string defaultaction = Conf->ReadValue("dccallow", "action", 0); + std::string defaultaction = Conf.ReadValue("dccallow", "action", 0); std::string filename = tokens[2]; bool found = false; @@ -449,12 +446,13 @@ class ModuleDCCAllow : public Module void ReadFileConf() { + ConfigReader Conf; bfl.clear(); - for (int i = 0; i < Conf->Enumerate("banfile"); i++) + for (int i = 0; i < Conf.Enumerate("banfile"); i++) { BannedFileList bf; - std::string fileglob = Conf->ReadValue("banfile", "pattern", i); - std::string action = Conf->ReadValue("banfile", "action", i); + std::string fileglob = Conf.ReadValue("banfile", "pattern", i); + std::string action = Conf.ReadValue("banfile", "action", i); bf.filemask = fileglob; bf.action = action; bfl.push_back(bf); @@ -464,9 +462,7 @@ class ModuleDCCAllow : public Module virtual ~ModuleDCCAllow() { - delete Conf; delete ext; - Conf = NULL; } virtual Version GetVersion() diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp index f52702bca..fb6720ca9 100644 --- a/src/modules/m_deaf.cpp +++ b/src/modules/m_deaf.cpp @@ -67,11 +67,9 @@ class ModuleDeaf : public Module virtual void OnRehash(User* user) { - ConfigReader* conf = new ConfigReader; - deaf_bypasschars = conf->ReadValue("deaf", "bypasschars", 0); - deaf_bypasschars_uline = conf->ReadValue("deaf", "bypasscharsuline", 0); - - delete conf; + ConfigReader conf; + deaf_bypasschars = conf.ReadValue("deaf", "bypasschars", 0); + deaf_bypasschars_uline = conf.ReadValue("deaf", "bypasscharsuline", 0); } virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp index 4493b6240..4988c8daa 100644 --- a/src/modules/m_denychans.cpp +++ b/src/modules/m_denychans.cpp @@ -17,28 +17,20 @@ class ModuleDenyChannels : public Module { - private: - - - ConfigReader *Conf; - public: ModuleDenyChannels() { - - Conf = new ConfigReader; Implementation eventlist[] = { I_OnUserPreJoin, I_OnRehash }; ServerInstance->Modules->Attach(eventlist, this, 2); } virtual void OnRehash(User* user) { - delete Conf; - Conf = new ConfigReader; + ConfigReader Conf; /* check for redirect validity and loops/chains */ - for (int i =0; i < Conf->Enumerate("badchan"); i++) + for (int i =0; i < Conf.Enumerate("badchan"); i++) { - std::string name = Conf->ReadValue("badchan","name",i); - std::string redirect = Conf->ReadValue("badchan","redirect",i); + std::string name = Conf.ReadValue("badchan","name",i); + std::string redirect = Conf.ReadValue("badchan","redirect",i); if (!redirect.empty()) { @@ -50,14 +42,14 @@ class ModuleDenyChannels : public Module throw ModuleException("Invalid badchan redirect, not a channel"); } - for (int j =0; j < Conf->Enumerate("badchan"); j++) + for (int j =0; j < Conf.Enumerate("badchan"); j++) { - if (InspIRCd::Match(redirect, Conf->ReadValue("badchan","name",j))) + if (InspIRCd::Match(redirect, Conf.ReadValue("badchan","name",j))) { bool goodchan = false; - for (int k =0; k < Conf->Enumerate("goodchan"); k++) + for (int k =0; k < Conf.Enumerate("goodchan"); k++) { - if (InspIRCd::Match(redirect, Conf->ReadValue("goodchan","name",k))) + if (InspIRCd::Match(redirect, Conf.ReadValue("goodchan","name",k))) goodchan = true; } @@ -76,7 +68,6 @@ class ModuleDenyChannels : public Module virtual ~ModuleDenyChannels() { - delete Conf; } virtual Version GetVersion() @@ -87,22 +78,23 @@ class ModuleDenyChannels : public Module virtual ModResult OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven) { - for (int j =0; j < Conf->Enumerate("badchan"); j++) + ConfigReader Conf; + for (int j =0; j < Conf.Enumerate("badchan"); j++) { - if (InspIRCd::Match(cname, Conf->ReadValue("badchan","name",j))) + if (InspIRCd::Match(cname, Conf.ReadValue("badchan","name",j))) { - if (IS_OPER(user) && Conf->ReadFlag("badchan","allowopers",j)) + if (IS_OPER(user) && Conf.ReadFlag("badchan","allowopers",j)) { return MOD_RES_PASSTHRU; } else { - std::string reason = Conf->ReadValue("badchan","reason",j); - std::string redirect = Conf->ReadValue("badchan","redirect",j); + std::string reason = Conf.ReadValue("badchan","reason",j); + std::string redirect = Conf.ReadValue("badchan","redirect",j); - for (int i = 0; i < Conf->Enumerate("goodchan"); i++) + for (int i = 0; i < Conf.Enumerate("goodchan"); i++) { - if (InspIRCd::Match(cname, Conf->ReadValue("goodchan", "name", i))) + if (InspIRCd::Match(cname, Conf.ReadValue("goodchan", "name", i))) { return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 5fedf08dd..d97ea940a 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -24,7 +24,7 @@ /* $ModDesc: Provides handling of DNS blacklists */ /* Class holding data for a single entry */ -class DNSBLConfEntry : public classbase +class DNSBLConfEntry { public: enum EnumBanaction { I_UNKNOWN, I_KILL, I_ZLINE, I_KLINE, I_GLINE, I_MARK }; @@ -245,36 +245,36 @@ class ModuleDNSBL : public Module */ virtual void ReadConf() { - ConfigReader *MyConf = new ConfigReader; + ConfigReader MyConf; ClearEntries(); - for (int i=0; i< MyConf->Enumerate("dnsbl"); i++) + for (int i=0; i< MyConf.Enumerate("dnsbl"); i++) { DNSBLConfEntry *e = new DNSBLConfEntry(); - e->name = MyConf->ReadValue("dnsbl", "name", i); - e->ident = MyConf->ReadValue("dnsbl", "ident", i); - e->host = MyConf->ReadValue("dnsbl", "host", i); - e->reason = MyConf->ReadValue("dnsbl", "reason", i); - e->domain = MyConf->ReadValue("dnsbl", "domain", i); + e->name = MyConf.ReadValue("dnsbl", "name", i); + e->ident = MyConf.ReadValue("dnsbl", "ident", i); + e->host = MyConf.ReadValue("dnsbl", "host", i); + e->reason = MyConf.ReadValue("dnsbl", "reason", i); + e->domain = MyConf.ReadValue("dnsbl", "domain", i); - if (MyConf->ReadValue("dnsbl", "type", i) == "bitmask") + if (MyConf.ReadValue("dnsbl", "type", i) == "bitmask") { e->type = DNSBLConfEntry::A_BITMASK; - e->bitmask = MyConf->ReadInteger("dnsbl", "bitmask", i, false); + e->bitmask = MyConf.ReadInteger("dnsbl", "bitmask", i, false); } else { memset(e->records, 0, sizeof(e->records)); e->type = DNSBLConfEntry::A_RECORD; - irc::portparser portrange(MyConf->ReadValue("dnsbl", "records", i), false); + irc::portparser portrange(MyConf.ReadValue("dnsbl", "records", i), false); long item = -1; while ((item = portrange.GetToken())) e->records[item] = 1; } - e->banaction = str2banaction(MyConf->ReadValue("dnsbl", "action", i)); - e->duration = ServerInstance->Duration(MyConf->ReadValue("dnsbl", "duration", "60", i)); + e->banaction = str2banaction(MyConf.ReadValue("dnsbl", "action", i)); + e->duration = ServerInstance->Duration(MyConf.ReadValue("dnsbl", "duration", "60", i)); /* Use portparser for record replies */ @@ -315,8 +315,6 @@ class ModuleDNSBL : public Module /* delete and drop it, error somewhere */ delete e; } - - delete MyConf; } virtual void OnRehash(User* user) diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index 84d48cc38..2991b524e 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -421,7 +421,7 @@ class ModuleHttpServer : public Module virtual Version GetVersion() { - return Version("Provides HTTP serving facilities to modules", VF_VENDOR | VF_SERVICEPROVIDER); + return Version("Provides HTTP serving facilities to modules", VF_VENDOR); } }; diff --git a/src/modules/m_md5.cpp b/src/modules/m_md5.cpp index 7669d63d7..6ac9c3d87 100644 --- a/src/modules/m_md5.cpp +++ b/src/modules/m_md5.cpp @@ -39,7 +39,7 @@ typedef unsigned char byte; /** An MD5 context, used by m_opermd5 */ -class MD5Context : public classbase +class MD5Context { public: word32 buf[4]; @@ -296,7 +296,7 @@ class ModuleMD5 : public Module Version GetVersion() { - return Version("Allows for MD5 encrypted oper passwords",VF_VENDOR|VF_SERVICEPROVIDER); + return Version("Allows for MD5 encrypted oper passwords",VF_VENDOR); } }; diff --git a/src/modules/m_nationalchars.cpp b/src/modules/m_nationalchars.cpp index af6e962cf..5e919dad6 100755 --- a/src/modules/m_nationalchars.cpp +++ b/src/modules/m_nationalchars.cpp @@ -243,15 +243,14 @@ class ModuleNationalChars : public Module virtual void OnRehash(User* user) { - ConfigReader* conf = new ConfigReader; - charset = conf->ReadValue("nationalchars", "file", 0); - casemapping = conf->ReadValue("nationalchars", "casemapping", charset, 0, false); + ConfigReader conf; + charset = conf.ReadValue("nationalchars", "file", 0); + casemapping = conf.ReadValue("nationalchars", "casemapping", charset, 0, false); charset.insert(0, "../locales/"); unsigned char * tables[8] = { m_additional, m_additionalMB, m_additionalUp, m_lower, m_upper, m_additionalUtf8, m_additionalUtf8range, m_additionalUtf8interval }; loadtables(charset, tables, 8, 5); - forcequit = conf->ReadFlag("nationalchars", "forcequit", 0); + forcequit = conf.ReadFlag("nationalchars", "forcequit", 0); CheckForceQuit("National character set changed"); - delete conf; } void CheckForceQuit(const char * message) diff --git a/src/modules/m_operjoin.cpp b/src/modules/m_operjoin.cpp index 772bef525..42b30f6fb 100644 --- a/src/modules/m_operjoin.cpp +++ b/src/modules/m_operjoin.cpp @@ -43,36 +43,35 @@ class ModuleOperjoin : public Module } public: - ModuleOperjoin() { + ModuleOperjoin() + { OnRehash(NULL); - Implementation eventlist[] = { I_OnPostOper, I_OnRehash }; - ServerInstance->Modules->Attach(eventlist, this, 2); + Implementation eventlist[] = { I_OnPostOper, I_OnRehash }; + ServerInstance->Modules->Attach(eventlist, this, 2); } virtual void OnRehash(User* user) { - ConfigReader* conf = new ConfigReader; + ConfigReader conf; - operChan = conf->ReadValue("operjoin", "channel", 0); - override = conf->ReadFlag("operjoin", "override", "0", 0); + operChan = conf.ReadValue("operjoin", "channel", 0); + override = conf.ReadFlag("operjoin", "override", "0", 0); operChans.clear(); if (!operChan.empty()) tokenize(operChan,operChans); std::map >().swap(operTypeChans); - int olines = conf->Enumerate("type"); + int olines = conf.Enumerate("type"); for (int index = 0; index < olines; ++index) { - std::string chanList = conf->ReadValue("type", "autojoin", index); + std::string chanList = conf.ReadValue("type", "autojoin", index); if (!chanList.empty()) { - tokenize(chanList, operTypeChans[conf->ReadValue("type", "name", index)]); + tokenize(chanList, operTypeChans[conf.ReadValue("type", "name", index)]); } } - - delete conf; } virtual ~ModuleOperjoin() diff --git a/src/modules/m_operlevels.cpp b/src/modules/m_operlevels.cpp index 6ed0c2a53..7a18991c1 100644 --- a/src/modules/m_operlevels.cpp +++ b/src/modules/m_operlevels.cpp @@ -16,26 +16,20 @@ /* $ModDesc: Gives each oper type a 'level', cannot kill opers 'above' your level. */ class ModuleOperLevels : public Module { - private: - ConfigReader* conf; public: ModuleOperLevels() - { - conf = new ConfigReader; + { Implementation eventlist[] = { I_OnRehash, I_OnKill }; ServerInstance->Modules->Attach(eventlist, this, 2); } virtual ~ModuleOperLevels() { - delete conf; } virtual void OnRehash(User* user) { - delete conf; - conf = new ConfigReader; } virtual Version GetVersion() @@ -45,29 +39,19 @@ class ModuleOperLevels : public Module virtual ModResult OnKill(User* source, User* dest, const std::string &reason) { - long dest_level = 0,source_level = 0; - // oper killing an oper? if (IS_OPER(dest) && IS_OPER(source)) { - for (int j =0; j < conf->Enumerate("type"); j++) - { - std::string typen = conf->ReadValue("type","name",j); - if (typen == dest->oper) - { - dest_level = conf->ReadInteger("type","level",j,true); - break; - } - } - for (int k =0; k < conf->Enumerate("type"); k++) - { - std::string typen = conf->ReadValue("type","name",k); - if (typen == source->oper) - { - source_level = conf->ReadInteger("type","level",k,true); - break; - } - } + TagIndex::iterator dest_type = ServerInstance->Config->opertypes.find(dest->oper); + TagIndex::iterator src_type = ServerInstance->Config->opertypes.find(source->oper); + + if (dest_type == ServerInstance->Config->opertypes.end()) + return MOD_RES_PASSTHRU; + if (src_type == ServerInstance->Config->opertypes.end()) + return MOD_RES_PASSTHRU; + + long dest_level = dest_type->second->getInt("level"); + long source_level = src_type->second->getInt("level"); if (dest_level > source_level) { if (IS_LOCAL(source)) ServerInstance->SNO->WriteGlobalSno('a', "Oper %s (level %ld) attempted to /kill a higher oper: %s (level %ld): Reason: %s",source->nick.c_str(),source_level,dest->nick.c_str(),dest_level,reason.c_str()); diff --git a/src/modules/m_opermodes.cpp b/src/modules/m_opermodes.cpp index d4b873918..9db0b5b4a 100644 --- a/src/modules/m_opermodes.cpp +++ b/src/modules/m_opermodes.cpp @@ -17,16 +17,9 @@ class ModuleModesOnOper : public Module { - private: - - - ConfigReader *Conf; - public: ModuleModesOnOper() - { - - Conf = new ConfigReader; + { Implementation eventlist[] = { I_OnPostOper, I_OnRehash }; ServerInstance->Modules->Attach(eventlist, this, 2); } @@ -34,13 +27,10 @@ class ModuleModesOnOper : public Module virtual void OnRehash(User* user) { - delete Conf; - Conf = new ConfigReader; } virtual ~ModuleModesOnOper() { - delete Conf; } virtual Version GetVersion() @@ -50,36 +40,33 @@ class ModuleModesOnOper : public Module virtual void OnPostOper(User* user, const std::string &opertype, const std::string &opername) { + TagIndex::iterator typetag = ServerInstance->Config->opertypes.find(opertype); + if (typetag == ServerInstance->Config->opertypes.end()) + return; // whenever a user opers, go through the oper types, find their , // and if they have one apply their modes. The mode string can contain +modes // to add modes to the user or -modes to take modes from the user. - for (int j =0; j < Conf->Enumerate("type"); j++) + std::string ThisOpersModes = typetag->second->getString("modes"); + if (!ThisOpersModes.empty()) { - std::string typen = Conf->ReadValue("type","name",j); - if (typen == user->oper) - { - std::string ThisOpersModes = Conf->ReadValue("type","modes",j); - if (!ThisOpersModes.empty()) - { - ApplyModes(user, ThisOpersModes); - } - break; - } + ApplyModes(user, ThisOpersModes); } if (!opername.empty()) // if user is local .. { - for (int j = 0; j < Conf->Enumerate("oper"); j++) + for (int i = 0;; i++) { - if (opername == Conf->ReadValue("oper", "name", j)) - { - std::string ThisOpersModes = Conf->ReadValue("oper", "modes", j); - if (!ThisOpersModes.empty()) - { - ApplyModes(user, ThisOpersModes); - } + ConfigTag* tag = ServerInstance->Config->ConfValue("oper", i); + if (!tag) break; + if (tag->getString("name") != opername) + continue; + ThisOpersModes = tag->getString("modes"); + if (!ThisOpersModes.empty()) + { + ApplyModes(user, ThisOpersModes); } + break; } } } diff --git a/src/modules/m_opermotd.cpp b/src/modules/m_opermotd.cpp index a9f7b3b07..a4956f05f 100644 --- a/src/modules/m_opermotd.cpp +++ b/src/modules/m_opermotd.cpp @@ -63,17 +63,12 @@ class ModuleOpermotd : public Module void LoadOperMOTD() { - ConfigReader* conf = new ConfigReader; + ConfigReader conf; std::string filename; - filename = conf->ReadValue("opermotd","file",0); - if (opermotd) - { - delete opermotd; - opermotd = NULL; - } + filename = conf.ReadValue("opermotd","file",0); + delete opermotd; opermotd = new FileReader(filename); - onoper = conf->ReadFlag("opermotd","onoper","yes",0); - delete conf; + onoper = conf.ReadFlag("opermotd","onoper","yes",0); } ModuleOpermotd() diff --git a/src/modules/m_randquote.cpp b/src/modules/m_randquote.cpp index 3cdf4f30d..f6925e974 100644 --- a/src/modules/m_randquote.cpp +++ b/src/modules/m_randquote.cpp @@ -55,19 +55,17 @@ class ModuleRandQuote : public Module { private: CommandRandquote cmd; - ConfigReader *conf; public: ModuleRandQuote() : cmd(this) { - - conf = new ConfigReader; + ConfigReader conf; // Sort the Randomizer thingie.. srand(ServerInstance->Time()); - q_file = conf->ReadValue("randquote","file",0); - prefix = conf->ReadValue("randquote","prefix",0); - suffix = conf->ReadValue("randquote","suffix",0); + q_file = conf.ReadValue("randquote","file",0); + prefix = conf.ReadValue("randquote","prefix",0); + suffix = conf.ReadValue("randquote","suffix",0); if (q_file.empty()) { @@ -91,7 +89,6 @@ class ModuleRandQuote : public Module virtual ~ModuleRandQuote() { - delete conf; delete quotes; } diff --git a/src/modules/m_regex_glob.cpp b/src/modules/m_regex_glob.cpp index a3923205f..42cc0abd1 100644 --- a/src/modules/m_regex_glob.cpp +++ b/src/modules/m_regex_glob.cpp @@ -42,7 +42,7 @@ public: virtual Version GetVersion() { - return Version("Regex module using plain wildcard matching.", VF_OPTCOMMON | VF_VENDOR | VF_SERVICEPROVIDER); + return Version("Regex module using plain wildcard matching.", VF_OPTCOMMON | VF_VENDOR); } virtual ~ModuleRegexGlob() diff --git a/src/modules/m_restrictchans.cpp b/src/modules/m_restrictchans.cpp index 12c373ab8..8cc882d90 100644 --- a/src/modules/m_restrictchans.cpp +++ b/src/modules/m_restrictchans.cpp @@ -17,28 +17,24 @@ class ModuleRestrictChans : public Module { - - - std::map allowchans; + std::set allowchans; void ReadConfig() { - ConfigReader* MyConf = new ConfigReader; allowchans.clear(); - for (int i = 0; i < MyConf->Enumerate("allowchannel"); i++) + for (int i = 0;; i++) { - std::string txt; - txt = MyConf->ReadValue("allowchannel", "name", i); - irc::string channel = txt.c_str(); - allowchans[channel] = 1; + ConfigTag* tag = ServerInstance->Config->ConfValue("allowchannel", i); + if (!tag) + return; + std::string txt = tag->getString("name"); + allowchans.insert(txt.c_str()); } - delete MyConf; } public: ModuleRestrictChans() - { - + { ReadConfig(); Implementation eventlist[] = { I_OnUserPreJoin, I_OnRehash }; ServerInstance->Modules->Attach(eventlist, this, 2); diff --git a/src/modules/m_ripemd160.cpp b/src/modules/m_ripemd160.cpp index b8647b3a9..03a7f9895 100644 --- a/src/modules/m_ripemd160.cpp +++ b/src/modules/m_ripemd160.cpp @@ -465,7 +465,7 @@ class ModuleRIPEMD160 : public Module virtual Version GetVersion() { - return Version("Allows for RIPEMD-160 encrypted oper passwords", VF_VENDOR|VF_SERVICEPROVIDER); + return Version("Allows for RIPEMD-160 encrypted oper passwords", VF_VENDOR); } }; diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index 91dc3a0cd..c553aa742 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -38,14 +38,13 @@ class ModuleSecureList : public Module void OnRehash(User* user) { - ConfigReader* MyConf = new ConfigReader; + ConfigReader MyConf; allowlist.clear(); - for (int i = 0; i < MyConf->Enumerate("securehost"); i++) - allowlist.push_back(MyConf->ReadValue("securehost", "exception", i)); + for (int i = 0; i < MyConf.Enumerate("securehost"); i++) + allowlist.push_back(MyConf.ReadValue("securehost", "exception", i)); - WaitTime = MyConf->ReadInteger("securelist", "waittime", "60", 0, true); - delete MyConf; + WaitTime = MyConf.ReadInteger("securelist", "waittime", "60", 0, true); } diff --git a/src/modules/m_sha256.cpp b/src/modules/m_sha256.cpp index 1f967207b..7856b296b 100644 --- a/src/modules/m_sha256.cpp +++ b/src/modules/m_sha256.cpp @@ -62,7 +62,7 @@ typedef unsigned int uint32_t; /** An sha 256 context, used by m_opersha256 */ -class SHA256Context : public classbase +class SHA256Context { public: unsigned int tot_len; @@ -273,7 +273,7 @@ class ModuleSHA256 : public Module Version GetVersion() { - return Version("Allows for SHA-256 encrypted oper passwords", VF_VENDOR|VF_SERVICEPROVIDER); + return Version("Allows for SHA-256 encrypted oper passwords", VF_VENDOR); } }; diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 024605a79..c4d5755e6 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -381,16 +381,16 @@ void SpanningTreeUtilities::RefreshIPCache() void SpanningTreeUtilities::ReadConfiguration(bool rebind) { - ConfigReader* Conf = new ConfigReader; + ConfigReader Conf; if (rebind) { - for (int j = 0; j < Conf->Enumerate("bind"); j++) + for (int j = 0; j < Conf.Enumerate("bind"); j++) { - std::string Type = Conf->ReadValue("bind","type",j); - std::string IP = Conf->ReadValue("bind","address",j); - std::string Port = Conf->ReadValue("bind","port",j); - std::string ssl = Conf->ReadValue("bind","ssl",j); + std::string Type = Conf.ReadValue("bind","type",j); + std::string IP = Conf.ReadValue("bind","address",j); + std::string Port = Conf.ReadValue("bind","port",j); + std::string ssl = Conf.ReadValue("bind","ssl",j); if (Type == "servers") { irc::portparser portrange(Port, false); @@ -413,14 +413,14 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) } } } - FlatLinks = Conf->ReadFlag("security","flatlinks",0); - HideULines = Conf->ReadFlag("security","hideulines",0); - AnnounceTSChange = Conf->ReadFlag("options","announcets",0); - AllowOptCommon = Conf->ReadFlag("options", "allowmismatch", 0); - ChallengeResponse = !Conf->ReadFlag("security", "disablehmac", 0); - quiet_bursts = Conf->ReadFlag("performance", "quietbursts", 0); - PingWarnTime = Conf->ReadInteger("options", "pingwarning", 0, true); - PingFreq = Conf->ReadInteger("options", "serverpingfreq", 0, true); + FlatLinks = Conf.ReadFlag("security","flatlinks",0); + HideULines = Conf.ReadFlag("security","hideulines",0); + AnnounceTSChange = Conf.ReadFlag("options","announcets",0); + AllowOptCommon = Conf.ReadFlag("options", "allowmismatch", 0); + ChallengeResponse = !Conf.ReadFlag("security", "disablehmac", 0); + quiet_bursts = Conf.ReadFlag("performance", "quietbursts", 0); + PingWarnTime = Conf.ReadInteger("options", "pingwarning", 0, true); + PingFreq = Conf.ReadInteger("options", "serverpingfreq", 0, true); if (PingFreq == 0) PingFreq = 60; @@ -431,22 +431,22 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) AutoconnectBlocks.clear(); LinkBlocks.clear(); ValidIPs.clear(); - for (int j = 0; j < Conf->Enumerate("link"); ++j) + for (int j = 0; j < Conf.Enumerate("link"); ++j) { reference L = new Link; - std::string Allow = Conf->ReadValue("link", "allowmask", j); - L->Name = (Conf->ReadValue("link", "name", j)).c_str(); + std::string Allow = Conf.ReadValue("link", "allowmask", j); + L->Name = (Conf.ReadValue("link", "name", j)).c_str(); L->AllowMask = Allow; - L->IPAddr = Conf->ReadValue("link", "ipaddr", j); - L->Port = Conf->ReadInteger("link", "port", j, true); - L->SendPass = Conf->ReadValue("link", "sendpass", j); - L->RecvPass = Conf->ReadValue("link", "recvpass", j); - L->Fingerprint = Conf->ReadValue("link", "fingerprint", j); - L->HiddenFromStats = Conf->ReadFlag("link", "statshidden", j); - L->Timeout = Conf->ReadInteger("link", "timeout", j, true); - L->Hook = Conf->ReadValue("link", "ssl", j); - L->Bind = Conf->ReadValue("link", "bind", j); - L->Hidden = Conf->ReadFlag("link", "hidden", j); + L->IPAddr = Conf.ReadValue("link", "ipaddr", j); + L->Port = Conf.ReadInteger("link", "port", j, true); + L->SendPass = Conf.ReadValue("link", "sendpass", j); + L->RecvPass = Conf.ReadValue("link", "recvpass", j); + L->Fingerprint = Conf.ReadValue("link", "fingerprint", j); + L->HiddenFromStats = Conf.ReadFlag("link", "statshidden", j); + L->Timeout = Conf.ReadInteger("link", "timeout", j, true); + L->Hook = Conf.ReadValue("link", "ssl", j); + L->Bind = Conf.ReadValue("link", "bind", j); + L->Hidden = Conf.ReadFlag("link", "hidden", j); if (L->Name.find('.') == std::string::npos) throw CoreException("The link name '"+assign(L->Name)+"' is invalid and must contain at least one '.' character"); @@ -524,13 +524,13 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) LinkBlocks.push_back(L); } - for (int j = 0; j < Conf->Enumerate("autoconnect"); ++j) + for (int j = 0; j < Conf.Enumerate("autoconnect"); ++j) { reference A = new Autoconnect; - A->Period = Conf->ReadInteger("autoconnect", "period", j, true); + A->Period = Conf.ReadInteger("autoconnect", "period", j, true); A->NextConnectTime = ServerInstance->Time() + A->Period; A->position = -1; - std::string servers = Conf->ReadValue("autoconnect", "server", j); + std::string servers = Conf.ReadValue("autoconnect", "server", j); irc::spacesepstream ss(servers); std::string server; while (ss.GetToken(server)) @@ -550,8 +550,6 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) AutoconnectBlocks.push_back(A); } - - delete Conf; } Link* SpanningTreeUtilities::FindLink(const std::string& name) diff --git a/src/modules/m_sqlutils.cpp b/src/modules/m_sqlutils.cpp index 269f70ad0..28f32ec26 100644 --- a/src/modules/m_sqlutils.cpp +++ b/src/modules/m_sqlutils.cpp @@ -218,7 +218,7 @@ public: Version GetVersion() { - return Version("Provides some utilities to SQL client modules, such as mapping queries to users and channels", VF_VENDOR | VF_SERVICEPROVIDER); + return Version("Provides some utilities to SQL client modules, such as mapping queries to users and channels", VF_VENDOR); } }; diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index 31a209d4e..0ab749703 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -135,7 +135,7 @@ class ModuleSSLInfo : public Module Version GetVersion() { - return Version("SSL Certificate Utilities", VF_VENDOR | VF_SERVICEPROVIDER); + return Version("SSL Certificate Utilities", VF_VENDOR); } void OnWhois(User* source, User* dest) diff --git a/src/modules/m_vhost.cpp b/src/modules/m_vhost.cpp index a8f7b98e6..18c2a1eb0 100644 --- a/src/modules/m_vhost.cpp +++ b/src/modules/m_vhost.cpp @@ -27,29 +27,28 @@ class CommandVhost : public Command CmdResult Handle (const std::vector ¶meters, User *user) { - ConfigReader *Conf = new ConfigReader; - - for (int index = 0; index < Conf->Enumerate("vhost"); index++) + for (int index = 0;; index++) { - std::string mask = Conf->ReadValue("vhost","host",index); - std::string username = Conf->ReadValue("vhost","user",index); - std::string pass = Conf->ReadValue("vhost","pass",index); - std::string hash = Conf->ReadValue("vhost","hash",index); + ConfigTag* tag = ServerInstance->Config->ConfValue("vhost", index); + if (!tag) + break; + std::string mask = tag->getString("host"); + std::string username = tag->getString("user"); + std::string pass = tag->getString("pass"); + std::string hash = tag->getString("hash"); - if ((!strcmp(parameters[0].c_str(),username.c_str())) && !ServerInstance->PassCompare(user, pass.c_str(), parameters[1].c_str(), hash.c_str())) + if (parameters[0] == username && !ServerInstance->PassCompare(user, pass, parameters[1], hash)) { if (!mask.empty()) { - user->WriteServ("NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask); + user->WriteServ("NOTICE "+user->nick+" :Setting your VHost: " + mask); user->ChangeDisplayedHost(mask.c_str()); - delete Conf; return CMD_SUCCESS; } } } user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid username or password."); - delete Conf; return CMD_FAILURE; } }; -- cgit v1.2.3