From 583954d3a1db658281a9afb7b7dd6773726c8c11 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 28 Apr 2011 22:44:34 -0400 Subject: Use module type to determine what type each module is instead of its location in the configuration file. --- data/example.conf | 156 ++- docs/Changes.conf | 3 + include/anope.h | 13 +- include/config.h | 10 - include/extern.h | 4 +- include/modules.h | 49 +- include/servers.h | 4 +- modules/core/bs_act.cpp | 3 +- modules/core/bs_assign.cpp | 3 +- modules/core/bs_badwords.cpp | 3 +- modules/core/bs_bot.cpp | 3 +- modules/core/bs_botlist.cpp | 3 +- modules/core/bs_help.cpp | 3 +- modules/core/bs_info.cpp | 3 +- modules/core/bs_kick.cpp | 3 +- modules/core/bs_main.cpp | 5 +- modules/core/bs_say.cpp | 3 +- modules/core/bs_set.cpp | 3 +- modules/core/bs_unassign.cpp | 3 +- modules/core/cs_access.cpp | 3 +- modules/core/cs_akick.cpp | 3 +- modules/core/cs_ban.cpp | 3 +- modules/core/cs_clearusers.cpp | 3 +- modules/core/cs_clone.cpp | 3 +- modules/core/cs_drop.cpp | 3 +- modules/core/cs_forbid.cpp | 3 +- modules/core/cs_getkey.cpp | 3 +- modules/core/cs_help.cpp | 3 +- modules/core/cs_info.cpp | 3 +- modules/core/cs_invite.cpp | 3 +- modules/core/cs_kick.cpp | 3 +- modules/core/cs_list.cpp | 3 +- modules/core/cs_main.cpp | 5 +- modules/core/cs_mode.cpp | 3 +- modules/core/cs_modes.cpp | 3 +- modules/core/cs_register.cpp | 3 +- modules/core/cs_saset.cpp | 3 +- modules/core/cs_saset_noexpire.cpp | 3 +- modules/core/cs_set.cpp | 3 +- modules/core/cs_set_bantype.cpp | 3 +- modules/core/cs_set_description.cpp | 3 +- modules/core/cs_set_founder.cpp | 3 +- modules/core/cs_set_keeptopic.cpp | 3 +- modules/core/cs_set_opnotice.cpp | 3 +- modules/core/cs_set_peace.cpp | 3 +- modules/core/cs_set_persist.cpp | 3 +- modules/core/cs_set_private.cpp | 3 +- modules/core/cs_set_restricted.cpp | 3 +- modules/core/cs_set_secure.cpp | 3 +- modules/core/cs_set_securefounder.cpp | 3 +- modules/core/cs_set_secureops.cpp | 3 +- modules/core/cs_set_signkick.cpp | 3 +- modules/core/cs_set_successor.cpp | 3 +- modules/core/cs_set_topiclock.cpp | 3 +- modules/core/cs_set_xop.cpp | 5 +- modules/core/cs_status.cpp | 3 +- modules/core/cs_suspend.cpp | 3 +- modules/core/cs_topic.cpp | 3 +- modules/core/cs_unban.cpp | 3 +- modules/core/cs_xop.cpp | 3 +- modules/core/db_mysql.cpp | 1652 ++++++++++++++++++++++++++++++ modules/core/db_mysql_live.cpp | 289 ++++++ modules/core/db_plain.cpp | 3 +- modules/core/enc_md5.cpp | 16 +- modules/core/enc_none.cpp | 5 +- modules/core/enc_old.cpp | 16 +- modules/core/enc_sha1.cpp | 19 +- modules/core/enc_sha256.cpp | 16 +- modules/core/gl_global.cpp | 3 +- modules/core/gl_help.cpp | 3 +- modules/core/gl_main.cpp | 5 +- modules/core/hs_del.cpp | 3 +- modules/core/hs_delall.cpp | 3 +- modules/core/hs_group.cpp | 3 +- modules/core/hs_help.cpp | 3 +- modules/core/hs_list.cpp | 3 +- modules/core/hs_main.cpp | 7 +- modules/core/hs_off.cpp | 3 +- modules/core/hs_on.cpp | 3 +- modules/core/hs_set.cpp | 3 +- modules/core/hs_setall.cpp | 3 +- modules/core/ms_cancel.cpp | 3 +- modules/core/ms_check.cpp | 3 +- modules/core/ms_del.cpp | 3 +- modules/core/ms_help.cpp | 3 +- modules/core/ms_ignore.cpp | 3 +- modules/core/ms_info.cpp | 3 +- modules/core/ms_list.cpp | 3 +- modules/core/ms_main.cpp | 5 +- modules/core/ms_read.cpp | 3 +- modules/core/ms_rsend.cpp | 3 +- modules/core/ms_send.cpp | 3 +- modules/core/ms_sendall.cpp | 3 +- modules/core/ms_set.cpp | 3 +- modules/core/ms_staff.cpp | 3 +- modules/core/ns_access.cpp | 3 +- modules/core/ns_ajoin.cpp | 3 +- modules/core/ns_alist.cpp | 3 +- modules/core/ns_cert.cpp | 5 +- modules/core/ns_drop.cpp | 3 +- modules/core/ns_forbid.cpp | 3 +- modules/core/ns_getemail.cpp | 3 +- modules/core/ns_getpass.cpp | 3 +- modules/core/ns_ghost.cpp | 3 +- modules/core/ns_group.cpp | 3 +- modules/core/ns_help.cpp | 3 +- modules/core/ns_identify.cpp | 3 +- modules/core/ns_info.cpp | 3 +- modules/core/ns_list.cpp | 3 +- modules/core/ns_logout.cpp | 3 +- modules/core/ns_main.cpp | 5 +- modules/core/ns_recover.cpp | 3 +- modules/core/ns_register.cpp | 3 +- modules/core/ns_release.cpp | 3 +- modules/core/ns_resetpass.cpp | 3 +- modules/core/ns_saset.cpp | 11 +- modules/core/ns_saset_noexpire.cpp | 3 +- modules/core/ns_sendpass.cpp | 3 +- modules/core/ns_set.cpp | 11 +- modules/core/ns_set_autoop.cpp | 3 +- modules/core/ns_set_email.cpp | 3 +- modules/core/ns_set_greet.cpp | 3 +- modules/core/ns_set_hide.cpp | 3 +- modules/core/ns_set_kill.cpp | 3 +- modules/core/ns_set_language.cpp | 3 +- modules/core/ns_set_message.cpp | 3 +- modules/core/ns_set_private.cpp | 3 +- modules/core/ns_set_secure.cpp | 3 +- modules/core/ns_status.cpp | 3 +- modules/core/ns_suspend.cpp | 3 +- modules/core/ns_update.cpp | 3 +- modules/core/os_akill.cpp | 3 +- modules/core/os_chankill.cpp | 3 +- modules/core/os_chanlist.cpp | 3 +- modules/core/os_config.cpp | 3 +- modules/core/os_help.cpp | 3 +- modules/core/os_ignore.cpp | 3 +- modules/core/os_jupe.cpp | 3 +- modules/core/os_kick.cpp | 3 +- modules/core/os_login.cpp | 3 +- modules/core/os_main.cpp | 5 +- modules/core/os_mode.cpp | 3 +- modules/core/os_modinfo.cpp | 5 +- modules/core/os_modlist.cpp | 30 +- modules/core/os_modload.cpp | 14 +- modules/core/os_modreload.cpp | 15 +- modules/core/os_modunload.cpp | 13 +- modules/core/os_news.cpp | 3 +- modules/core/os_noop.cpp | 3 +- modules/core/os_oline.cpp | 5 +- modules/core/os_quit.cpp | 3 +- modules/core/os_reload.cpp | 3 +- modules/core/os_restart.cpp | 3 +- modules/core/os_session.cpp | 3 +- modules/core/os_set.cpp | 3 +- modules/core/os_shutdown.cpp | 3 +- modules/core/os_snline.cpp | 5 +- modules/core/os_sqline.cpp | 5 +- modules/core/os_staff.cpp | 3 +- modules/core/os_stats.cpp | 3 +- modules/core/os_svsnick.cpp | 5 +- modules/core/os_szline.cpp | 5 +- modules/core/os_update.cpp | 3 +- modules/core/os_userlist.cpp | 3 +- modules/extra/cs_appendtopic.cpp | 3 +- modules/extra/cs_enforce.cpp | 3 +- modules/extra/cs_entrymsg.cpp | 3 +- modules/extra/cs_set_misc.cpp | 3 +- modules/extra/cs_tban.cpp | 3 +- modules/extra/db_mysql.cpp | 1653 ------------------------------- modules/extra/db_mysql_live.cpp | 289 ------ modules/extra/hs_request.cpp | 3 +- modules/extra/m_alias.cpp | 2 +- modules/extra/m_async_commands.cpp | 6 +- modules/extra/m_dnsbl.cpp | 3 +- modules/extra/m_helpchan.cpp | 3 +- modules/extra/m_ldap.cpp | 2 +- modules/extra/m_ldap_authentication.cpp | 3 +- modules/extra/m_ldap_oper.cpp | 3 +- modules/extra/m_mysql.cpp | 2 +- modules/extra/m_ssl.cpp | 3 +- modules/extra/m_xmlrpc.cpp | 2 +- modules/extra/m_xmlrpc_main.cpp | 2 +- modules/extra/ns_maxemail.cpp | 3 +- modules/extra/ns_set_misc.cpp | 6 +- modules/extra/os_defcon.cpp | 3 +- modules/protocol/bahamut.cpp | 3 +- modules/protocol/inspircd-ts6.h | 3 +- modules/protocol/inspircd11.cpp | 6 +- modules/protocol/inspircd12.cpp | 6 +- modules/protocol/inspircd20.cpp | 9 +- modules/protocol/plexus.cpp | 6 +- modules/protocol/ratbox.cpp | 6 +- modules/protocol/unreal.cpp | 1142 +++++++++++++++++++++ modules/protocol/unreal32.cpp | 1143 --------------------- src/base.cpp | 9 +- src/bots.cpp | 2 +- src/config.cpp | 8 - src/encrypt.cpp | 31 +- src/init.cpp | 27 +- src/messages.cpp | 4 +- src/module.cpp | 23 +- src/modulemanager.cpp | 64 +- src/modules.cpp | 75 +- src/protocol.cpp | 3 +- src/servers.cpp | 141 +-- 206 files changed, 3562 insertions(+), 3962 deletions(-) create mode 100644 modules/core/db_mysql.cpp create mode 100644 modules/core/db_mysql_live.cpp delete mode 100644 modules/extra/db_mysql.cpp delete mode 100644 modules/extra/db_mysql_live.cpp create mode 100644 modules/protocol/unreal.cpp delete mode 100644 modules/protocol/unreal32.cpp diff --git a/data/example.conf b/data/example.conf index 24120d128..c9ffc04df 100644 --- a/data/example.conf +++ b/data/example.conf @@ -88,7 +88,7 @@ uplink * * NOTE: On some shell providers, this will not be an option. */ - host = "localhost" + host = "127.0.0.1" /* * Enable if Services should connect using IPv6. @@ -149,21 +149,6 @@ serverinfo */ #localhost = "nowhere." - /* - * This directive instructs Anope which IRCd Protocol to speak when connecting. - * You MUST modify this to match the IRCd you run. - * - * Supported: - * - inspircd11 - * - inspircd12 - * - inspircd20 - * - ratbox - * - bahamut - * - unreal32 - * - plexus - */ - type = "inspircd12" - /* * What Server ID to use for this connection? * Note: This should *ONLY* be used for TS6/P10 IRCds. Refer to your IRCd documentation @@ -190,6 +175,22 @@ serverinfo motd = "services.motd" } +/* + * [REQUIRED] Protocol module + * This directive tells Anope which IRCd Protocol to speak when connecting. + * You MUST modify this to match the IRCd you run. + * + * Supported: + * - bahamut + * - inspircd11 + * - inspircd12 + * - inspircd20 + * - plexus + * - ratbox + * - unreal + */ +module { name = "inspircd12" } + /* * [REQUIRED] Network Information * @@ -233,68 +234,6 @@ networkinfo */ options { - /* - * The encryption modules are used when dealing with passwords. This determines how - * the passwords are stored in the databases, and does not add any security as - * far as transmitting passwords over the network goes. - * - * When using enc_none, passwords will be stored without encryption in plain - * text, allowing for passwords to be recovered later but isn't secure therefore - * is not recommended. - * - * The other encryption modules use one-way encryption, so the passwords can not - * be recovered later if those are used. - * - * NOTE: enc_old is Anope's previous (broken) MD5 implementation, if your databases - * were made using that module, continue to use it and do not use enc_md5. - * - * NOTE: enc_sha1 relies on how the OS stores 2+ byte data internally, and is - * potentially broken when moving between 2 different OSes, such as moving from - * Linux to Windows. It is recommended that you use enc_sha256 instead if you want - * to use an SHA-based encryption. If you choose to do so, it is also recommended - * that you first try to get everyone's passwords converted to enc_sha256 before - * switching OSes by placing enc_sha256 at the beginning of the list. - * - * Supported: - * - enc_none (plain text, no encryption) - * - enc_old (old, broken MD5 encryption) - * - enc_md5 (working MD5 encryption) - * - enc_sha1 (SHA1 encryption) - * - enc_sha256 (SHA256 encryption with random salts) - * - * The first module in this list is the active encryption module. All new passwords are - * encrypted by this module. Old passwords stored in another encryption method are - * automatically re-encrypted by the active encryption module on next identify. - * Changing the order of the modules requires the services to restart. - */ - encryption = "enc_md5 enc_none enc_sha1 enc_sha256 enc_old" - - /* - * The database modules are used for saving and loading databases for Anope. - * - * Supported: - * - db_plain - * - db_mysql - * - db_mysql_live - * - * You may have more than one loaded at once! - * - * The db_mysql_live module is an extension to db_mysql, and should only be used if - * db_mysql is being used. This module pulls data in real time from SQL as it is - * requested by the core as a result of someone executing commands. - * - * This effectively allows you to edit your database and have it be immediately - * reflected back in Anope. - * - * For information on how to make db_mysql_live use asynchronous queries see - * m_async_commands. - * - * At this time db_mysql_live only supports pulling data in real time from the three - * main tables: anope_cs_info, anope_ns_alias, and anope_ns_core. - * - */ - database = "db_plain" - /* * The maximum length of passwords */ @@ -1888,8 +1827,10 @@ cs_set_misc /* * db_plain * - * This is the default flatfile database format + * This is the default flatfile database format. You must have at least one database + * module loaded or Anope will not save databases! */ +module { name = "db_plain" } db_plain { /* @@ -1898,6 +1839,63 @@ db_plain database = "anope.db" } +/* + * db_mysql and db_mysql_live + * + * Enables (live) MySQL support. + * + * The db_mysql_live module is an extension to db_mysql, and should only be used if + * db_mysql is being used. This module pulls data in real time from SQL as it is + * requested by the core as a result of someone executing commands. + * + * This effectively allows you to edit your database and have it be immediately + * reflected back in Anope. + * + * For information on how to make db_mysql_live use asynchronous queries see + * m_async_commands. + * + * At this time db_mysql_live only supports pulling data in real time from the three + * main tables: anope_cs_info, anope_ns_alias, and anope_ns_core. + */ +#module { name = "db_mysql" } +#module { name = "db_mysql_live" } + +/* + * The encryption modules are used when dealing with passwords. This determines how + * the passwords are stored in the databases, and does not add any security as + * far as transmitting passwords over the network goes. + * + * Without any encryption modules, passwords will be stored in plain text, allowing + * for passwords to be recovered later but isn't secure therefore is not recommended. + * + * The other encryption modules use one-way encryption, so the passwords can not + * be recovered later if those are used. + * + * NOTE: enc_old is Anope's previous (broken) MD5 implementation, if your databases + * were made using that module, continue to use it and do not use enc_md5. + * + * NOTE: enc_sha1 relies on how the OS stores 2+ byte data internally, and is + * potentially broken when moving between 2 different OSes, such as moving from + * Linux to Windows. It is recommended that you use enc_sha256 instead if you want + * to use an SHA-based encryption. If you choose to do so, it is also recommended + * that you first try to get everyone's passwords converted to enc_sha256 before + * switching OSes by placing enc_sha256 at the beginning of the list. + * + * The first encryption module loaded is the primary encryption module. All new passwords are + * encrypted by this module. Old passwords stored in another encryption method are + * automatically re-encrypted by the active encryption module on next identify. + */ +module { name = "enc_md5" } +#module { name = "enc_sha1" } +#module { name = "enc_sha256" } + +/* + * enc_old is Anope's previous (broken) MD5 implementation, if your databases + * were made using that module, load it here to allow conversion to the primary + * encryption method. + */ +#module { name = "enc_old" } + /* * hs_request * diff --git a/docs/Changes.conf b/docs/Changes.conf index bf4da4ea4..650603e24 100644 --- a/docs/Changes.conf +++ b/docs/Changes.conf @@ -18,6 +18,9 @@ options:globaloncycledown options:globaloncycleup options:anonymousglobal options:socketengine +options:encryption +options:database +serverinfo:protocol Anope Version 1.9.4 ------------------- diff --git a/include/anope.h b/include/anope.h index fb201db1e..b23b68481 100644 --- a/include/anope.h +++ b/include/anope.h @@ -316,9 +316,9 @@ namespace Anope */ extern CoreExport bool Match(const Anope::string &str, const Anope::string &mask, bool case_sensitive = false); - /** Returns a list of pointers to message handlers - * @param The message name as sent by the IRCd - * @return a vector with pointers to the messagehandlers (you can bind more than one handler to a message) + /** Find a message in the message table + * @param name The name of the message were looking for + * @return NULL if we cant find it, or a pointer to the Message if we can */ extern CoreExport std::vector FindMessage(const string &name); @@ -438,6 +438,7 @@ class CoreExport Base virtual ~Base(); void AddReference(dynamic_reference_base *r); void DelReference(dynamic_reference_base *r); + static void operator delete(void *ptr); }; class dynamic_reference_base : public Base @@ -469,7 +470,7 @@ class dynamic_reference : public dynamic_reference_base this->invalid = false; this->ref = NULL; } - else if (ref) + else if (this->operator bool()) ref->DelReference(this); } @@ -504,10 +505,10 @@ class dynamic_reference : public dynamic_reference_base this->invalid = false; this->ref = NULL; } - else if (this->ref) + else if (this->operator bool()) this->ref->DelReference(this); this->ref = newref; - if (this->ref) + if (this->operator bool()) this->ref->AddReference(this); } }; diff --git a/include/config.h b/include/config.h index 8d2455c78..8a564e8ec 100644 --- a/include/config.h +++ b/include/config.h @@ -342,9 +342,6 @@ class CoreExport ServerConfig /** Below here is a list of variables which contain the config files values */ - /* IRCd module in use */ - Anope::string IRCDModule; - /* Host to connect to **/ Anope::string LocalHost; /* List of uplink servers to try and connect to */ @@ -667,13 +664,6 @@ class CoreExport ServerConfig /* List of modules to autoload */ std::list ModulesAutoLoad; - /* Encryption modules */ - std::list EncModuleList; - /* Database modules */ - std::list DBModuleList; - - /* The socket engine in use */ - Anope::string SocketEngine; /* User keys to use for generating random hashes for pass codes etc */ unsigned long UserKey1; diff --git a/include/extern.h b/include/extern.h index 555292712..0b319ceaf 100644 --- a/include/extern.h +++ b/include/extern.h @@ -74,8 +74,8 @@ E ConfigurationFile services_conf; E ServerConfig *Config; /**** encrypt.c ****/ -E int enc_encrypt(const Anope::string &src, Anope::string &dest); -E int enc_decrypt(const Anope::string &src, Anope::string &dest); +E void enc_encrypt(const Anope::string &src, Anope::string &dest); +E bool enc_decrypt(const Anope::string &src, Anope::string &dest); /**** hostserv.c ****/ diff --git a/include/modules.h b/include/modules.h index c3f533609..d24348b48 100644 --- a/include/modules.h +++ b/include/modules.h @@ -127,9 +127,6 @@ else \ class Message; -extern CoreExport Module *FindModule(const Anope::string &name); -int protocol_module_init(); - enum ModuleReturn { MOD_ERR_OK, @@ -137,15 +134,9 @@ enum ModuleReturn MOD_ERR_PARAMS, MOD_ERR_EXISTS, MOD_ERR_NOEXIST, - MOD_ERR_NOUSER, MOD_ERR_NOLOAD, - MOD_ERR_NOUNLOAD, - MOD_ERR_SYNTAX, - MOD_ERR_NODELETE, MOD_ERR_UNKNOWN, MOD_ERR_FILE_IO, - MOD_ERR_NOSERVICE, - MOD_ERR_NO_MOD_NAME, MOD_ERR_EXCEPTION, MOD_ERR_VERSION }; @@ -154,7 +145,7 @@ enum ModuleReturn */ enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER }; /* Module types, in the order in which they are unloaded. The order these are in is IMPORTANT */ -enum MODType { MT_BEGIN, THIRD, QATESTED, SUPPORTED, CORE, DATABASE, ENCRYPTION, PROTOCOL, MT_END }; +enum ModType { MT_BEGIN, THIRD, SUPPORTED, CORE, DATABASE, ENCRYPTION, PROTOCOL, MT_END }; typedef std::multimap message_map; extern CoreExport message_map MessageMap; @@ -210,6 +201,10 @@ class CoreExport Module : public Extensible */ Anope::string name; + /** What type this module is + */ + ModType type; + /** The temporary path/filename */ Anope::string filename; @@ -234,24 +229,17 @@ class CoreExport Module : public Extensible */ Anope::string author; - /** What type this module is - */ - MODType type; - /** Creates and initialises a new module. + * @param modname The module name * @param loadernick The nickname of the user loading the module. + * @param type The module type */ - Module(const Anope::string &modname, const Anope::string &loadernick); + Module(const Anope::string &modname, const Anope::string &loadernick, ModType type = THIRD); /** Destroys a module, freeing resources it has allocated. */ virtual ~Module(); - /** Sets a given type (CORE,PROTOCOL,3RD etc) on a module. - * @param type The type to set the module as. - */ - void SetType(MODType type); - /** Toggles the permanent flag on a module. If a module is permanent, * then it may not be unloaded. * @@ -1039,10 +1027,10 @@ class CoreExport Module : public Extensible */ virtual void OnPrivmsg(User *u, ChannelInfo *ci, Anope::string &msg) { } - /** Called when any object is destroyed + /** Called when any object is deleted * @param b The object */ - virtual void OnObjectDestroy(Base *b) { } + virtual void OnDeleteObject(Base *b) { } }; /** Implementation-specific flags which may be set in ModuleManager::Attach() @@ -1096,7 +1084,7 @@ enum Implementation I_OnServerQuit, I_OnTopicUpdated, I_OnEncrypt, I_OnDecrypt, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd, - I_OnMLock, I_OnUnMLock, I_OnServerSync, I_OnUplinkSync, I_OnBotPrivmsg, I_OnPrivmsg, I_OnObjectDestroy, + I_OnMLock, I_OnUnMLock, I_OnServerSync, I_OnUplinkSync, I_OnBotPrivmsg, I_OnPrivmsg, I_OnDeleteObject, I_END }; @@ -1139,6 +1127,18 @@ class CoreExport ModuleManager */ static ModuleReturn UnloadModule(Module *m, User * u); + /** Find a module + * @param name The module name + * @return The module + */ + static Module *FindModule(const Anope::string &name); + + /** Find the first module of a certain type + * @param type The module type + * @return The module + */ + static Module *FindFirstOf(ModType type); + /** Checks whether this version of Anope is at least major.minor.patch.build * Throws a ModuleException if not * @param major The major version @@ -1231,8 +1231,9 @@ class CoreExport ModuleManager private: /** Call the module_delete function to safely delete the module * @param m the module to delete + * @return MOD_ERR_OK on success, anything else on fail */ - static void DeleteModule(Module *m); + static ModuleReturn DeleteModule(Module *m); }; /** Class used for callbacks within modules diff --git a/include/servers.h b/include/servers.h index 9e3907668..f2a8ce1b5 100644 --- a/include/servers.h +++ b/include/servers.h @@ -6,8 +6,8 @@ extern CoreExport Server *Me; extern CoreExport void do_server(const Anope::string &source, const Anope::string &servername, unsigned int hops, const Anope::string &descript, const Anope::string &numeric); -extern CoreExport const char *ts6_uid_retrieve(); -extern CoreExport const char *ts6_sid_retrieve(); +extern CoreExport const Anope::string ts6_uid_retrieve(); +extern CoreExport const Anope::string ts6_sid_retrieve(); /* Types of capab */ diff --git a/modules/core/bs_act.cpp b/modules/core/bs_act.cpp index 2547ce3c1..d06fc1848 100644 --- a/modules/core/bs_act.cpp +++ b/modules/core/bs_act.cpp @@ -79,10 +79,9 @@ class BSAct : public Module CommandBSAct commandbsact; public: - BSAct(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + BSAct(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!botserv) throw ModuleException("BotServ is not loaded!"); diff --git a/modules/core/bs_assign.cpp b/modules/core/bs_assign.cpp index 5be9e6bf3..f1e2e4f69 100644 --- a/modules/core/bs_assign.cpp +++ b/modules/core/bs_assign.cpp @@ -89,10 +89,9 @@ class BSAssign : public Module CommandBSAssign commandbsassign; public: - BSAssign(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + BSAssign(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!botserv) throw ModuleException("BotServ is not loaded!"); diff --git a/modules/core/bs_badwords.cpp b/modules/core/bs_badwords.cpp index 1b3b2a884..1ea8161f1 100644 --- a/modules/core/bs_badwords.cpp +++ b/modules/core/bs_badwords.cpp @@ -321,10 +321,9 @@ class BSBadwords : public Module CommandBSBadwords commandbsbadwords; public: - BSBadwords(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + BSBadwords(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!botserv) throw ModuleException("BotServ is not loaded!"); diff --git a/modules/core/bs_bot.cpp b/modules/core/bs_bot.cpp index c7a898dc1..4d42380f3 100644 --- a/modules/core/bs_bot.cpp +++ b/modules/core/bs_bot.cpp @@ -415,10 +415,9 @@ class BSBot : public Module CommandBSBot commandbsbot; public: - BSBot(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + BSBot(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!botserv) throw ModuleException("BotServ is not loaded!"); diff --git a/modules/core/bs_botlist.cpp b/modules/core/bs_botlist.cpp index a6a56f088..aa4731189 100644 --- a/modules/core/bs_botlist.cpp +++ b/modules/core/bs_botlist.cpp @@ -79,10 +79,9 @@ class BSBotList : public Module CommandBSBotList commandbsbotlist; public: - BSBotList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + BSBotList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!botserv) throw ModuleException("BotServ is not loaded!"); diff --git a/modules/core/bs_help.cpp b/modules/core/bs_help.cpp index eafa5b44e..953c5f37e 100644 --- a/modules/core/bs_help.cpp +++ b/modules/core/bs_help.cpp @@ -58,10 +58,9 @@ class BSHelp : public Module CommandBSHelp commandbshelp; public: - BSHelp(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + BSHelp(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!botserv) throw ModuleException("BotServ is not loaded!"); diff --git a/modules/core/bs_info.cpp b/modules/core/bs_info.cpp index afb13c66d..9c996b247 100644 --- a/modules/core/bs_info.cpp +++ b/modules/core/bs_info.cpp @@ -243,10 +243,9 @@ class BSInfo : public Module CommandBSInfo commandbsinfo; public: - BSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + BSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!botserv) throw ModuleException("BotServ is not loaded!"); diff --git a/modules/core/bs_kick.cpp b/modules/core/bs_kick.cpp index 9b78d6e7b..66232f10c 100644 --- a/modules/core/bs_kick.cpp +++ b/modules/core/bs_kick.cpp @@ -627,10 +627,9 @@ class BSKick : public Module } public: - BSKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + BSKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!botserv) throw ModuleException("BotServ is not loaded!"); diff --git a/modules/core/bs_main.cpp b/modules/core/bs_main.cpp index 5bd7e5ce2..193afac21 100644 --- a/modules/core/bs_main.cpp +++ b/modules/core/bs_main.cpp @@ -155,10 +155,9 @@ class BotServCore : public Module BanDataPurger bdpurger; public: - BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), mybotserv(this), bdpurger(this) + BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), mybotserv(this), bdpurger(this) { this->SetAuthor("Anope"); - this->SetType(CORE); ModuleManager::RegisterService(&this->mybotserv); @@ -180,7 +179,7 @@ class BotServCore : public Module Anope::string module; while (coreModules.GetToken(module)) { - Module *m = FindModule(module); + Module *m = ModuleManager::FindModule(module); if (m != NULL) ModuleManager::UnloadModule(m, NULL); } diff --git a/modules/core/bs_say.cpp b/modules/core/bs_say.cpp index 673244a6c..56176a947 100644 --- a/modules/core/bs_say.cpp +++ b/modules/core/bs_say.cpp @@ -81,10 +81,9 @@ class BSSay : public Module CommandBSSay commandbssay; public: - BSSay(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + BSSay(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!botserv) throw ModuleException("BotServ is not loaded!"); diff --git a/modules/core/bs_set.cpp b/modules/core/bs_set.cpp index daf37c199..1daf30fa4 100644 --- a/modules/core/bs_set.cpp +++ b/modules/core/bs_set.cpp @@ -304,10 +304,9 @@ class BSSet : public Module CommandBSSet commandbsset; public: - BSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + BSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!botserv) throw ModuleException("BotServ is not loaded!"); diff --git a/modules/core/bs_unassign.cpp b/modules/core/bs_unassign.cpp index 104eded56..6fe62d838 100644 --- a/modules/core/bs_unassign.cpp +++ b/modules/core/bs_unassign.cpp @@ -71,10 +71,9 @@ class BSUnassign : public Module CommandBSUnassign commandbsunassign; public: - BSUnassign(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + BSUnassign(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!botserv) throw ModuleException("BotServ is not loaded!"); diff --git a/modules/core/cs_access.cpp b/modules/core/cs_access.cpp index 5fc4e7290..243d62057 100644 --- a/modules/core/cs_access.cpp +++ b/modules/core/cs_access.cpp @@ -763,10 +763,9 @@ class CSAccess : public Module CommandCSLevels commandcslevels; public: - CSAccess(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSAccess(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_akick.cpp b/modules/core/cs_akick.cpp index 3aafbc537..8650aebd4 100644 --- a/modules/core/cs_akick.cpp +++ b/modules/core/cs_akick.cpp @@ -575,10 +575,9 @@ class CSAKick : public Module CommandCSAKick commandcsakick; public: - CSAKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSAKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_ban.cpp b/modules/core/cs_ban.cpp index 3bccd9897..53c91314d 100644 --- a/modules/core/cs_ban.cpp +++ b/modules/core/cs_ban.cpp @@ -98,10 +98,9 @@ class CSBan : public Module CommandCSBan commandcsban; public: - CSBan(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), commandcsban("BAN") + CSBan(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), commandcsban("BAN") { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_clearusers.cpp b/modules/core/cs_clearusers.cpp index 7cf5055b7..b3e9d5d91 100644 --- a/modules/core/cs_clearusers.cpp +++ b/modules/core/cs_clearusers.cpp @@ -73,10 +73,9 @@ class CSClearUsers : public Module CommandCSClearUsers commandcsclearusers; public: - CSClearUsers(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSClearUsers(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_clone.cpp b/modules/core/cs_clone.cpp index 52161abf1..77bfc5387 100644 --- a/modules/core/cs_clone.cpp +++ b/modules/core/cs_clone.cpp @@ -173,10 +173,9 @@ class CSClone : public Module CommandCSClone commandcsclone; public: - CSClone(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSClone(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_drop.cpp b/modules/core/cs_drop.cpp index 66f1b31f6..3a1026f21 100644 --- a/modules/core/cs_drop.cpp +++ b/modules/core/cs_drop.cpp @@ -106,10 +106,9 @@ class CSDrop : public Module CommandCSDrop commandcsdrop; public: - CSDrop(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSDrop(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_forbid.cpp b/modules/core/cs_forbid.cpp index 9c0573971..e7f2b7894 100644 --- a/modules/core/cs_forbid.cpp +++ b/modules/core/cs_forbid.cpp @@ -117,10 +117,9 @@ class CSForbid : public Module CommandCSForbid commandcsforbid; public: - CSForbid(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSForbid(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_getkey.cpp b/modules/core/cs_getkey.cpp index b46a7df53..63a13cce4 100644 --- a/modules/core/cs_getkey.cpp +++ b/modules/core/cs_getkey.cpp @@ -68,10 +68,9 @@ class CSGetKey : public Module CommandCSGetKey commandcsgetkey; public: - CSGetKey(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSGetKey(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_help.cpp b/modules/core/cs_help.cpp index aff4c5165..b2ff5e496 100644 --- a/modules/core/cs_help.cpp +++ b/modules/core/cs_help.cpp @@ -62,10 +62,9 @@ class CSHelp : public Module CommandCSHelp commandcshelp; public: - CSHelp(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSHelp(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_info.cpp b/modules/core/cs_info.cpp index a899c2911..71a8b132f 100644 --- a/modules/core/cs_info.cpp +++ b/modules/core/cs_info.cpp @@ -136,10 +136,9 @@ class CSInfo : public Module CommandCSInfo commandcsinfo; public: - CSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_invite.cpp b/modules/core/cs_invite.cpp index e7bcbbdab..ec0af478c 100644 --- a/modules/core/cs_invite.cpp +++ b/modules/core/cs_invite.cpp @@ -92,10 +92,9 @@ class CSInvite : public Module CommandCSInvite commandcsinvite; public: - CSInvite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSInvite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_kick.cpp b/modules/core/cs_kick.cpp index 2cf06e1e4..3f2988998 100644 --- a/modules/core/cs_kick.cpp +++ b/modules/core/cs_kick.cpp @@ -84,10 +84,9 @@ class CSKick : public Module CommandCSKick commandcskick; public: - CSKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_list.cpp b/modules/core/cs_list.cpp index 318eea59f..e434abf80 100644 --- a/modules/core/cs_list.cpp +++ b/modules/core/cs_list.cpp @@ -142,10 +142,9 @@ class CSList : public Module CommandCSList commandcslist; public: - CSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_main.cpp b/modules/core/cs_main.cpp index 772c626d2..802528ee8 100644 --- a/modules/core/cs_main.cpp +++ b/modules/core/cs_main.cpp @@ -151,10 +151,9 @@ class ChanServCore : public Module ExpireCallback expires; public: - ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), mychanserv(this), expires(this) + ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), mychanserv(this), expires(this) { this->SetAuthor("Anope"); - this->SetType(CORE); ModuleManager::RegisterService(&this->mychanserv); @@ -176,7 +175,7 @@ class ChanServCore : public Module Anope::string module; while (coreModules.GetToken(module)) { - Module *m = FindModule(module); + Module *m = ModuleManager::FindModule(module); if (m != NULL) ModuleManager::UnloadModule(m, NULL); } diff --git a/modules/core/cs_mode.cpp b/modules/core/cs_mode.cpp index fc4538033..a7938d5dd 100644 --- a/modules/core/cs_mode.cpp +++ b/modules/core/cs_mode.cpp @@ -362,10 +362,9 @@ class CSMode : public Module CommandCSMode commandcsmode; public: - CSMode(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSMode(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_modes.cpp b/modules/core/cs_modes.cpp index eeaf9f733..dbbe0e491 100644 --- a/modules/core/cs_modes.cpp +++ b/modules/core/cs_modes.cpp @@ -457,10 +457,9 @@ class CSModes : public Module CommandCSDeVoice commandcsdevoice; public: - CSModes(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSModes(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_register.cpp b/modules/core/cs_register.cpp index 0682f045a..9674ff126 100644 --- a/modules/core/cs_register.cpp +++ b/modules/core/cs_register.cpp @@ -133,10 +133,9 @@ class CSRegister : public Module CommandCSRegister commandcsregister; public: - CSRegister(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSRegister(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_saset.cpp b/modules/core/cs_saset.cpp index b262ce14a..21c1bf4d4 100644 --- a/modules/core/cs_saset.cpp +++ b/modules/core/cs_saset.cpp @@ -127,10 +127,9 @@ class CSSASet : public Module CommandCSSASet commandcssaset; public: - CSSASet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSASet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_saset_noexpire.cpp b/modules/core/cs_saset_noexpire.cpp index 1026d8976..5f3be9624 100644 --- a/modules/core/cs_saset_noexpire.cpp +++ b/modules/core/cs_saset_noexpire.cpp @@ -64,10 +64,9 @@ class CSSetNoexpire : public Module CommandCSSASetNoexpire commandcssasetnoexpire; public: - CSSetNoexpire(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetNoexpire(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set.cpp b/modules/core/cs_set.cpp index d395fad32..e38d7f79f 100644 --- a/modules/core/cs_set.cpp +++ b/modules/core/cs_set.cpp @@ -131,10 +131,9 @@ class CSSet : public Module CommandCSSet commandcsset; public: - CSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_bantype.cpp b/modules/core/cs_set_bantype.cpp index 35b8c6c14..1ae61a5ed 100644 --- a/modules/core/cs_set_bantype.cpp +++ b/modules/core/cs_set_bantype.cpp @@ -84,10 +84,9 @@ class CSSetBanType : public Module CommandCSSASetBanType commandcssasetbantype; public: - CSSetBanType(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetBanType(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_description.cpp b/modules/core/cs_set_description.cpp index a65f4511b..493445a91 100644 --- a/modules/core/cs_set_description.cpp +++ b/modules/core/cs_set_description.cpp @@ -71,10 +71,9 @@ class CSSetDescription : public Module CommandCSSASetDescription commandcssasetdescription; public: - CSSetDescription(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetDescription(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_founder.cpp b/modules/core/cs_set_founder.cpp index 27d6f86fc..e6430eb99 100644 --- a/modules/core/cs_set_founder.cpp +++ b/modules/core/cs_set_founder.cpp @@ -107,10 +107,9 @@ class CSSetFounder : public Module CommandCSSASetFounder commandcssasetfounder; public: - CSSetFounder(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetFounder(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_keeptopic.cpp b/modules/core/cs_set_keeptopic.cpp index 89491d418..bb121aab4 100644 --- a/modules/core/cs_set_keeptopic.cpp +++ b/modules/core/cs_set_keeptopic.cpp @@ -81,10 +81,9 @@ class CSSetKeepTopic : public Module CommandCSSASetKeepTopic commandcssasetkeeptopic; public: - CSSetKeepTopic(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetKeepTopic(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_opnotice.cpp b/modules/core/cs_set_opnotice.cpp index 0d71b42c4..abaecdde1 100644 --- a/modules/core/cs_set_opnotice.cpp +++ b/modules/core/cs_set_opnotice.cpp @@ -80,10 +80,9 @@ class CSSetOpNotice : public Module CommandCSSASetOpNotice commandcssasetopnotice; public: - CSSetOpNotice(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetOpNotice(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_peace.cpp b/modules/core/cs_set_peace.cpp index 51c7bc827..cae57d588 100644 --- a/modules/core/cs_set_peace.cpp +++ b/modules/core/cs_set_peace.cpp @@ -80,10 +80,9 @@ class CSSetPeace : public Module CommandCSSASetPeace commandcssasetpeace; public: - CSSetPeace(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetPeace(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_persist.cpp b/modules/core/cs_set_persist.cpp index 683bd4481..692b0dc1c 100644 --- a/modules/core/cs_set_persist.cpp +++ b/modules/core/cs_set_persist.cpp @@ -152,10 +152,9 @@ class CSSetPersist : public Module CommandCSSASetPersist commandcssasetpeace; public: - CSSetPersist(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetPersist(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_private.cpp b/modules/core/cs_set_private.cpp index 42f7a2261..db7bf3b26 100644 --- a/modules/core/cs_set_private.cpp +++ b/modules/core/cs_set_private.cpp @@ -79,10 +79,9 @@ class CSSetPrivate : public Module CommandCSSASetPrivate commandcssasetprivate; public: - CSSetPrivate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetPrivate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_restricted.cpp b/modules/core/cs_set_restricted.cpp index 93fe0d023..f9ea3b514 100644 --- a/modules/core/cs_set_restricted.cpp +++ b/modules/core/cs_set_restricted.cpp @@ -82,10 +82,9 @@ class CSSetRestricted : public Module CommandCSSASetRestricted commandcssasetrestricted; public: - CSSetRestricted(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetRestricted(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_secure.cpp b/modules/core/cs_set_secure.cpp index 5fb8d9a7c..39d50fad2 100644 --- a/modules/core/cs_set_secure.cpp +++ b/modules/core/cs_set_secure.cpp @@ -81,10 +81,9 @@ class CSSetSecure : public Module CommandCSSASetSecure commandcssasetsecure; public: - CSSetSecure(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetSecure(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_securefounder.cpp b/modules/core/cs_set_securefounder.cpp index 3daa67924..a77df7f69 100644 --- a/modules/core/cs_set_securefounder.cpp +++ b/modules/core/cs_set_securefounder.cpp @@ -88,10 +88,9 @@ class CSSetSecureFounder : public Module CommandCSSASetSecureFounder commandcssasetsecurefounder; public: - CSSetSecureFounder(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetSecureFounder(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_secureops.cpp b/modules/core/cs_set_secureops.cpp index 773ae8ffd..7f45fdce0 100644 --- a/modules/core/cs_set_secureops.cpp +++ b/modules/core/cs_set_secureops.cpp @@ -79,10 +79,9 @@ class CSSetSecureOps : public Module CommandCSSASetSecureOps commandcssasetsecureops; public: - CSSetSecureOps(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetSecureOps(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_signkick.cpp b/modules/core/cs_set_signkick.cpp index 50c0d74f9..6ac081f63 100644 --- a/modules/core/cs_set_signkick.cpp +++ b/modules/core/cs_set_signkick.cpp @@ -94,10 +94,9 @@ class CSSetSignKick : public Module CommandCSSASetSignKick commandcssasetsignkick; public: - CSSetSignKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetSignKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_successor.cpp b/modules/core/cs_set_successor.cpp index 7c3b156e3..a9a1e7498 100644 --- a/modules/core/cs_set_successor.cpp +++ b/modules/core/cs_set_successor.cpp @@ -114,10 +114,9 @@ class CSSetSuccessor : public Module CommandCSSASetSuccessor commandcssasetsuccessor; public: - CSSetSuccessor(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetSuccessor(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_topiclock.cpp b/modules/core/cs_set_topiclock.cpp index add079c52..8792f9d37 100644 --- a/modules/core/cs_set_topiclock.cpp +++ b/modules/core/cs_set_topiclock.cpp @@ -80,10 +80,9 @@ class CSSetTopicLock : public Module CommandCSSASetTopicLock commandcssasettopiclock; public: - CSSetTopicLock(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetTopicLock(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_set_xop.cpp b/modules/core/cs_set_xop.cpp index 2f423e098..39cfa6bac 100644 --- a/modules/core/cs_set_xop.cpp +++ b/modules/core/cs_set_xop.cpp @@ -28,7 +28,7 @@ class CommandCSSetXOP : public Command User *u = source.u; ChannelInfo *ci = source.ci; - if (!FindModule("cs_xop")) + if (!ModuleManager::FindModule("cs_xop")) { source.Reply(_("xOP system is not available."), "XOP"); return MOD_CONT; @@ -134,10 +134,9 @@ class CSSetXOP : public Module CommandCSSASetXOP commandcssasetxop; public: - CSSetXOP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSetXOP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); if (!chanserv) throw ModuleException("ChanServ is not loaded!"); diff --git a/modules/core/cs_status.cpp b/modules/core/cs_status.cpp index 0ff2db90a..f9107fc8e 100644 --- a/modules/core/cs_status.cpp +++ b/modules/core/cs_status.cpp @@ -62,10 +62,9 @@ class CSStatus : public Module CommandCSStatus commandcsstatus; public: - CSStatus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSStatus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); this->AddCommand(chanserv->Bot(), &commandcsstatus); } diff --git a/modules/core/cs_suspend.cpp b/modules/core/cs_suspend.cpp index 37fae7723..374e44bc2 100644 --- a/modules/core/cs_suspend.cpp +++ b/modules/core/cs_suspend.cpp @@ -149,10 +149,9 @@ class CSSuspend : public Module CommandCSUnSuspend commandcsunsuspend; public: - CSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); this->AddCommand(chanserv->Bot(), &commandcssuspend); this->AddCommand(chanserv->Bot(), &commandcsunsuspend); diff --git a/modules/core/cs_topic.cpp b/modules/core/cs_topic.cpp index 52fecd7a4..a6c6fad74 100644 --- a/modules/core/cs_topic.cpp +++ b/modules/core/cs_topic.cpp @@ -74,10 +74,9 @@ class CSTopic : public Module CommandCSTopic commandcstopic; public: - CSTopic(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSTopic(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); this->AddCommand(chanserv->Bot(), &commandcstopic); } diff --git a/modules/core/cs_unban.cpp b/modules/core/cs_unban.cpp index be567db9a..8cdb0f2fd 100644 --- a/modules/core/cs_unban.cpp +++ b/modules/core/cs_unban.cpp @@ -82,10 +82,9 @@ class CSUnban : public Module CommandCSUnban commandcsunban; public: - CSUnban(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSUnban(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); this->AddCommand(chanserv->Bot(), &commandcsunban); } diff --git a/modules/core/cs_xop.cpp b/modules/core/cs_xop.cpp index 3b65e035f..72471a868 100644 --- a/modules/core/cs_xop.cpp +++ b/modules/core/cs_xop.cpp @@ -723,10 +723,9 @@ class CSXOP : public Module CommandCSVOP commandcsvop; public: - CSXOP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + CSXOP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) { this->SetAuthor("Anope"); - this->SetType(CORE); this->AddCommand(chanserv->Bot(), &commandcssop); this->AddCommand(chanserv->Bot(), &commandcsaop); diff --git a/modules/core/db_mysql.cpp b/modules/core/db_mysql.cpp new file mode 100644 index 000000000..386e20740 --- /dev/null +++ b/modules/core/db_mysql.cpp @@ -0,0 +1,1652 @@ +#include "module.h" +#include "operserv.h" +#include "../extra/sql.h" +#include "os_session.h" + +static Anope::string ToString(const std::vector &strings) +{ + Anope::string ret; + + for (unsigned i = 0; i < strings.size(); ++i) + ret += " " + strings[i]; + + if (!ret.empty()) + ret.erase(ret.begin()); + + return ret; +} + +static std::vector MakeVector(const Anope::string &buf) +{ + Anope::string s; + spacesepstream sep(buf); + std::vector params; + + while (sep.GetToken(s)) + { + if (s[0] == ':') + { + s.erase(s.begin()); + if (!s.empty() && !sep.StreamEnd()) + params.push_back(s + " " + sep.GetRemaining()); + else if (!s.empty()) + params.push_back(s); + } + else + params.push_back(s); + } + + return params; +} + +static NickAlias *CurNick = NULL; +static NickCore *CurCore = NULL; +static ChannelInfo *CurChannel = NULL; +static BotInfo *CurBot = NULL; + +static void Write(const Anope::string &data); +static void WriteNickMetadata(const Anope::string &key, const Anope::string &data); +static void WriteCoreMetadata(const Anope::string &key, const Anope::string &data); +static void WriteChannelMetadata(const Anope::string &key, const Anope::string &data); +static void WriteBotMetadata(const Anope::string &key, const Anope::string &data); + +class CommandSQLSync : public Command +{ + public: + CommandSQLSync() : Command("SQLSYNC", 0, 0, "operserv/sqlsync") + { + this->SetDesc(_("Import your databases to SQL")); + } + + CommandReturn Execute(CommandSource &source, const std::vector ¶ms); + + bool OnHelp(CommandSource &source, const Anope::string &subcommand) + { + source.Reply(_("Syntax: \002SQLSYNC\002\n" + " \n" + "This command syncs your databases with SQL. You should\n" + "only have to execute this command once, when you initially\n" + "import your databases into SQL.")); + return true; + } +}; + +class MySQLInterface : public SQLInterface +{ + public: + MySQLInterface(Module *o) : SQLInterface(o) { } + + void OnResult(const SQLResult &r); + + void OnError(const SQLResult &r); +}; + +class DBMySQL; +static DBMySQL *me; +class DBMySQL : public Module +{ + private: + CommandSQLSync commandsqlsync; + MySQLInterface sqlinterface; + service_reference SQL; + + public: + service_reference SessionInterface; + time_t lastwarn; + bool ro; + + void RunQuery(const SQLQuery &query) + { + if (SQL) + { + if (readonly && this->ro) + { + readonly = this->ro = false; + if (operserv) + ircdproto->SendGlobops(operserv->Bot(), "Found SQL again, going out of readonly mode..."); + } + + SQL->Run(&sqlinterface, query); + } + else + { + if (Anope::CurTime - Config->UpdateTimeout > lastwarn) + { + if (operserv) + ircdproto->SendGlobops(operserv->Bot(), "Unable to locate SQL reference, is m_mysql loaded? Going to readonly..."); + readonly = this->ro = true; + this->lastwarn = Anope::CurTime; + } + } + } + + DBMySQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE), sqlinterface(this), SQL("mysql/main"), SessionInterface("session") + { + me = this; + + + this->lastwarn = 0; + this->ro = false; + + Implementation i[] = { + I_OnLoadDatabase, I_OnServerConnect + }; + ModuleManager::Attach(i, this, 2); + + if (operserv) + this->AddCommand(operserv->Bot(), &commandsqlsync); + + if (uplink_server) + OnServerConnect(); + } + + void OnServerConnect() + { + Implementation i[] = { + /* Misc */ + I_OnSaveDatabase, I_OnPostCommand, + /* NickServ */ + I_OnNickAddAccess, I_OnNickEraseAccess, I_OnNickClearAccess, + I_OnDelCore, I_OnNickForbidden, I_OnNickGroup, + I_OnNickRegister, I_OnChangeCoreDisplay, + I_OnNickSuspended, I_OnDelNick, + /* ChanServ */ + I_OnAccessAdd, I_OnAccessDel, I_OnAccessChange, I_OnAccessClear, I_OnLevelChange, + I_OnChanForbidden, I_OnDelChan, I_OnChanRegistered, I_OnChanSuspend, + I_OnAkickAdd, I_OnAkickDel, I_OnMLock, I_OnUnMLock, + /* BotServ */ + I_OnBotCreate, I_OnBotChange, I_OnBotDelete, + I_OnBotAssign, I_OnBotUnAssign, + I_OnBadWordAdd, I_OnBadWordDel, + /* MemoServ */ + I_OnMemoSend, I_OnMemoDel, + /* OperServ */ + I_OnAddAkill, I_OnDelAkill, I_OnExceptionAdd, I_OnExceptionDel, + I_OnAddXLine, I_OnDelXLine, + /* HostServ */ + I_OnSetVhost, I_OnDeleteVhost + }; + ModuleManager::Attach(i, this, 42); + } + + EventReturn OnLoadDatabase() + { + if (!SQL) + { + Log() << "Error, unable to find service reference for SQL, is m_mysql loaded and configured properly?"; + return EVENT_CONTINUE; + } + + SQLQuery query; + + query = "SELECT * FROM `anope_ns_core`"; + SQLResult r = SQL->RunQuery(query); + for (int i = 0; i < r.Rows(); ++i) + { + NickCore *nc = new NickCore(r.Get(i, "display")); + nc->pass = r.Get(i, "pass"); + nc->email = r.Get(i, "email"); + nc->greet = r.Get(i, "greet"); + + spacesepstream sep(r.Get(i, "flags")); + Anope::string buf; + std::vector flags; + while (sep.GetToken(buf)) + flags.push_back(buf); + nc->FromString(flags); + + nc->language = r.Get(i, "language"); + nc->channelcount = r.Get(i, "channelcount").is_number_only() ? convertTo(r.Get(i, "channelcount")) : 0; + nc->memos.memomax = r.Get(i, "memomax").is_number_only() ? convertTo(r.Get(i, "memomax")) : 20; + } + + query = "SE