diff options
| author | Adam <Adam@anope.org> | 2013-04-10 22:26:40 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2013-04-10 22:26:40 -0500 |
| commit | 207c46c871e85b55ae66acc456c6bc412c0c79f9 (patch) | |
| tree | 27b07dc9d1e0ee068872ec7841920eea9b846b65 /modules/extra | |
| parent | 957cb2bf93d77a5ebb97d945b0656bd1e7bec164 (diff) | |
Move some of the modules in extras/ that arent really extra out of extras. Mark our modules as VENDOR and allow modules to have multple types.
Diffstat (limited to 'modules/extra')
| -rw-r--r-- | modules/extra/bs_autoassign.cpp | 51 | ||||
| -rw-r--r-- | modules/extra/cs_statusupdate.cpp | 67 | ||||
| -rw-r--r-- | modules/extra/m_chanstats.cpp | 3 | ||||
| -rw-r--r-- | modules/extra/m_dns.cpp | 3 | ||||
| -rw-r--r-- | modules/extra/m_dnsbl.cpp | 176 | ||||
| -rw-r--r-- | modules/extra/m_helpchan.cpp | 46 | ||||
| -rw-r--r-- | modules/extra/m_httpd.cpp | 3 | ||||
| -rw-r--r-- | modules/extra/m_ldap.cpp | 2 | ||||
| -rw-r--r-- | modules/extra/m_ldap_authentication.cpp | 3 | ||||
| -rw-r--r-- | modules/extra/m_ldap_oper.cpp | 3 | ||||
| -rw-r--r-- | modules/extra/m_mysql.cpp | 2 | ||||
| -rw-r--r-- | modules/extra/m_proxyscan.cpp | 3 | ||||
| -rw-r--r-- | modules/extra/m_regex_pcre.cpp | 3 | ||||
| -rw-r--r-- | modules/extra/m_regex_posix.cpp | 3 | ||||
| -rw-r--r-- | modules/extra/m_regex_tre.cpp | 3 | ||||
| -rw-r--r-- | modules/extra/m_rewrite.cpp | 192 | ||||
| -rw-r--r-- | modules/extra/m_sql_authentication.cpp | 3 | ||||
| -rw-r--r-- | modules/extra/m_sql_oper.cpp | 3 | ||||
| -rw-r--r-- | modules/extra/m_sqlite.cpp | 2 | ||||
| -rw-r--r-- | modules/extra/m_ssl.cpp | 3 | ||||
| -rw-r--r-- | modules/extra/m_xmlrpc.cpp | 2 | ||||
| -rw-r--r-- | modules/extra/m_xmlrpc_main.cpp | 2 | ||||
| -rw-r--r-- | modules/extra/ns_maxemail.cpp | 88 | ||||
| -rw-r--r-- | modules/extra/webcpanel/webcpanel.cpp | 3 |
24 files changed, 18 insertions, 651 deletions
diff --git a/modules/extra/bs_autoassign.cpp b/modules/extra/bs_autoassign.cpp deleted file mode 100644 index 8bdab26d7..000000000 --- a/modules/extra/bs_autoassign.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * (C) 2003-2013 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - -#include "module.h" - -class BSAutoAssign : public Module -{ - Anope::string bot; - - public: - BSAutoAssign(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) - { - this->SetAuthor("Anope"); - - Implementation i[] = { I_OnChanRegistered, I_OnReload }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - this->OnReload(); - } - - void OnChanRegistered(ChannelInfo *ci) anope_override - { - if (this->bot.empty()) - return; - - BotInfo *bi = BotInfo::Find(this->bot); - if (bi == NULL) - { - Log(this) << "bs_autoassign is configured to assign bot " << this->bot << ", but it does not exist?"; - return; - } - - bi->Assign(NULL, ci); - } - - void OnReload() anope_override - { - ConfigReader config; - this->bot = config.ReadValue("bs_autoassign", "bot", "", 0); - } -}; - -MODULE_INIT(BSAutoAssign) diff --git a/modules/extra/cs_statusupdate.cpp b/modules/extra/cs_statusupdate.cpp deleted file mode 100644 index 934b928d1..000000000 --- a/modules/extra/cs_statusupdate.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * (C) 2003-2013 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#include "module.h" - -class StatusUpdate : public Module -{ - public: - StatusUpdate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) - { - this->SetAuthor("Anope"); - - Implementation i[] = { I_OnAccessAdd, I_OnAccessDel }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - } - - void OnAccessAdd(ChannelInfo *ci, CommandSource &, ChanAccess *access) anope_override - { - if (ci->c) - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) - { - User *user = it->second->user; - - if (user->server != Me && access->Matches(user, user->Account())) - { - for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i) - { - ChannelModeStatus *cms = ModeManager::GetStatusChannelModesByRank()[i]; - if (!access->HasPriv("AUTO" + cms->name)) - ci->c->RemoveMode(NULL, cms, user->GetUID()); - } - ci->c->SetCorrectModes(user, true, false); - } - } - } - - void OnAccessDel(ChannelInfo *ci, CommandSource &, ChanAccess *access) anope_override - { - if (ci->c) - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) - { - User *user = it->second->user; - - if (user->server != Me && access->Matches(user, user->Account())) - { - /* Get user's current access and remove the entry about to be deleted */ - AccessGroup ag = ci->AccessFor(user); - AccessGroup::iterator iter = std::find(ag.begin(), ag.end(), access); - if (iter != ag.end()) - ag.erase(iter); - - for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i) - { - ChannelModeStatus *cms = ModeManager::GetStatusChannelModesByRank()[i]; - if (!ag.HasPriv("AUTO" + cms->name)) - ci->c->RemoveMode(NULL, cms, user->GetUID()); - } - } - } - } -}; - -MODULE_INIT(StatusUpdate) diff --git a/modules/extra/m_chanstats.cpp b/modules/extra/m_chanstats.cpp index 3c964b55c..d62befbb0 100644 --- a/modules/extra/m_chanstats.cpp +++ b/modules/extra/m_chanstats.cpp @@ -334,9 +334,8 @@ class MChanstats : public Module public: MChanstats(const Anope::string &modname, const Anope::string &creator) : - Module(modname, creator, CORE), sql("", ""), sqlinterface(this) + Module(modname, creator, EXTRA | VENDOR), sql("", ""), sqlinterface(this) { - this->SetAuthor("Anope"); Implementation i[] = { I_OnPrivmsg, I_OnUserKicked, diff --git a/modules/extra/m_dns.cpp b/modules/extra/m_dns.cpp index 90f9bee9e..3ee7aaa67 100644 --- a/modules/extra/m_dns.cpp +++ b/modules/extra/m_dns.cpp @@ -933,9 +933,8 @@ class ModuleDNS : public Module int port; public: - ModuleDNS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), manager(this) + ModuleDNS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), manager(this) { - this->SetAuthor("Anope"); Implementation i[] = { I_OnReload, I_OnModuleUnload }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); diff --git a/modules/extra/m_dnsbl.cpp b/modules/extra/m_dnsbl.cpp deleted file mode 100644 index 49d39d980..000000000 --- a/modules/extra/m_dnsbl.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* - * (C) 2003-2013 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#include "module.h" -#include "dns.h" - -using namespace DNS; - -static ServiceReference<XLineManager> akills("XLineManager", "xlinemanager/sgline"); -static ServiceReference<Manager> dnsmanager("DNS::Manager", "dns/manager"); - -struct Blacklist -{ - Anope::string name; - time_t bantime; - Anope::string reason; - std::map<int, Anope::string> replies; - - Blacklist(const Anope::string &n, time_t b, const Anope::string &r, const std::map<int, Anope::string> &re) : name(n), bantime(b), reason(r), replies(re) { } -}; - -class DNSBLResolver : public Request -{ - Reference<User> user; - Blacklist blacklist; - bool add_to_akill; - - public: - DNSBLResolver(Module *c, User *u, const Blacklist &b, const Anope::string &host, bool add_akill) : Request(dnsmanager, c, host, QUERY_A, true), user(u), blacklist(b), add_to_akill(add_akill) { } - - void OnLookupComplete(const Query *record) anope_override - { - if (!user || user->HasExt("m_dnsbl_akilled")) - return; - - const ResourceRecord &ans_record = record->answers[0]; - // Replies should be in 127.0.0.0/24 - if (ans_record.rdata.find("127.0.0.") != 0) - return; - - Anope::string record_reason; - if (!this->blacklist.replies.empty()) - { - sockaddrs sresult; - sresult.pton(AF_INET, ans_record.rdata); - int result = sresult.sa4.sin_addr.s_addr >> 24; - - if (!this->blacklist.replies.count(result)) - return; - record_reason = this->blacklist.replies[result]; - } - - user->Extend("m_dnsbl_akilled"); - - Anope::string reason = this->blacklist.reason; - reason = reason.replace_all_cs("%n", user->nick); - reason = reason.replace_all_cs("%u", user->GetIdent()); - reason = reason.replace_all_cs("%g", user->realname); - reason = reason.replace_all_cs("%h", user->host); - reason = reason.replace_all_cs("%i", user->ip); - reason = reason.replace_all_cs("%r", record_reason); - reason = reason.replace_all_cs("%N", Config->NetworkName); - - Log(OperServ) << "DNSBL: " << user->GetMask() << " (" << user->ip << ") appears in " << this->blacklist.name; - XLine *x = new XLine("*@" + user->ip, Config->OperServ, Anope::CurTime + this->blacklist.bantime, reason, XLineManager::GenerateUID()); - if (this->add_to_akill && akills) - { - akills->AddXLine(x); - akills->Send(NULL, x); - } - else - { - IRCD->SendAkill(NULL, x); - delete x; - } - } -}; - -class ModuleDNSBL : public Module -{ - std::vector<Blacklist> blacklists; - bool check_on_connect; - bool check_on_netburst; - bool add_to_akill; - - public: - ModuleDNSBL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) - { - this->SetAuthor("Anope"); - - Implementation i[] = { I_OnReload, I_OnUserConnect }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - OnReload(); - } - - void OnReload() anope_override - { - ConfigReader config; - - this->check_on_connect = config.ReadFlag("m_dnsbl", "check_on_connect", "no", 0); - this->check_on_netburst = config.ReadFlag("m_dnsbl", "check_on_netburst", "no", 0); - this->add_to_akill = config.ReadFlag("m_dnsbl", "add_to_akill", "yes", 0); - - this->blacklists.clear(); - for (int i = 0, num = config.Enumerate("blacklist"); i < num; ++i) - { - Anope::string bname = config.ReadValue("blacklist", "name", "", i); - if (bname.empty()) - continue; - Anope::string sbantime = config.ReadValue("blacklist", "time", "4h", i); - time_t bantime = Anope::DoTime(sbantime); - if (bantime < 0) - bantime = 9000; - Anope::string reason = config.ReadValue("blacklist", "reason", "", i); - std::map<int, Anope::string> replies; - for (int j = 0; j < 256; ++j) - { - Anope::string k = config.ReadValue("blacklist", stringify(j), "", i); - if (!k.empty()) - replies[j] = k; - } - - this->blacklists.push_back(Blacklist(bname, bantime, reason, replies)); - } - } - - void OnUserConnect(User *user, bool &exempt) anope_override - { - if (exempt || user->Quitting() || (!this->check_on_connect && !Me->IsSynced()) || !dnsmanager) - return; - - if (!this->check_on_netburst && !user->server->IsSynced()) - return; - - /* At this time we only support IPv4 */ - sockaddrs user_ip; - try - { - user_ip.pton(AF_INET, user->ip); - } - catch (const SocketException &) - { - /* User doesn't have a valid IPv4 IP (ipv6/spoof/etc) */ - return; - } - - const unsigned long &ip = user_ip.sa4.sin_addr.s_addr; - unsigned long reverse_ip = (ip << 24) | ((ip & 0xFF00) << 8) | ((ip & 0xFF0000) >> 8) | (ip >> 24); - - user_ip.sa4.sin_addr.s_addr = reverse_ip; - - for (unsigned i = 0; i < this->blacklists.size(); ++i) - { - const Blacklist &b = this->blacklists[i]; - - try - { - Anope::string dnsbl_host = user_ip.addr() + "." + b.name; - DNSBLResolver *res = new DNSBLResolver(this, user, b, dnsbl_host, this->add_to_akill); - dnsmanager->Process(res); - } - catch (const SocketException &ex) - { - Log(this) << ex.GetReason(); - } - } - } -}; - -MODULE_INIT(ModuleDNSBL) - diff --git a/modules/extra/m_helpchan.cpp b/modules/extra/m_helpchan.cpp deleted file mode 100644 index 32d1859fc..000000000 --- a/modules/extra/m_helpchan.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * (C) 2003-2013 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#include "module.h" - -class HelpChannel : public Module -{ - Anope::string HelpChan; - - public: - HelpChannel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) - { - this->SetAuthor("Anope"); - - Implementation i[] = { I_OnChannelModeSet, I_OnReload }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - OnReload(); - } - - EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, const Anope::string &mname, const Anope::string ¶m) anope_override - { - if (mname == "OP" && c && c->ci && c->name.equals_ci(this->HelpChan)) - { - User *u = User::Find(param); - - if (u && c->ci->AccessFor(u).HasPriv("OPDEOPME")) - u->SetMode(OperServ, "HELPOP"); - } - - return EVENT_CONTINUE; - } - - void OnReload() anope_override - { - ConfigReader config; - - this->HelpChan = config.ReadValue("m_helpchan", "helpchannel", "", 0); - } -}; - -MODULE_INIT(HelpChannel) diff --git a/modules/extra/m_httpd.cpp b/modules/extra/m_httpd.cpp index f1e5392c5..6972bcdf1 100644 --- a/modules/extra/m_httpd.cpp +++ b/modules/extra/m_httpd.cpp @@ -331,9 +331,8 @@ class HTTPD : public Module ServiceReference<SSLService> sslref; std::map<Anope::string, HTTPProvider *> providers; public: - HTTPD(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), sslref("SSLService", "ssl") + HTTPD(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), sslref("SSLService", "ssl") { - this->SetAuthor("Anope"); Implementation i[] = { I_OnReload }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); diff --git a/modules/extra/m_ldap.cpp b/modules/extra/m_ldap.cpp index d53e04992..80a6b5a9e 100644 --- a/modules/extra/m_ldap.cpp +++ b/modules/extra/m_ldap.cpp @@ -403,7 +403,7 @@ class ModuleLDAP : public Module, public Pipe std::map<Anope::string, LDAPService *> LDAPServices; public: - ModuleLDAP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) + ModuleLDAP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) { me = this; diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp index 5ddd9da2d..cc5626cd3 100644 --- a/modules/extra/m_ldap_authentication.cpp +++ b/modules/extra/m_ldap_authentication.cpp @@ -216,9 +216,8 @@ class NSIdentifyLDAP : public Module Anope::string disable_email_reason; public: NSIdentifyLDAP(const Anope::string &modname, const Anope::string &creator) : - Module(modname, creator, SUPPORTED), ldap("LDAPProvider", "ldap/main"), iinterface(this), oninterface(this), orinterface(this) + Module(modname, creator, EXTRA | VENDOR), ldap("LDAPProvider", "ldap/main"), iinterface(this), oninterface(this), orinterface(this) { - this->SetAuthor("Anope"); me = this; diff --git a/modules/extra/m_ldap_oper.cpp b/modules/extra/m_ldap_oper.cpp index ed2f5900a..f44628c63 100644 --- a/modules/extra/m_ldap_oper.cpp +++ b/modules/extra/m_ldap_oper.cpp @@ -86,9 +86,8 @@ class LDAPOper : public Module Anope::string filter; public: LDAPOper(const Anope::string &modname, const Anope::string &creator) : - Module(modname, creator, SUPPORTED), ldap("LDAPProvider", "ldap/main"), iinterface(this) + Module(modname, creator, EXTRA | VENDOR), ldap("LDAPProvider", "ldap/main"), iinterface(this) { - this->SetAuthor("Anope"); Implementation i[] = { I_OnReload, I_OnNickIdentify, I_OnDelCore }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp index e072f8dfe..8eecb4a23 100644 --- a/modules/extra/m_mysql.cpp +++ b/modules/extra/m_mysql.cpp @@ -165,7 +165,7 @@ class ModuleSQL : public Module, public Pipe /* The thread used to execute queries */ DispatcherThread *DThread; - ModuleSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) + ModuleSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) { me = this; diff --git a/modules/extra/m_proxyscan.cpp b/modules/extra/m_proxyscan.cpp index e14f82df6..78f42a910 100644 --- a/modules/extra/m_proxyscan.cpp +++ b/modules/extra/m_proxyscan.cpp @@ -221,10 +221,9 @@ class ModuleProxyScan : public Module } connectionTimeout; public: - ModuleProxyScan(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), + ModuleProxyScan(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), connectionTimeout(this, 5) { - this->SetAuthor("Anope"); Implementation i[] = { I_OnReload, I_OnUserConnect }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); diff --git a/modules/extra/m_regex_pcre.cpp b/modules/extra/m_regex_pcre.cpp index 998a7692d..b6bf88af1 100644 --- a/modules/extra/m_regex_pcre.cpp +++ b/modules/extra/m_regex_pcre.cpp @@ -44,10 +44,9 @@ class ModuleRegexPCRE : public Module PCRERegexProvider pcre_regex_provider; public: - ModuleRegexPCRE(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), + ModuleRegexPCRE(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), pcre_regex_provider(this) { - this->SetAuthor("Anope"); this->SetPermanent(true); } }; diff --git a/modules/extra/m_regex_posix.cpp b/modules/extra/m_regex_posix.cpp index 409a057ba..551d978b8 100644 --- a/modules/extra/m_regex_posix.cpp +++ b/modules/extra/m_regex_posix.cpp @@ -46,10 +46,9 @@ class ModuleRegexPOSIX : public Module POSIXRegexProvider posix_regex_provider; public: - ModuleRegexPOSIX(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), + ModuleRegexPOSIX(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), posix_regex_provider(this) { - this->SetAuthor("Anope"); this->SetPermanent(true); } }; diff --git a/modules/extra/m_regex_tre.cpp b/modules/extra/m_regex_tre.cpp index 8cfbd3b18..760097b08 100644 --- a/modules/extra/m_regex_tre.cpp +++ b/modules/extra/m_regex_tre.cpp @@ -47,10 +47,9 @@ class ModuleRegexTRE : public Module TRERegexProvider tre_regex_provider; public: - ModuleRegexTRE(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), + ModuleRegexTRE(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), tre_regex_provider(this) { - this->SetAuthor("Anope"); this->SetPermanent(true); } }; diff --git a/modules/extra/m_rewrite.cpp b/modules/extra/m_rewrite.cpp deleted file mode 100644 index 2df259e3d..000000000 --- a/modules/extra/m_rewrite.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * (C) 2003-2013 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#include "module.h" - -struct Rewrite -{ - Anope::string client, source_message, target_message, desc; - - bool Matches(const std::vector<Anope::string> &message) - { - std::vector<Anope::string> sm; - spacesepstream(this->source_message).GetTokens(sm); - - for (unsigned i = 0; i < sm.size(); ++i) - if (i >= message.size() || (sm[i] != "$" && !sm[i].equals_ci(message[i]))) - return false; - - return true; - } - - Anope::string Process(CommandSource &source, const std::vector<Anope::string> ¶ms) - { - spacesepstream sep(this->target_message); - Anope::string token, message; - - while (sep.GetToken(token)) - { - if (token[0] != '$') - message += " " + token; - else if (token == "$me") - message += " " + source.GetNick(); - else - { - int num = -1, end = -1; - try - { - Anope::string num_str = token.substr(1); - size_t hy = num_str.find('-'); - if (hy == Anope::string::npos) - { - num = convertTo<int>(num_str); - end = num + 1; - } - else - { - num = convertTo<int>(num_str.substr(0, hy)); - if (hy == num_str.length() - 1) - end = params.size(); - else - end = convertTo<int>(num_str.substr(hy + 1)) + 1; - } - } - catch (const ConvertException &) - { - continue; - } - - for (int i = num; i < end && static_cast<unsigned>(i) < params.size(); ++i) - message += " " + params[i]; - } - } - - message.trim(); - return message; - } - - static std::vector<Rewrite> rewrites; - - static Rewrite *Find(const Anope::string &client, const Anope::string &cmd) - { - for (unsigned i = 0; i < rewrites.size(); ++i) - { - Rewrite &r = rewrites[i]; - - if ((client.empty() || r.client.equals_ci(client)) && (r.source_message.equals_ci(cmd) || r.source_message.find_ci(cmd + " ") == 0)) - return &r; - } - - return NULL; - } - - static Rewrite *Match(const Anope::string &client, const std::vector<Anope::string> ¶ms) - { - for (unsigned i = 0; i < rewrites.size(); ++i) - { - Rewrite &r = rewrites[i]; - - if ((client.empty() || r.client.equals_ci(client)) && r.Matches(params)) - return &r; - } - - return NULL; - } -}; - -std::vector<Rewrite> Rewrite::rewrites; - -class RewriteCommand : public Command -{ - public: - RewriteCommand(Module *creator) : Command(creator, "rewrite", 0, 0) { } - - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - std::vector<Anope::string> full_params = params; - full_params.insert(full_params.begin(), source.command); - - Rewrite *r = Rewrite::Match(!source.c ? source.service->nick : "", full_params); - if (r != NULL) - { - Anope::string new_message = r->Process(source, full_params); - Log(LOG_DEBUG) << "m_rewrite: Rewrote '" << source.command << (!params.empty() ? " " + params[0] : "") << "' to '" << new_message << "' using '" << r->source_message << "'"; - source.service = BotInfo::Find(r->client); - if (!source.service) - return; - RunCommand(source, new_message); - } - else - Log() << "m_rewrite: Unable to rewrite '" << source.command << (!params.empty() ? " " + params[0] : "") << "'"; - } - - void OnServHelp(CommandSource &source) anope_override - { - Rewrite *r = Rewrite::Find(!source.c ? source.service->nick : "", source.command); - if (r != NULL && !r->desc.empty()) - { - this->SetDesc(r->desc); - Command::OnServHelp(source); - } - } - - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override - { - Rewrite *r = Rewrite::Find(!source.c ? source.service->nick : "", source.command); - if (r != NULL && !r->desc.empty()) - { - source.Reply(r->desc); - size_t sz = r->target_message.find(' '); - source.Reply(_("This command is an alias to the command %s."), sz != Anope::string::npos ? r->target_message.substr(0, sz).c_str() : r->target_message.c_str()); - return true; - } - return false; - } -}; - -class ModuleRewrite : public Module -{ - RewriteCommand cmdrewrite; - - public: - ModuleRewrite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), cmdrewrite(this) - { - this->SetAuthor("Anope"); - - Implementation i[] = { I_OnReload }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - this->OnReload(); - } - - void OnReload() anope_override - { - ConfigReader config; - - Rewrite::rewrites.clear(); - - for (int i = 0; i < config.Enumerate("command"); ++i) - { - if (!config.ReadFlag("command", "rewrite", "no", i)) - continue; - - Rewrite rw; - - rw.client = config.ReadValue("command", "service", "", i); - rw.source_message = config.ReadValue("command", "rewrite_source", "", i), - rw.target_message = config.ReadValue("command", "rewrite_target", "", i); - rw.desc = config.ReadValue("command", "rewrite_description", "", i); - - if (rw.client.empty() || rw.source_message.empty() || rw.target_message.empty()) - continue; - - Rewrite::rewrites.push_back(rw); - } - } -}; - -MODULE_INIT(ModuleRewrite) diff --git a/modules/extra/m_sql_authentication.cpp b/modules/extra/m_sql_authentication.cpp index abdd745a5..7fcdf4e13 100644 --- a/modules/extra/m_sql_authentication.cpp +++ b/modules/extra/m_sql_authentication.cpp @@ -78,9 +78,8 @@ class ModuleSQLAuthentication : public Module ServiceReference<SQL::Provider> SQL; public: - ModuleSQLAuthentication(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) + ModuleSQLAuthentication(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) { - this->SetAuthor("Anope"); me = this; diff --git a/modules/extra/m_sql_oper.cpp b/modules/extra/m_sql_oper.cpp index f786ad36d..bbcd108c4 100644 --- a/modules/extra/m_sql_oper.cpp +++ b/modules/extra/m_sql_oper.cpp @@ -94,9 +94,8 @@ class ModuleSQLOper : public Module ServiceReference<SQL::Provider> SQL; public: - ModuleSQLOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) + ModuleSQLOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) { - this->SetAuthor("Anope"); Implementation i[] = { I_OnReload, I_OnNickIdentify }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); diff --git a/modules/extra/m_sqlite.cpp b/modules/extra/m_sqlite.cpp index 69fd16b9f..623e1e8b1 100644 --- a/modules/extra/m_sqlite.cpp +++ b/modules/extra/m_sqlite.cpp @@ -64,7 +64,7 @@ class ModuleSQLite : public Module /* SQL connections */ std::map<Anope::string, SQLiteService *> SQLiteServices; public: - ModuleSQLite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) + ModuleSQLite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) { Implementation i[] = { I_OnReload }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); diff --git a/modules/extra/m_ssl.cpp b/modules/extra/m_ssl.cpp index 7158a5ce5..5ecf30cfc 100644 --- a/modules/extra/m_ssl.cpp +++ b/modules/extra/m_ssl.cpp @@ -92,11 +92,10 @@ class SSLModule : public Module public: MySSLService service; - SSLModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), service(this, "ssl") + SSLModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), service(this, "ssl") { me = this; - this->SetAuthor("Anope"); this->SetPermanent(true); SSL_library_init(); diff --git a/modules/extra/m_xmlrpc.cpp b/modules/extra/m_xmlrpc.cpp index a3b999a5e..060001940 100644 --- a/modules/extra/m_xmlrpc.cpp +++ b/modules/extra/m_xmlrpc.cpp @@ -161,7 +161,7 @@ class ModuleXMLRPC : public Module public: MyXMLRPCServiceInterface xmlrpcinterface; - ModuleXMLRPC(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), xmlrpcinterface(this, "xmlrpc") + ModuleXMLRPC(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), xmlrpcinterface(this, "xmlrpc") { OnReload(); diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp index 9166f27df..0ba748f0b 100644 --- a/modules/extra/m_xmlrpc_main.cpp +++ b/modules/extra/m_xmlrpc_main.cpp @@ -258,7 +258,7 @@ class ModuleXMLRPCMain : public Module MyXMLRPCEvent stats; public: - ModuleXMLRPCMain(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), xmlrpc("XMLRPCServiceInterface", "xmlrpc") + ModuleXMLRPCMain(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), xmlrpc("XMLRPCServiceInterface", "xmlrpc") { me = this; diff --git a/modules/extra/ns_maxemail.cpp b/modules/extra/ns_maxemail.cpp deleted file mode 100644 index fda500a07..000000000 --- a/modules/extra/ns_maxemail.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* ns_maxemail.cpp - Limit the amount of times an email address - * can be used for a NickServ account. - * - * (C) 2003-2013 Anope Team - * Contact us at team@anope.org - * - * Included in the Anope module pack since Anope 1.7.9 - * Anope Coder: GeniusDex <geniusdex@anope.org> - * - * Please read COPYING and README for further details. - */ - -#include "module.h" - -class NSMaxEmail : public Module -{ - int NSEmailMax; - - bool CheckLimitReached(CommandSource &source, const Anope::string &email) - { - if (this->NSEmailMax < 1 || email.empty()) - return false; - - if (this->CountEmail(email, source.nc) < this->NSEmailMax) - return false; - - if (this->NSEmailMax == 1) - source.Reply(_("The given email address has reached its usage limit of 1 user.")); - else - source.Reply(_("The given email address has reached its usage limit of %d users."), this->NSEmailMax); - - return true; - } - - int CountEmail(const Anope::string &email, NickCore *unc) - { - int count = 0; - - if (email.empty()) - return 0; - - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) - { - const NickCore *nc = it->second; - - if (unc != nc && !nc->email.empty() && nc->email.equals_ci(email)) - ++count; - } - - return count; - } - - public: - NSMaxEmail(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) - { - this->SetAuthor("Anope"); - - Implementation i[] = { I_OnReload, I_OnPreCommand }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - OnReload(); - } - - void OnReload() anope_override - { - ConfigReader config; - this->NSEmailMax = config.ReadInteger("ns_maxemail", "maxemails", "0", 0, false); - Log(LOG_DEBUG) << "[ns_maxemail] NSEmailMax set to " << NSEmailMax; - } - - EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) anope_override - { - if (command->name == "nickserv/register") - { - if (this->CheckLimitReached(source, params.size() > 1 ? params[1] : "")) - return EVENT_STOP; - } - else if (command->name == "nickserv/set/email") - { - if (this->CheckLimitReached(source, params.size() > 0 ? params[0] : "")) - return EVENT_STOP; - } - - return EVENT_CONTINUE; - } -}; - -MODULE_INIT(NSMaxEmail) diff --git a/modules/extra/webcpanel/webcpanel.cpp b/modules/extra/webcpanel/webcpanel.cpp index 77e99dd4e..e2a026559 100644 --- a/modules/extra/webcpanel/webcpanel.cpp +++ b/modules/extra/webcpanel/webcpanel.cpp @@ -41,7 +41,7 @@ class ModuleWebCPanel : public Module public: - ModuleWebCPanel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), + ModuleWebCPanel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), panel(this, "webcpanel"), style_css("style.css", "/static/style.css", "text/css"), logo_png("logo.png", "/static/logo.png", "image/png"), favicon_ico("favicon.ico", "/favicon.ico", "image/x-icon"), index("/"), logout("/logout"), _register("/register"), confirm("/confirm"), @@ -49,7 +49,6 @@ class ModuleWebCPanel : public Module chanserv_info(Config->ChanServ, "/chanserv/info"), chanserv_set(Config->ChanServ, "/chanserv/set"), chanserv_access(Config->ChanServ, "/chanserv/access"), chanserv_akick(Config->ChanServ, "/chanserv/akick"), chanserv_drop(Config->ChanServ, "/chanserv/drop"), memoserv_memos(Config->MemoServ, "/memoserv/memos"), hostserv_request(Config->HostServ, "/hostserv/request"), operserv_akill(Config->OperServ, "/operserv/akill") { - this->SetAuthor("Anope"); me = this; |
