diff options
| author | Adam <Adam@anope.org> | 2016-09-25 20:10:33 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2016-09-25 20:10:33 -0400 |
| commit | f3bfaa814ac9e12bb151620ad807b1f9e57ae323 (patch) | |
| tree | a9e8a11be22687193b417fe3c97a40de43c9a6b0 | |
| parent | aee628f6bb7d2a510802a70b635a4c1b4a4fe7c4 (diff) | |
Get rid of service alias stuff, make proto mods link to each other
| -rw-r--r-- | include/modules/protocol/charybdis.h | 60 | ||||
| -rw-r--r-- | include/modules/protocol/hybrid.h | 129 | ||||
| -rw-r--r-- | include/modules/protocol/plexus.h | 50 | ||||
| -rw-r--r-- | include/modules/protocol/ratbox.h | 58 | ||||
| -rw-r--r-- | include/service.h | 11 | ||||
| -rw-r--r-- | modules/chanserv/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | modules/protocol/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | modules/protocol/charybdis.cpp | 209 | ||||
| -rw-r--r-- | modules/protocol/hybrid.cpp | 350 | ||||
| -rw-r--r-- | modules/protocol/plexus.cpp | 224 | ||||
| -rw-r--r-- | modules/protocol/ratbox.cpp | 170 | ||||
| -rw-r--r-- | src/service.cpp | 11 | ||||
| -rw-r--r-- | src/service_manager.cpp | 15 |
13 files changed, 700 insertions, 589 deletions
diff --git a/include/modules/protocol/charybdis.h b/include/modules/protocol/charybdis.h new file mode 100644 index 000000000..36de05544 --- /dev/null +++ b/include/modules/protocol/charybdis.h @@ -0,0 +1,60 @@ +/* + * Anope IRC Services + * + * Copyright (C) 2016 Anope Team <team@anope.org> + * + * This file is part of Anope. Anope is free software; you can + * redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software + * Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +namespace charybdis +{ + +class Encap : public IRCDMessage +{ + ServiceReference<SASL::Service> sasl; + + public: + Encap(Module *creator) : IRCDMessage(creator, "ENCAP", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT);} + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class EUID : public IRCDMessage +{ + public: + EUID(Module *creator) : IRCDMessage(creator, "EUID", 11) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Server : public IRCDMessage +{ + public: + Server(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + // SERVER dev.anope.de 1 :charybdis test server + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Pass : public IRCDMessage +{ + public: + Pass(Module *creator) : IRCDMessage(creator, "PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +} // namespace charybdis diff --git a/include/modules/protocol/hybrid.h b/include/modules/protocol/hybrid.h new file mode 100644 index 000000000..4991ec624 --- /dev/null +++ b/include/modules/protocol/hybrid.h @@ -0,0 +1,129 @@ +/* + * Anope IRC Services + * + * Copyright (C) 2016 Anope Team <team@anope.org> + * + * This file is part of Anope. Anope is free software; you can + * redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software + * Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +namespace hybrid +{ + +class BMask : public IRCDMessage +{ + public: + BMask(Module *creator) : IRCDMessage(creator, "BMASK", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class EOB : public IRCDMessage +{ + public: + EOB(Module *craetor) : IRCDMessage(craetor, "EOB", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Join : public Message::Join +{ + public: + Join(Module *creator) : Message::Join(creator, "JOIN") { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Nick : public IRCDMessage +{ + public: + Nick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Pong : public IRCDMessage +{ + public: + Pong(Module *creator) : IRCDMessage(creator, "PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Server : public IRCDMessage +{ + public: + Server(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class SID : public IRCDMessage +{ + public: + SID(Module *creator) : IRCDMessage(creator, "SID", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class SJoin : public IRCDMessage +{ + public: + SJoin(Module *creator) : IRCDMessage(creator, "SJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class SVSMode : public IRCDMessage +{ + public: + SVSMode(Module *creator) : IRCDMessage(creator, "SVSMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class TBurst : public IRCDMessage +{ + public: + TBurst(Module *creator) : IRCDMessage(creator, "TBURST", 5) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class TMode : public IRCDMessage +{ + public: + TMode(Module *creator) : IRCDMessage(creator, "TMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class UID : public IRCDMessage +{ + public: + UID(Module *creator) : IRCDMessage(creator, "UID", 10) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class CertFP : public IRCDMessage +{ + public: + CertFP(Module *creator) : IRCDMessage(creator, "CERTFP", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +} // namespace hybrid
\ No newline at end of file diff --git a/include/modules/protocol/plexus.h b/include/modules/protocol/plexus.h new file mode 100644 index 000000000..1d6f79780 --- /dev/null +++ b/include/modules/protocol/plexus.h @@ -0,0 +1,50 @@ +/* + * Anope IRC Services + * + * Copyright (C) 2016 Anope Team <team@anope.org> + * + * This file is part of Anope. Anope is free software; you can + * redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software + * Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +namespace plexus +{ + +class Encap : public IRCDMessage +{ + public: + Encap(Module *creator) : IRCDMessage(creator, "ENCAP", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Server : public IRCDMessage +{ + public: + Server(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class UID : public IRCDMessage +{ + public: + UID(Module *creator) : IRCDMessage(creator, "UID", 11) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +} + diff --git a/include/modules/protocol/ratbox.h b/include/modules/protocol/ratbox.h new file mode 100644 index 000000000..d2661a41f --- /dev/null +++ b/include/modules/protocol/ratbox.h @@ -0,0 +1,58 @@ +/* + * Anope IRC Services + * + * Copyright (C) 2016 Anope Team <team@anope.org> + * + * This file is part of Anope. Anope is free software; you can + * redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software + * Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +namespace ratbox +{ + +class Encap : public IRCDMessage +{ + public: + Encap(Module *creator) : IRCDMessage(creator, "ENCAP", 3) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + + // Debug: Received: :00BAAAAAB ENCAP * LOGIN Adam + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Server : public IRCDMessage +{ + public: + Server(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class TB : public IRCDMessage +{ + public: + TB(Module *creator) : IRCDMessage(creator, "TB", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class UID : public IRCDMessage +{ + public: + UID(Module *creator) : IRCDMessage(creator, "UID", 9) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +} // namespace ratbox
\ No newline at end of file diff --git a/include/service.h b/include/service.h index 7ce593578..fd5e2245a 100644 --- a/include/service.h +++ b/include/service.h @@ -160,10 +160,6 @@ class ServiceManager return static_cast<T>(FindService(type, name)); } - void AddAlias(const Anope::string &t, const Anope::string &n, const Anope::string &v); - - void DelAlias(const Anope::string &t, const Anope::string &n); - void Register(Service *service); void Unregister(Service *service); @@ -177,10 +173,3 @@ class ServiceManager static void Destroy(); }; -class ServiceAlias -{ - Anope::string t, f; - public: - ServiceAlias(const Anope::string &type, const Anope::string &from, const Anope::string &to); - ~ServiceAlias(); -}; diff --git a/modules/chanserv/CMakeLists.txt b/modules/chanserv/CMakeLists.txt index afefd9d26..9a236d6d0 100644 --- a/modules/chanserv/CMakeLists.txt +++ b/modules/chanserv/CMakeLists.txt @@ -1,3 +1,2 @@ -#add_subdirs(${CMAKE_CURRENT_SOURCE_DIR}) build_modules(${CMAKE_CURRENT_SOURCE_DIR}) build_modules_dependencies(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/modules/protocol/CMakeLists.txt b/modules/protocol/CMakeLists.txt index cd225a94d..9a236d6d0 100644 --- a/modules/protocol/CMakeLists.txt +++ b/modules/protocol/CMakeLists.txt @@ -1 +1,2 @@ build_modules(${CMAKE_CURRENT_SOURCE_DIR}) +build_modules_dependencies(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp index 121915924..f6cb2f29a 100644 --- a/modules/protocol/charybdis.cpp +++ b/modules/protocol/charybdis.cpp @@ -17,9 +17,14 @@ * along with this program; if not, see see <http://www.gnu.org/licenses/>. */ +/* Dependencies: anope_protocol.ratbox */ + #include "module.h" -#include "modules/chanserv/mode.h" #include "modules/sasl.h" +#include "modules/protocol/hybrid.h" +#include "modules/protocol/charybdis.h" +#include "modules/protocol/ratbox.h" +#include "modules/chanserv/mode.h" static Anope::string UplinkSID; @@ -164,115 +169,79 @@ class CharybdisProto : public IRCDProto }; -struct IRCDMessageEncap : IRCDMessage +void charybdis::Encap::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - ServiceReference<SASL::Service> sasl; + User *u = source.GetUser(); - IRCDMessageEncap(Module *creator) : IRCDMessage(creator, "ENCAP", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT);} - - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override + // In a burst, states that the source user is logged in as the account. + if (params[1] == "LOGIN" || params[1] == "SU") { - User *u = source.GetUser(); - - // In a burst, states that the source user is logged in as the account. - if (params[1] == "LOGIN" || params[1] == "SU") - { - NickServ::Account *nc = NickServ::FindAccount(params[2]); - if (!nc) - return; - u->Login(nc); - } - // Received: :42XAAAAAE ENCAP * CERTFP :3f122a9cc7811dbad3566bf2cec3009007c0868f - if (params[1] == "CERTFP") - { - u->fingerprint = params[2]; - EventManager::Get()->Dispatch(&Event::Fingerprint::OnFingerprint, u); - } - /* - * Received: :42X ENCAP * SASL 42XAAAAAH * S PLAIN - * Received: :42X ENCAP * SASL 42XAAAAAC * D A - * - * Part of a SASL authentication exchange. The mode is 'C' to send some data - * (base64 encoded), or 'S' to end the exchange (data indicates type of - * termination: 'A' for abort, 'F' for authentication failure, 'S' for - * authentication success). - * - * Charybdis only accepts messages from SASL agents; these must have umode +S - */ - if (params[1] == "SASL" && sasl && params.size() >= 6) - { - SASL::Message m; - m.source = params[2]; - m.target = params[3]; - m.type = params[4]; - m.data = params[5]; - m.ext = params.size() > 6 ? params[6] : ""; - - sasl->ProcessMessage(m); - } + NickServ::Account *nc = NickServ::FindAccount(params[2]); + if (!nc) + return; + u->Login(nc); + } + // Received: :42XAAAAAE ENCAP * CERTFP :3f122a9cc7811dbad3566bf2cec3009007c0868f + if (params[1] == "CERTFP") + { + u->fingerprint = params[2]; + EventManager::Get()->Dispatch(&Event::Fingerprint::OnFingerprint, u); } -}; - -struct IRCDMessageEUID : IRCDMessage -{ - IRCDMessageEUID(Module *creator) : IRCDMessage(creator, "EUID", 11) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } - /* - * :42X EUID DukePyrolator 1 1353240577 +Zi ~jens erft-5d80b00b.pool.mediaWays.net 93.128.176.11 42XAAAAAD * * :jens - * :<SID> EUID <NICK> <HOPS> <TS> +<UMODE> <USERNAME> <VHOST> <IP> <UID> <REALHOST> <ACCOUNT> :<GECOS> - * 0 1 2 3 4 5 6 7 8 9 10 + * Received: :42X ENCAP * SASL 42XAAAAAH * S PLAIN + * Received: :42X ENCAP * SASL 42XAAAAAC * D A + * + * Part of a SASL authentication exchange. The mode is 'C' to send some data + * (base64 encoded), or 'S' to end the exchange (data indicates type of + * termination: 'A' for abort, 'F' for authentication failure, 'S' for + * authentication success). * - * Introduces a user. The hostname field is now always the visible host. - * The realhost field is * if the real host is equal to the visible host. - * The account field is * if the login is not set. - * Note that even if both new fields are *, an EUID command still carries more - * information than a UID command (namely that real host is visible host and the - * user is not logged in with services). Hence a NICK or UID command received - * from a remote server should not be sent in EUID form to other servers. + * Charybdis only accepts messages from SASL agents; these must have umode +S */ - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override + if (params[1] == "SASL" && sasl && params.size() >= 6) { - NickServ::Nick *na = NULL; - if (params[9] != "*") - na = NickServ::FindNick(params[9]); - - User::OnIntroduce(params[0], params[4], params[8], params[5], params[6], source.GetServer(), params[10], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime, params[3], params[7], na ? na->GetAccount() : NULL); + SASL::Message m; + m.source = params[2]; + m.target = params[3]; + m.type = params[4]; + m.data = params[5]; + m.ext = params.size() > 6 ? params[6] : ""; + + sasl->ProcessMessage(m); } -}; +} -// we can't use this function from ratbox because we set a local variable here -struct IRCDMessageServer : IRCDMessage +void charybdis::EUID::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + NickServ::Nick *na = NULL; + if (params[9] != "*") + na = NickServ::FindNick(params[9]); - // SERVER dev.anope.de 1 :charybdis test server - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override - { - // Servers other then our immediate uplink are introduced via SID - if (params[1] != "1") - return; - new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID); - IRCD->SendPing(Me->GetName(), params[0]); - } -}; + User::OnIntroduce(params[0], params[4], params[8], params[5], params[6], source.GetServer(), params[10], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime, params[3], params[7], na ? na->GetAccount() : NULL); +} // we can't use this function from ratbox because we set a local variable here -struct IRCDMessagePass : IRCDMessage +// SERVER dev.anope.de 1 :charybdis test server +void charybdis::Server::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessagePass(Module *creator) : IRCDMessage(creator, "PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + // Servers other then our immediate uplink are introduced via SID + if (params[1] != "1") + return; + new ::Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID); + IRCD->SendPing(Me->GetName(), params[0]); +} - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override - { - // UplinkSID is used in IRCDMessageServer - UplinkSID = params[3]; - } -}; +// we can't use this function from ratbox because we set a local variable here +void charybdis::Pass::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) +{ + // UplinkSID is used in server handler + UplinkSID = params[3]; +} class ProtoCharybdis : public Module , public EventHook<Event::ChannelSync> , public EventHook<Event::MLockEvents> { - Module *m_ratbox; ServiceReference<ModeLocks> mlocks; CharybdisProto ircd_proto; @@ -298,15 +267,20 @@ class ProtoCharybdis : public Module Message::Version message_version; Message::Whois message_whois; - /* Ratbox Message Handlers */ - ServiceAlias message_bmask, message_join, message_nick, message_pong, message_sid, message_sjoin, - message_tb, message_tmode, message_uid; - /* Our message handlers */ - IRCDMessageEncap message_encap; - IRCDMessageEUID message_euid; - IRCDMessagePass message_pass; - IRCDMessageServer message_server; + hybrid::BMask message_bmask; + charybdis::Encap message_encap; + charybdis::EUID message_euid; + hybrid::Join message_join; + hybrid::Nick message_nick; + charybdis::Pass message_pass; + hybrid::Pong message_pong; + charybdis::Server message_server; + hybrid::SID message_sid; + hybrid::SJoin message_sjoin; + ratbox::TB message_tb; + hybrid::TMode message_tmode; + ratbox::UID message_uid; bool use_server_side_mlock; @@ -335,38 +309,20 @@ class ProtoCharybdis : public Module , message_version(this) , message_whois(this) - , message_bmask("IRCDMessage", "charybdis/bmask", "ratbox/bmask") - , message_join("IRCDMessage", "charybdis/join", "ratbox/join") - , message_nick("IRCDMessage", "charybdis/nick", "ratbox/nick") - , message_pong("IRCDMessage", "charybdis/pong", "ratbox/pong") - , message_sid("IRCDMessage", "charybdis/sid", "ratbox/sid") - , message_sjoin("IRCDMessage", "charybdis/sjoin", "ratbox/sjoin") - , message_tb("IRCDMessage", "charybdis/tb", "ratbox/tb") - , message_tmode("IRCDMessage", "charybdis/tmode", "ratbox/tmode") - , message_uid("IRCDMessage", "charybdis/uid", "ratbox/uid") - + , message_bmask(this) , message_encap(this) , message_euid(this) + , message_join(this) + , message_nick(this) , message_pass(this) + , message_pong(this) , message_server(this) - + , message_sid(this) + , message_sjoin(this) + , message_tb(this) + , message_tmode(this) + , message_uid(this) { - - - if (ModuleManager::LoadModule("ratbox", User::Find(creator)) != MOD_ERR_OK) - throw ModuleException("Unable to load ratbox"); - m_ratbox = ModuleManager::FindModule("ratbox"); - if (!m_ratbox) - throw ModuleException("Unable to find ratbox"); -#warning "" -// if (!ratbox) -// throw ModuleException("No protocol interface for ratbox"); - } - - ~ProtoCharybdis() - { - m_ratbox = ModuleManager::FindModule("ratbox"); - ModuleManager::UnloadModule(m_ratbox, NULL); } void OnReload(Configuration::Conf *conf) override @@ -417,4 +373,9 @@ class ProtoCharybdis : public Module } }; +template<> void ModuleInfo<ProtoCharybdis>(ModuleDef *def) +{ + def->Depends("ratbox"); +} + MODULE_INIT(ProtoCharybdis) diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index ccf4cd05b..8345b18d3 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -19,6 +19,7 @@ */ #include "module.h" +#include "modules/protocol/hybrid.h" static Anope::string UplinkSID; @@ -339,64 +340,44 @@ class HybridProto : public IRCDProto } }; -struct IRCDMessageBMask : IRCDMessage +/* 0 1 2 3 */ +/* :0MC BMASK 1350157102 #channel b :*!*@*.test.com */ +void hybrid::BMask::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageBMask(Module *creator) : IRCDMessage(creator, "BMASK", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + Channel *c = Channel::Find(params[1]); + ChannelMode *mode = ModeManager::FindChannelModeByChar(params[2][0]); - /* 0 1 2 3 */ - /* :0MC BMASK 1350157102 #channel b :*!*@*.test.com */ - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override + if (c && mode) { - Channel *c = Channel::Find(params[1]); - ChannelMode *mode = ModeManager::FindChannelModeByChar(params[2][0]); - - if (c && mode) - { - spacesepstream bans(params[3]); - Anope::string token; - while (bans.GetToken(token)) - c->SetModeInternal(source, mode, token); - } + spacesepstream bans(params[3]); + Anope::string token; + while (bans.GetToken(token)) + c->SetModeInternal(source, mode, token); } -}; +} -struct IRCDMessageEOB : IRCDMessage +void hybrid::EOB::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageEOB(Module *craetor) : IRCDMessage(craetor, "EOB", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + source.GetServer()->Sync(true); +} - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override - { - source.GetServer()->Sync(true); - } -}; - -struct IRCDMessageJoin : Message::Join +void hybrid::Join::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageJoin(Module *creator) : Message::Join(creator, "JOIN") { } + if (params.size() < 2) + return; - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override - { - if (params.size() < 2) - return; - - std::vector<Anope::string> p = params; - p.erase(p.begin()); + std::vector<Anope::string> p = params; + p.erase(p.begin()); - return Message::Join::Run(source, p); - } -}; + return Message::Join::Run(source, p); +} -struct IRCDMessageNick : IRCDMessage +/* 0 1 */ +/* :0MCAAAAAB NICK newnick 1350157102 */ +void hybrid::Nick::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } - - /* 0 1 */ - /* :0MCAAAAAB NICK newnick 1350157102 */ - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override - { - source.GetUser()->ChangeNick(params[0], convertTo<time_t>(params[1])); - } -}; + source.GetUser()->ChangeNick(params[0], convertTo<time_t>(params[1])); +} struct IRCDMessagePass : IRCDMessage { @@ -410,196 +391,149 @@ struct IRCDMessagePass : IRCDMessage } }; -struct IRCDMessagePong : IRCDMessage +void hybrid::Pong::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessagePong(Module *creator) : IRCDMessage(creator, "PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + source.GetServer()->Sync(false); +} - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override - { - source.GetServer()->Sync(false); - } -}; - -struct IRCDMessageServer : IRCDMessage +/* 0 1 2 */ +/* SERVER hades.arpa 1 :ircd-hybrid test server */ +void hybrid::Server::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + /* Servers other than our immediate uplink are introduced via SID */ + if (params[1] != "1") + return; - /* 0 1 2 */ - /* SERVER hades.arpa 1 :ircd-hybrid test server */ - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override - { - /* Servers other than our immediate uplink are introduced via SID */ - if (params[1] != "1") - return; - - new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID); + new ::Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID); - IRCD->SendPing(Me->GetName(), params[0]); - } -}; + IRCD->SendPing(Me->GetName(), params[0]); +} -struct IRCDMessageSID : IRCDMessage +void hybrid::SID::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageSID(Module *creator) : IRCDMessage(creator, "SID", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + unsigned int hops = params[1].is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0; + new ::Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[3], params[2]); - /* 0 1 2 3 */ - /* :0MC SID hades.arpa 2 4XY :ircd-hybrid test server */ - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override - { - unsigned int hops = params[1].is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0; - new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[3], params[2]); - - IRCD->SendPing(Me->GetName(), params[0]); - } -}; + IRCD->SendPing(Me->GetName(), params[0]); +} -struct IRCDMessageSJoin : IRCDMessage +void hybrid::SJoin::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageSJoin(Module *creator) : IRCDMessage(creator, "SJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + Anope::string modes; + if (params.size() >= 3) + for (unsigned i = 2; i < params.size() - 1; ++i) + modes += " " + params[i]; + if (!modes.empty()) + modes.erase(modes.begin()); - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override - { - Anope::string modes; - if (params.size() >= 3) - for (unsigned i = 2; i < params.size() - 1; ++i) - modes += " " + params[i]; - if (!modes.empty()) - modes.erase(modes.begin()); + std::list<Message::Join::SJoinUser> users; - std::list<Message::Join::SJoinUser> users; + spacesepstream sep(params[params.size() - 1]); + Anope::string buf; - spacesepstream sep(params[params.size() - 1]); - Anope::string buf; + while (sep.GetToken(buf)) + { + Message::Join::SJoinUser sju; - while (sep.GetToken(buf)) + /* Get prefixes from the nick */ + for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));) { - Message::Join::SJoinUser sju; - - /* Get prefixes from the nick */ - for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));) - { - buf.erase(buf.begin()); - sju.first.AddMode(ch); - } - - sju.second = User::Find(buf); - if (!sju.second) - { - Log(LOG_DEBUG) << "SJOIN for non-existent user " << buf << " on " << params[1]; - continue; - } + buf.erase(buf.begin()); + sju.first.AddMode(ch); + } - users.push_back(sju); + sju.second = User::Find(buf); + if (!sju.second) + { + Log(LOG_DEBUG) << "SJOIN for non-existent user " << buf << " on " << params[1]; + continue; } - time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : Anope::CurTime; - Message::Join::SJoin(source, params[1], ts, modes, users); + users.push_back(sju); } -}; -struct IRCDMessageSVSMode : IRCDMessage + time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : Anope::CurTime; + Message::Join::SJoin(source, params[1], ts, modes, users); +} + +/* + * parv[0] = nickname + * parv[1] = TS + * parv[2] = mode + * parv[3] = optional argument (services id) + */ +void hybrid::SVSMode::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageSVSMode(Module *creator) : IRCDMessage(creator, "SVSMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } - - /* - * parv[0] = nickname - * parv[1] = TS - * parv[2] = mode - * parv[3] = optional argument (services id) - */ - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override - { - User *u = User::Find(params[0]); - if (!u) - return; + User *u = User::Find(params[0]); + if (!u) + return; - if (!params[1].is_pos_number_only() || convertTo<time_t>(params[1]) != u->timestamp) - return; + if (!params[1].is_pos_number_only() || convertTo<time_t>(params[1]) != u->timestamp) + return; - u->SetModesInternal(source, "%s", params[2].c_str()); - } -}; + u->SetModesInternal(source, "%s", params[2].c_str()); +} -struct IRCDMessageTBurst : IRCDMessage +void hybrid::TBurst::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageTBurst(Module *creator) : IRCDMessage(creator, "TBURST", 5) { } + Anope::string setter; + sepstream(params[3], '!').GetToken(setter, 0); + time_t topic_time = Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime; + Channel *c = Channel::Find(params[1]); - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override - { - Anope::string setter; - sepstream(params[3], '!').GetToken(setter, 0); - time_t topic_time = Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime; - Channel *c = Channel::Find(params[1]); + if (c) + c->ChangeTopicInternal(NULL, setter, params[4], topic_time); +} - if (c) - c->ChangeTopicInternal(NULL, setter, params[4], topic_time); - } -}; - -struct IRCDMessageTMode : IRCDMessage +void hybrid::TMode::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageTMode(Module *creator) : IRCDMessage(creator, "TMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + time_t ts = 0; - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override + try |
