summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-09-25 20:10:33 -0400
committerAdam <Adam@anope.org>2016-09-25 20:10:33 -0400
commitf3bfaa814ac9e12bb151620ad807b1f9e57ae323 (patch)
treea9e8a11be22687193b417fe3c97a40de43c9a6b0
parentaee628f6bb7d2a510802a70b635a4c1b4a4fe7c4 (diff)
Get rid of service alias stuff, make proto mods link to each other
-rw-r--r--include/modules/protocol/charybdis.h60
-rw-r--r--include/modules/protocol/hybrid.h129
-rw-r--r--include/modules/protocol/plexus.h50
-rw-r--r--include/modules/protocol/ratbox.h58
-rw-r--r--include/service.h11
-rw-r--r--modules/chanserv/CMakeLists.txt1
-rw-r--r--modules/protocol/CMakeLists.txt1
-rw-r--r--modules/protocol/charybdis.cpp209
-rw-r--r--modules/protocol/hybrid.cpp350
-rw-r--r--modules/protocol/plexus.cpp224
-rw-r--r--modules/protocol/ratbox.cpp170
-rw-r--r--src/service.cpp11
-rw-r--r--src/service_manager.cpp15
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> &params) 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> &params) 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> &params) 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> &params) 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> &params) 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> &params) override;
+};
+
+class Join : public Message::Join
+{
+ public:
+ Join(Module *creator) : Message::Join(creator, "JOIN") { }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) 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> &params) 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> &params) 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> &params) 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> &params) 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> &params) 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> &params) override;
+};
+
+class TBurst : public IRCDMessage
+{
+ public:
+ TBurst(Module *creator) : IRCDMessage(creator, "TBURST", 5) { }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) 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> &params) 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> &params) 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> &params) 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> &params) 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> &params) 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> &params) 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> &params) 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> &params) 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> &params) 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> &params) 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> &params)
{
- 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> &params) 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> &params) 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> &params)
{
- 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> &params) 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> &params)
{
- 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> &params) 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> &params)
+{
+ // 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> &params)
{
- 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> &params) 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> &params)
{
- IRCDMessageEOB(Module *craetor) : IRCDMessage(craetor, "EOB", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+ source.GetServer()->Sync(true);
+}
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
- {
- source.GetServer()->Sync(true);
- }
-};
-
-struct IRCDMessageJoin : Message::Join
+void hybrid::Join::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageJoin(Module *creator) : Message::Join(creator, "JOIN") { }
+ if (params.size() < 2)
+ return;
- void Run(MessageSource &source, const std::vector<Anope::string> &params) 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> &params)
{
- 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> &params) 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> &params)
{
- 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> &params) 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> &params)
{
- 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> &params) 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> &params)
{
- 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> &params) 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> &params)
{
- 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> &params) 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> &params)
{
- 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> &params) 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> &params)
{
- 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> &params) 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> &params)
{
- IRCDMessageTMode(Module *creator) : IRCDMessage(creator, "TMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
+ time_t ts = 0;
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
+ try
{
- time_t ts = 0;
-
- try
- {
- ts = convertTo<time_t>(params[0]);
- }
- catch (const ConvertException &) { }
+ ts = convertTo<time_t>(params[0]);
+ }
+ catch (const ConvertException &) { }
- Channel *c = Channel::Find(params[1]);
- Anope::string modes = params[2];
+ Channel *c = Channel::Find(params[1]);
+ Anope::string modes = params[2];
- for (unsigned i = 3; i < params.size(); ++i)
- modes += " " + params[i];
+ for (unsigned i = 3; i < params.size(); ++i)
+ modes += " " + params[i];
- if (c)
- c->SetModesInternal(source, modes, ts);
- }
-};
+ if (c)
+ c->SetModesInternal(source, modes, ts);
+}
-struct IRCDMessageUID : IRCDMessage
+/* 0 1 2 3 4 5 6 7 8 9 */
+/* :0MC UID Steve 1 1350157102 +oi ~steve resolved.host 10.0.0.1 0MCAAAAAB Steve :Mining all the time */
+void hybrid::UID::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 10) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+ Anope::string ip = params[6];
- /* 0 1 2 3 4 5 6 7 8 9 */
- /* :0MC UID Steve 1 1350157102 +oi ~steve resolved.host 10.0.0.1 0MCAAAAAB Steve :Mining all the time */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
- {
- Anope::string ip = params[6];
-
- if (ip == "0") /* Can be 0 for spoofed clients */
- ip.clear();
+ if (ip == "0") /* Can be 0 for spoofed clients */
+ ip.clear();
- NickServ::Nick *na = NULL;
- if (params[8] != "0" && params[8] != "*")
- na = NickServ::FindNick(params[8]);
+ NickServ::Nick *na = NULL;
+ if (params[8] != "0" && params[8] != "*")
+ na = NickServ::FindNick(params[8]);
- /* Source is always the server */
- User::OnIntroduce(params[0], params[4], params[5], "",
- ip, source.GetServer(),
- params[9], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0,
- params[3], params[7], na ? na->GetAccount() : NULL);
- }
-};
+ /* Source is always the server */
+ User::OnIntroduce(params[0], params[4], params[5], "",
+ ip, source.GetServer(),
+ params[9], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0,
+ params[3], params[7], na ? na->GetAccount() : NULL);
+}
-struct IRCDMessageCertFP: IRCDMessage
+/* 0 */
+/* :0MCAAAAAB CERTFP 4C62287BA6776A89CD4F8FF10A62FFB35E79319F51AF6C62C674984974FCCB1D */
+void hybrid::CertFP::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageCertFP(Module *creator) : IRCDMessage(creator, "CERTFP", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
+ User *u = source.GetUser();
- /* 0 */
- /* :0MCAAAAAB CERTFP 4C62287BA6776A89CD4F8FF10A62FFB35E79319F51AF6C62C674984974FCCB1D */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
- {
- User *u = source.GetUser();
-
- u->fingerprint = params[0];
- EventManager::Get()->Dispatch(&Event::Fingerprint::OnFingerprint, u);
- }
-};
+ u->fingerprint = params[0];
+ EventManager::Get()->Dispatch(&Event::Fingerprint::OnFingerprint, u);
+}
class ProtoHybrid : public Module
, public EventHook<Event::UserNickChange>
@@ -628,20 +562,20 @@ class ProtoHybrid : public Module
Message::Whois message_whois;
/* Our message handlers */
- IRCDMessageBMask message_bmask;
- IRCDMessageEOB message_eob;
- IRCDMessageJoin message_join;
- IRCDMessageNick message_nick;
+ hybrid::CertFP message_certfp;
+ hybrid::BMask message_bmask;
+ hybrid::EOB message_eob;
+ hybrid::Join message_join;
+ hybrid::Nick message_nick;
IRCDMessagePass message_pass;
- IRCDMessagePong message_pong;
- IRCDMessageServer message_server;
- IRCDMessageSID message_sid;
- IRCDMessageSJoin message_sjoin;
- IRCDMessageSVSMode message_svsmode;
- IRCDMessageTBurst message_tburst;
- IRCDMessageTMode message_tmode;
- IRCDMessageUID message_uid;
- IRCDMessageCertFP message_certfp;
+ hybrid::Pong message_pong;
+ hybrid::Server message_server;
+ hybrid::SID message_sid;
+ hybrid::SJoin message_sjoin;
+ hybrid::SVSMode message_svsmode;
+ hybrid::TBurst message_tburst;
+ hybrid::TMode message_tmode;
+ hybrid::UID message_uid;
public:
ProtoHybrid(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR)
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index df9853340..02d2a4d6e 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -17,7 +17,11 @@
* along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
+/* Dependencies: anope_protocol.hybrid */
+
#include "module.h"
+#include "modules/protocol/plexus.h"
+#include "modules/protocol/hybrid.h"
static Anope::string UplinkSID;
@@ -180,48 +184,43 @@ class PlexusProto : public IRCDProto
}
};
-struct IRCDMessageEncap : IRCDMessage
+void plexus::Encap::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageEncap(Module *creator) : IRCDMessage(creator, "ENCAP", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
+ /*
+ * Received: :dev.anope.de ENCAP * SU DukePyrolator DukePyrolator
+ * params[0] = *
+ * params[1] = SU
+ * params[2] = nickname
+ * params[3] = account
+ */
+ if (params[1].equals_cs("SU"))
{
- /*
- * Received: :dev.anope.de ENCAP * SU DukePyrolator DukePyrolator
- * params[0] = *
- * params[1] = SU
- * params[2] = nickname
- * params[3] = account
- */
- if (params[1].equals_cs("SU"))
+ User *u = User::Find(params[2]);
+ NickServ::Account *nc = NickServ::FindAccount(params[3]);
+ if (u && nc)
{
- User *u = User::Find(params[2]);
- NickServ::Account *nc = NickServ::FindAccount(params[3]);
- if (u && nc)
- {
- u->Login(nc);
- }
+ u->Login(nc);
}
+ }
- /*
- * Received: :dev.anope.de ENCAP * CERTFP DukePyrolator :3F122A9CC7811DBAD3566BF2CEC3009007C0868F
- * params[0] = *
- * params[1] = CERTFP
- * params[2] = nickname
- * params[3] = fingerprint
- */
- else if (params[1].equals_cs("CERTFP"))
+ /*
+ * Received: :dev.anope.de ENCAP * CERTFP DukePyrolator :3F122A9CC7811DBAD3566BF2CEC3009007C0868F
+ * params[0] = *
+ * params[1] = CERTFP
+ * params[2] = nickname
+ * params[3] = fingerprint
+ */
+ else if (params[1].equals_cs("CERTFP"))
+ {
+ User *u = User::Find(params[2]);
+ if (u)
{
- User *u = User::Find(params[2]);
- if (u)
- {
- u->fingerprint = params[3];
- EventManager::Get()->Dispatch(&Event::Fingerprint::OnFingerprint, u);
- }
+ u->fingerprint = params[3];
+ EventManager::Get()->Dispatch(&Event::Fingerprint::OnFingerprint, u);
}
- return;
}
-};
+ return;
+}
struct IRCDMessagePass : IRCDMessage
{
@@ -233,70 +232,60 @@ struct IRCDMessagePass : IRCDMessage
}
};
-struct IRCDMessageServer : IRCDMessage
+/* 0 1 2 */
+/* SERVER hades.arpa 1 :ircd-hybrid test server */
+void plexus::Server::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- 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> &params) 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);
- }
-};
-
-struct IRCDMessageUID : IRCDMessage
+/*
+ params[0] = nick
+ params[1] = hop
+ params[2] = ts
+ params[3] = modes
+ params[4] = user
+ params[5] = host
+ params[6] = IP
+ params[7] = UID
+ params[8] = services stamp
+ params[9] = realhost
+ params[10] = info
+*/
+// :42X UID Adam 1 1348535644 +aow Adam 192.168.0.5 192.168.0.5 42XAAAAAB 0 192.168.0.5 :Adam
+void plexus::UID::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 11) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+ /* An IP of 0 means the user is spoofed */
+ Anope::string ip = params[6];
+ if (ip == "0")
+ ip.clear();
- /*
- params[0] = nick
- params[1] = hop
- params[2] = ts
- params[3] = modes
- params[4] = user
- params[5] = host
- params[6] = IP
- params[7] = UID
- params[8] = services stamp
- params[9] = realhost
- params[10] = info
- */
- // :42X UID Adam 1 1348535644 +aow Adam 192.168.0.5 192.168.0.5 42XAAAAAB 0 192.168.0.5 :Adam
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
+ time_t ts;
+ try
{
- /* An IP of 0 means the user is spoofed */
- Anope::string ip = params[6];
- if (ip == "0")
- ip.clear();
-
- time_t ts;
- try
- {
- ts = convertTo<time_t>(params[2]);
- }
- catch (const ConvertException &)
- {
- ts = Anope::CurTime;
- }
-
- NickServ::Nick *na = NULL;
- try
- {
- if (params[8].is_pos_number_only() && convertTo<time_t>(params[8]) == ts)
- na = NickServ::FindNick(params[0]);
- }
- catch (const ConvertException &) { }
- if (params[8] != "0" && !na)
- na = NickServ::FindNick(params[8]);
+ ts = convertTo<time_t>(params[2]);
+ }
+ catch (const ConvertException &)
+ {
+ ts = Anope::CurTime;
+ }
- User::OnIntroduce(params[0], params[4], params[9], params[5], ip, source.GetServer(), params[10], ts, params[3], params[7], na ? na->GetAccount() : NULL);
+ NickServ::Nick *na = NULL;
+ try
+ {
+ if (params[8].is_pos_number_only() && convertTo<time_t>(params[8]) == ts)
+ na = NickServ::FindNick(params[0]);
}
-};
+ catch (const ConvertException &) { }
+ if (params[8] != "0" && !na)
+ na = NickServ::FindNick(params[8]);
+
+ User::OnIntroduce(params[0], params[4], params[9], params[5], ip, source.GetServer(), params[10], ts, params[3], params[7], na ? na->GetAccount() : NULL);
+}
class ProtoPlexus : public Module
{
@@ -325,15 +314,19 @@ class ProtoPlexus : public Module
Message::Version message_version;
Message::Whois message_whois;
- /* Hybrid message handlers */
- ServiceAlias message_bmask, message_eob, message_join, message_nick, message_sid, message_sjoin,
- message_tburst, message_tmode;
-
/* Our message handlers */
- IRCDMessageEncap message_encap;
+ hybrid::BMask message_bmask;
+ hybrid::EOB message_eob;
+ plexus::Encap message_encap;
+ hybrid::Join message_join;
+ hybrid::Nick message_nick;
IRCDMessagePass message_pass;
- IRCDMessageServer message_server;
- IRCDMessageUID message_uid;
+ plexus::Server message_server;
+ hybrid::SID message_sid;
+ hybrid::SJoin message_sjoin;
+ hybrid::TBurst message_tburst;
+ hybrid::TMode message_tmode;
+ plexus::UID message_uid;
public:
ProtoPlexus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR)
@@ -358,36 +351,25 @@ class ProtoPlexus : public Module
, message_version(this)
, message_whois(this)
- , message_bmask("IRCDMessage", "plexus/bmask", "hybrid/bmask")
- , message_eob("IRCDMessage", "plexus/eob", "hybrid/eob")
- , message_join("IRCDMessage", "plexus/join", "hybrid/join")
- , message_nick("IRCDMessage", "plexus/nick", "hybrid/nick")
- , message_sid("IRCDMessage", "plexus/sid", "hybrid/sid")
- , message_sjoin("IRCDMessage", "plexus/sjoin", "hybrid/sjoin")
- , message_tburst("IRCDMessage", "plexus/tburst", "hybrid/tburst")
- , message_tmode("IRCDMessage", "plexus/tmode", "hybrid/tmode")
-
+ , message_bmask(this)
+ , message_eob(this)
, message_encap(this)
+ , message_join(this)
+ , message_nick(this)
, message_pass(this)
, message_server(this)
+ , message_sid(this)
+ , message_sjoin(this)
+ , message_tburst(this)
+ , message_tmode(this)
, message_uid(this)
{
-
- if (ModuleManager::LoadModule("hybrid", User::Find(creator)) != MOD_ERR_OK)
- throw ModuleException("Unable to load hybrid");
- m_hybrid = ModuleManager::FindModule("hybrid");
- if (!m_hybrid)
- throw ModuleException("Unable to find hybrid");
-#warning ""
-// if (!hybrid)
-// throw ModuleException("No protocol interface for hybrid");
- }
-
- ~ProtoPlexus()
- {
- m_hybrid = ModuleManager::FindModule("hybrid");
- ModuleManager::UnloadModule(m_hybrid, NULL);
}
};
+template<> void ModuleInfo<ProtoPlexus>(ModuleDef *def)
+{
+ def->Depends("hybrid");
+}
+
MODULE_INIT(ProtoPlexus)
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index f1a7c85da..5511bcedf 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -17,7 +17,11 @@
* along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
+/* Dependencies: anope_protocol.hybrid */
+
#include "module.h"
+#include "modules/protocol/hybrid.h"
+#include "modules/protocol/ratbox.h"
static Anope::string UplinkSID;
@@ -125,30 +129,25 @@ class RatboxProto : public IRCDProto
}
};
-struct IRCDMessageEncap : IRCDMessage
+// Debug: Received: :00BAAAAAB ENCAP * LOGIN Adam
+void ratbox::Encap::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageEncap(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> &params) override
+ if (params[1] == "LOGIN" || params[1] == "SU")
{
- if (params[1] == "LOGIN" || params[1] == "SU")
- {
- User *u = source.GetUser();
-
- NickServ::Account *nc = NickServ::FindAccount(params[2]);
- if (!nc)
- return;
- u->Login(nc);
-
- /* Sometimes a user connects, we send them the usual "this nickname is registered" mess (if
- * their server isn't syncing) and then we receive this.. so tell them about it.
- */
- if (u->server->IsSynced())
- u->SendMessage(Config->GetClient("NickServ"), _("You have been logged in as \002%s\002."), nc->GetDisplay().c_str());
- }
+ User *u = source.GetUser();
+
+ NickServ::Account *nc = NickServ::FindAccount(params[2]);
+ if (!nc)
+ return;
+ u->Login(nc);
+
+ /* Sometimes a user connects, we send them the usual "this nickname is registered" mess (if
+ * their server isn't syncing) and then we receive this.. so tell them about it.
+ */
+ if (u->server->IsSynced())
+ u->SendMessage(Config->GetClient("NickServ"), _("You have been logged in as \002%s\002."), nc->GetDisplay().c_str());
}
-};
+}
struct IRCDMessagePass : IRCDMessage
{
@@ -160,62 +159,45 @@ struct IRCDMessagePass : IRCDMessage
}
};
-struct IRCDMessageServer : IRCDMessage
+// SERVER hades.arpa 1 :ircd-ratbox test server
+void ratbox::Server::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { 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]);
+}
- // SERVER hades.arpa 1 :ircd-ratbox test server
- void Run(MessageSource &source, const std::vector<Anope::string> &params) 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]);
- }
-};
-
-struct IRCDMessageTBurst : IRCDMessage
+/*
+ * params[0] = channel
+ * params[1] = ts
+ * params[2] = topic OR who set the topic
+ * params[3] = topic if params[2] isn't the topic
+ */
+void ratbox::TB::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageTBurst(Module *creator) : IRCDMessage(creator, "TB", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- /*
- * params[0] = channel
- * params[1] = ts
- * params[2] = topic OR who set the topic
- * params[3] = topic if params[2] isn't the topic
- */
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
- {
- time_t topic_time = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime;
- Channel *c = Channel::Find(params[0]);
+ time_t topic_time = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime;
+ Channel *c = Channel::Find(params[0]);
- if (!c)
- return;
+ if (!c)
+ return;
- const Anope::string &setter = params.size() == 4 ? params[2] : "",
- topic = params.size() == 4 ? params[3] : params[2];
+ const Anope::string &setter = params.size() == 4 ? params[2] : "",
+ topic = params.size() == 4 ? params[3] : params[2];
- c->ChangeTopicInternal(NULL, setter, topic, topic_time);
- }
-};
+ c->ChangeTopicInternal(NULL, setter, topic, topic_time);
+}
-struct IRCDMessageUID : IRCDMessage
+// :42X UID Adam 1 1348535644 +aow Adam 192.168.0.5 192.168.0.5 42XAAAAAB :Adam
+void ratbox::UID::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 9) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
-
- // :42X UID Adam 1 1348535644 +aow Adam 192.168.0.5 192.168.0.5 42XAAAAAB :Adam
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
- {
- /* Source is always the server */
- User::OnIntroduce(params[0], params[4], params[5], "", params[6], source.GetServer(), params[8], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[3], params[7], NULL);
- }
-};
+ /* Source is always the server */
+ User::OnIntroduce(params[0], params[4], params[5], "", params[6], source.GetServer(), params[8], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[3], params[7], NULL);
+}
class ProtoRatbox : public Module
{
- Module *m_hybrid;
-
RatboxProto ircd_proto;
/* Core message handlers */
@@ -239,16 +221,19 @@ class ProtoRatbox : public Module
Message::Version message_version;
Message::Whois message_whois;
- /* Hybrid message handlers */
- ServiceAlias message_bmask, message_join, message_nick, message_pong, message_sid,
- message_sjoin, message_tmode;
-
/* Our message handlers */
- IRCDMessageEncap message_encap;
+ hybrid::BMask message_bmask;
+ ratbox::Encap message_encap;
+ hybrid::Join message_join;
+ hybrid::Nick message_nick;
IRCDMessagePass message_pass;
- IRCDMessageServer message_server;
- IRCDMessageTBurst message_tburst;
- IRCDMessageUID message_uid;
+ hybrid::Pong message_pong;
+ ratbox::Server message_server;
+ hybrid::SID message_sid;
+ hybrid::SJoin message_sjoin;
+ ratbox::TB message_tb;
+ hybrid::TMode message_tmode;
+ ratbox::UID message_uid;
public:
ProtoRatbox(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR)
@@ -273,36 +258,25 @@ class ProtoRatbox : public Module
, message_version(this)
, message_whois(this)
- , message_bmask("IRCDMessage", "ratbox/bmask", "hybrid/bmask")
- , message_join("IRCDMessage", "ratbox/join", "hybrid/join")
- , message_nick("IRCDMessage", "ratbox/nick", "hybrid/nick")
- , message_pong("IRCDMessage", "ratbox/pong", "hybrid/pong")
- , message_sid("IRCDMessage", "ratbox/sid", "hybrid/sid")
- , message_sjoin("IRCDMessage", "ratbox/sjoin", "hybrid/sjoin")
- , message_tmode("IRCDMessage", "ratbox/tmode", "hybrid/tmode")
-
+ , message_bmask(this)
, message_encap(this)
+ , message_join(this)
+ , message_nick(this)
, message_pass(this)
+ , message_pong(this)
, message_server(this)
- , message_tburst(this)
+ , message_sid(this)
+ , message_sjoin(this)
+ , message_tb(this)
+ , message_tmode(this)
, message_uid(this)
{
-
- if (ModuleManager::LoadModule("hybrid", User::Find(creator)) != MOD_ERR_OK)
- throw ModuleException("Unable to load hybrid");
- m_hybrid = ModuleManager::FindModule("hybrid");
- if (!m_hybrid)
- throw ModuleException("Unable to find hybrid");
-#warning ""
-// if (!hybrid)
-// throw ModuleException("No protocol interface for hybrid");
- }
-
- ~ProtoRatbox()
- {
- m_hybrid = ModuleManager::FindModule("hybrid");
- ModuleManager::UnloadModule(m_hybrid, NULL);
}
};
+template<> void ModuleInfo<ProtoRatbox>(ModuleDef *def)
+{
+ def->Depends("hybrid");
+}
+
MODULE_INIT(ProtoRatbox)
diff --git a/src/service.cpp b/src/service.cpp
index 865c479df..9e99d0cad 100644
--- a/src/service.cpp
+++ b/src/service.cpp
@@ -65,14 +65,3 @@ Service::~Service()
ServiceManager::Get()->Unregister(this);
}
-ServiceAlias::ServiceAlias(const Anope::string &type, const Anope::string &from, const Anope::string &to) : t(type), f(from)
-{
- ServiceManager::Get()->AddAlias(type, from, to);
-}
-
-ServiceAlias::~ServiceAlias()
-{
- ServiceManager::Get()->DelAlias(t, f);
-}
-
-
diff --git a/src/service_manager.cpp b/src/service_manager.cpp
index 322cdc31f..ef26fb13b 100644
--- a/src/service_manager.cpp
+++ b/src/service_manager.cpp
@@ -68,21 +68,6 @@ std::vector<Service *> ServiceManager::FindServices(const Anope::string &type)
return v;
}
-void ServiceManager::AddAlias(const Anope::string &t, const Anope::string &n, const Anope::string &v)
-{
-#warning "aliases dont work"
-// std::map<Anope::string, Anope::string> &smap = aliases[t];
-// smap[n] = v;
-}
-
-void ServiceManager::DelAlias(const Anope::string &t, const Anope::string &n)
-{
-// std::map<Anope::string, Anope::string> &smap = aliases[t];
-// smap.erase(n);
-// if (smap.empty())
-// aliases.erase(t);
-}
-
void ServiceManager::Register(Service *service)
{
// assert type