diff options
| author | Adam <Adam@anope.org> | 2016-12-01 19:46:06 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2016-12-01 19:46:06 -0500 |
| commit | 76771aa05f7168ca02c217d3c6de36e84381eb5d (patch) | |
| tree | 2a6efe527c1178903e24bf920e047c07f539d040 | |
| parent | d95bc84eda5c131374b7097f9de7f59418bd9b6a (diff) | |
Split more protocol module message handler declarations into module headers
| -rw-r--r-- | include/modules/protocol/bahamut.h | 73 | ||||
| -rw-r--r-- | include/modules/protocol/charybdis.h | 4 | ||||
| -rw-r--r-- | include/modules/protocol/hybrid.h | 4 | ||||
| -rw-r--r-- | include/modules/protocol/inspircd20.h | 214 | ||||
| -rw-r--r-- | include/modules/protocol/ngircd.h | 127 | ||||
| -rw-r--r-- | include/modules/protocol/plexus.h | 4 | ||||
| -rw-r--r-- | include/modules/protocol/ratbox.h | 4 | ||||
| -rw-r--r-- | include/modules/protocol/unreal.h | 187 | ||||
| -rw-r--r-- | modules/protocol/bahamut.cpp | 249 | ||||
| -rw-r--r-- | modules/protocol/charybdis.cpp | 16 | ||||
| -rw-r--r-- | modules/protocol/hybrid.cpp | 70 | ||||
| -rw-r--r-- | modules/protocol/inspircd20.cpp | 1094 | ||||
| -rw-r--r-- | modules/protocol/ngircd.cpp | 655 | ||||
| -rw-r--r-- | modules/protocol/plexus.cpp | 6 | ||||
| -rw-r--r-- | modules/protocol/ratbox.cpp | 25 | ||||
| -rw-r--r-- | modules/protocol/rfc1459.cpp | 7 | ||||
| -rw-r--r-- | modules/protocol/unreal.cpp | 787 |
17 files changed, 1974 insertions, 1552 deletions
diff --git a/include/modules/protocol/bahamut.h b/include/modules/protocol/bahamut.h new file mode 100644 index 000000000..634360f99 --- /dev/null +++ b/include/modules/protocol/bahamut.h @@ -0,0 +1,73 @@ +/* + * Anope IRC Services + * + * Copyright (C) 2003-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 bahamut +{ + +class Burst : public IRCDMessage +{ + public: + Burst(Module *creator) : IRCDMessage(creator, "BURST", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Mode : public IRCDMessage +{ + public: + Mode(Module *creator, const Anope::string &sname) : IRCDMessage(creator, sname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + 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_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class ServerMessage : public IRCDMessage +{ + public: + ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { 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_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Topic : public IRCDMessage +{ + public: + Topic(Module *creator) : IRCDMessage(creator, "TOPIC", 4) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +} // namespace bahamut
\ No newline at end of file diff --git a/include/modules/protocol/charybdis.h b/include/modules/protocol/charybdis.h index 36de05544..4d525c49d 100644 --- a/include/modules/protocol/charybdis.h +++ b/include/modules/protocol/charybdis.h @@ -40,10 +40,10 @@ class EUID : public IRCDMessage void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; }; -class Server : public IRCDMessage +class ServerMessage : public IRCDMessage { public: - Server(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + ServerMessage(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; diff --git a/include/modules/protocol/hybrid.h b/include/modules/protocol/hybrid.h index 76c84f33c..9c1444f4d 100644 --- a/include/modules/protocol/hybrid.h +++ b/include/modules/protocol/hybrid.h @@ -64,10 +64,10 @@ class Pong : public IRCDMessage void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; }; -class Server : public IRCDMessage +class ServerMessage : public IRCDMessage { public: - Server(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; }; diff --git a/include/modules/protocol/inspircd20.h b/include/modules/protocol/inspircd20.h new file mode 100644 index 000000000..d65b174f9 --- /dev/null +++ b/include/modules/protocol/inspircd20.h @@ -0,0 +1,214 @@ +/* + * 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 inspircd20 +{ + +class Capab : public rfc1459::Capab +{ + public: + Capab(Module *creator) : rfc1459::Capab(creator, "CAPAB") { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class ChgHost : public IRCDMessage +{ + public: + ChgHost(Module *creator) : IRCDMessage(creator, "CHGHOST", 2) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class ChgIdent : public IRCDMessage +{ + public: + ChgIdent(Module *creator) : IRCDMessage(creator, "CHGIDENT", 2) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class ChgName : public IRCDMessage +{ + public: + ChgName(Module *creator) : IRCDMessage(creator, "CHGNAME", 2) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Encap : public IRCDMessage +{ + public: + Encap(Module *creator) : IRCDMessage(creator, "ENCAP", 4) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Endburst : public IRCDMessage +{ + public: + Endburst(Module *creator) : IRCDMessage(creator, "ENDBURST", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class FHost : public IRCDMessage +{ + public: + FHost(Module *creator) : IRCDMessage(creator, "FHOST", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class FIdent : public IRCDMessage +{ + public: + FIdent(Module *creator) : IRCDMessage(creator, "FIDENT", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class FJoin : public IRCDMessage +{ + public: + FJoin(Module *creator) : IRCDMessage(creator, "FJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class FMode : public IRCDMessage +{ + public: + FMode(Module *creator) : IRCDMessage(creator, "FMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class FTopic : public IRCDMessage +{ + public: + FTopic(Module *creator) : IRCDMessage(creator, "FTOPIC", 4) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Idle : public IRCDMessage +{ + public: + Idle(Module *creator) : IRCDMessage(creator, "IDLE", 1) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Metadata : public IRCDMessage +{ + public: + const bool &do_topiclock, &do_mlock; + + Metadata(Module *creator, const bool &handle_topiclock, const bool &handle_mlock) + : IRCDMessage(creator, "METADATA", 3) + , do_topiclock(handle_topiclock) + , do_mlock(handle_mlock) + { + SetFlag(IRCDMESSAGE_REQUIRE_SERVER); + } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Mode : public IRCDMessage +{ + public: + Mode(Module *creator) : IRCDMessage(creator, "MODE", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + 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 OperType : public IRCDMessage +{ + public: + OperType(Module *creator) : IRCDMessage(creator, "OPERTYPE", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_USER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class RSQuit : public IRCDMessage +{ + public: + RSQuit(Module *creator) : IRCDMessage(creator, "RSQUIT", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Save : public IRCDMessage +{ + time_t last_collide = 0; + + public: + Save(Module *creator) : IRCDMessage(creator, "SAVE", 2) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class ServerMessage : public IRCDMessage +{ + public: + ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 5) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class SQuit : public rfc1459::SQuit +{ + public: + SQuit(Module *creator) : rfc1459::SQuit(creator) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Time : public IRCDMessage +{ + public: + Time(Module *creator) : IRCDMessage(creator, "TIME", 2) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class UID : public IRCDMessage +{ + ServiceReference<SASL::Service> sasl; + + public: + UID(Module *creator) : IRCDMessage(creator, "UID", 8) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +} // namespace inspircd20 + diff --git a/include/modules/protocol/ngircd.h b/include/modules/protocol/ngircd.h new file mode 100644 index 000000000..0bfebea9f --- /dev/null +++ b/include/modules/protocol/ngircd.h @@ -0,0 +1,127 @@ +/* + * Anope IRC Services + * + * Copyright (C) 2011-2016 Anope Team <team@anope.org> + * Copyright (C) 2011-2012, 2014 Alexander Barton <alex@barton.de> + * + * 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 ngircd +{ + +class Numeric005 : public IRCDMessage +{ + public: + Numeric005(Module *creator) : IRCDMessage(creator, "005", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + // Please see <http://www.irc.org/tech_docs/005.html> for details. + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class ChanInfo : public IRCDMessage +{ + public: + ChanInfo(Module *creator) : IRCDMessage(creator, "CHANINFO", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + /* + * CHANINFO is used by servers to inform each other about a channel: its + * modes, channel key, user limits and its topic. The parameter combination + * <key> and <limit> is optional, as well as the <topic> parameter, so that + * there are three possible forms of this command: + * + * CHANINFO <chan> +<modes> + * CHANINFO <chan> +<modes> :<topic> + * CHANINFO <chan> +<modes> <key> <limit> :<topic> + * + * The parameter <key> must be ignored if a channel has no key (the parameter + * <modes> doesn't list the "k" channel mode). In this case <key> should + * contain "*" because the parameter <key> is required by the CHANINFO syntax + * and therefore can't be omitted. The parameter <limit> must be ignored when + * a channel has no user limit (the parameter <modes> doesn't list the "l" + * channel mode). In this case <limit> should be "0". + */ + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms); +}; + +class Join : public rfc1459::Join +{ + public: + Join(Module *creator) : rfc1459::Join(creator, "JOIN") { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Metadata : public IRCDMessage +{ + public: + Metadata(Module *creator) : IRCDMessage(creator, "METADATA", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Mode : public IRCDMessage +{ + public: + Mode(Module *creator) : IRCDMessage(creator, "MODE", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +struct Nick : public IRCDMessage +{ + public: + Nick(Module *creator) : IRCDMessage(creator, "NICK", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class NJoin : public IRCDMessage +{ + public: + NJoin(Module *creator) : IRCDMessage(creator, "NJOIN",2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }; + + /* + * RFC 2813, 4.2.2: Njoin Message: + * The NJOIN message is used between servers only. + * It is used when two servers connect to each other to exchange + * the list of channel members for each channel. + * + * Even though the same function can be performed by using a succession + * of JOIN, this message SHOULD be used instead as it is more efficient. + * + * Received: :dev.anope.de NJOIN #test :DukeP2,@DukeP,%test,+test2 + */ + 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 ServerMessage : public IRCDMessage +{ + public: + ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +} // namespace ngircd
\ No newline at end of file diff --git a/include/modules/protocol/plexus.h b/include/modules/protocol/plexus.h index d17725be4..b87f3e6c7 100644 --- a/include/modules/protocol/plexus.h +++ b/include/modules/protocol/plexus.h @@ -30,10 +30,10 @@ class Encap : public IRCDMessage void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; }; -class Server : public IRCDMessage +class ServerMessage : public IRCDMessage { public: - Server(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { 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 index e03846142..32710fbea 100644 --- a/include/modules/protocol/ratbox.h +++ b/include/modules/protocol/ratbox.h @@ -41,10 +41,10 @@ class Join : public rfc1459::Join void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; }; -class Server : public IRCDMessage +class ServerMessage : public IRCDMessage { public: - Server(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; }; diff --git a/include/modules/protocol/unreal.h b/include/modules/protocol/unreal.h new file mode 100644 index 000000000..305d52bd0 --- /dev/null +++ b/include/modules/protocol/unreal.h @@ -0,0 +1,187 @@ +/* + * Anope IRC Services + * + * Copyright (C) 2003-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 unreal +{ + +class ChgHost : public IRCDMessage +{ + public: + ChgHost(Module *creator) : IRCDMessage(creator, "CHGHOST", 2) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class ChgIdent : public IRCDMessage +{ + public: + ChgIdent(Module *creator) : IRCDMessage(creator, "CHGIDENT", 2) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class ChgName : public IRCDMessage +{ + public: + ChgName(Module *creator) : IRCDMessage(creator, "CHGNAME", 2) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class MD : public IRCDMessage +{ + public: + MD(Module *creator) : IRCDMessage(creator, "MD", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Mode : public IRCDMessage +{ + public: + Mode(Module *creator, const Anope::string &mname) : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class NetInfo : public IRCDMessage +{ + public: + NetInfo(Module *creator) : IRCDMessage(creator, "NETINFO", 8) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + 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_SOFT_LIMIT); } + + 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 Protoctl : public rfc1459::Capab +{ + public: + Protoctl(Module *creator) : rfc1459::Capab(creator, "PROTOCTL") { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class SASL : public IRCDMessage +{ + ServiceReference<::SASL::Service> sasl; + + public: + SASL(Module *creator) : IRCDMessage(creator, "SASL", 4) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class SDesc : public IRCDMessage +{ + public: + SDesc(Module *creator) : IRCDMessage(creator, "SDESC", 1) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class SetHost : public IRCDMessage +{ + public: + SetHost(Module *creator) : IRCDMessage(creator, "SETHOST", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class SetIdent : public IRCDMessage +{ + public: + SetIdent(Module *creator) : IRCDMessage(creator, "SETIDENT", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +struct SetName : IRCDMessage +{ + public: + SetName(Module *creator) : IRCDMessage(creator, "SETNAME", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class ServerMessage : public IRCDMessage +{ + public: + ServerMessage(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", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Topic : public IRCDMessage +{ + public: + Topic(Module *creator) : IRCDMessage(creator, "TOPIC", 4) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class UID : public IRCDMessage +{ + public: + UID(Module *creator) : IRCDMessage(creator, "UID", 12) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +class Umode2 : public IRCDMessage +{ + public: + Umode2(Module *creator) : IRCDMessage(creator, "UMODE2", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + +} // namespace unreal diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 988cfaead..8e753b443 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -21,6 +21,7 @@ #include "module.h" #include "modules/protocol/rfc1459.h" +#include "modules/protocol/bahamut.h" class ChannelModeFlood : public ChannelModeParam { @@ -317,56 +318,39 @@ class BahamutIRCdProto : public IRCDProto } }; -struct IRCDMessageBurst : IRCDMessage +void bahamut::Burst::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageBurst(Module *creator) : IRCDMessage(creator, "BURST", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + Server *s = source.GetServer(); + s->Sync(true); +} - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override - { - /* If we found a server with the given source, that one just - * finished bursting. If there was no source, then our uplink - * server finished bursting. -GD - */ - Server *s = source.GetServer(); - if (!s) - s = Me->GetLinks().front(); - if (s) - s->Sync(true); - } -}; - -struct IRCDMessageMode : IRCDMessage +void bahamut::Mode::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageMode(Module *creator, const Anope::string &sname) : IRCDMessage(creator, sname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } - - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override + if (params.size() > 2 && IRCD->IsChannelValid(params[0])) { - if (params.size() > 2 && IRCD->IsChannelValid(params[0])) - { - Channel *c = Channel::Find(params[0]); - time_t ts = 0; - - try - { - ts = convertTo<time_t>(params[1]); - } - catch (const ConvertException &) { } - - Anope::string modes = params[2]; - for (unsigned int i = 3; i < params.size(); ++i) - modes += " " + params[i]; + Channel *c = Channel::Find(params[0]); + time_t ts = 0; - if (c) - c->SetModesInternal(source, modes, ts); - } - else + try { - User *u = User::Find(params[0]); - if (u) - u->SetModesInternal(source, "%s", params[1].c_str()); + ts = convertTo<time_t>(params[1]); } + catch (const ConvertException &) { } + + Anope::string modes = params[2]; + for (unsigned int i = 3; i < params.size(); ++i) + modes += " " + params[i]; + + if (c) + c->SetModesInternal(source, modes, ts); } -}; + else + { + User *u = User::Find(params[0]); + if (u) + u->SetModesInternal(source, "%s", params[1].c_str()); + } +} /* ** NICK - new @@ -386,117 +370,128 @@ struct IRCDMessageMode : IRCDMessage ** parv[0] = new nickname ** parv[1] = hopcount */ -struct IRCDMessageNick : IRCDMessage +void bahamut::Nick::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } - - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override + if (params.size() == 10) { - if (params.size() == 10) + Server *s = Server::Find(params[6]); + if (s == nullptr) { - Server *s = Server::Find(params[6]); - if (s == NULL) - { - Log(LOG_DEBUG) << "User " << params[0] << " introduced from non-existent server " << params[6] << "?"; - return; - } + Log(LOG_DEBUG) << "User " << params[0] << " introduced from non-existent server " << params[6] << "?"; + return; + } - NickServ::Nick *na = NULL; - time_t signon = params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, - stamp = params[7].is_pos_number_only() ? convertTo<time_t>(params[7]) : 0; - if (signon && signon == stamp && NickServ::service) - na = NickServ::service->FindNick(params[0]); + NickServ::Nick *na = nullptr; + time_t signon = 0, stamp = 0; - User::OnIntroduce(params[0], params[4], params[5], "", params[8], s, params[9], signon, params[3], "", na ? na->GetAccount() : NULL); + try + { + signon = convertTo<time_t>(params[2]); + stamp = convertTo<time_t>(params[7]); } - else + catch (const ConvertException &) { - User *u = source.GetUser(); - - if (u) - u->ChangeNick(params[0]); } + + if (signon && signon == stamp && NickServ::service) + na = NickServ::service->FindNick(params[0]); + + User::OnIntroduce(params[0], params[4], params[5], "", params[8], s, params[9], signon, params[3], "", na ? na->GetAccount() : nullptr); } -}; + else + { + User *u = source.GetUser(); -struct IRCDMessageServer : IRCDMessage + if (u) + u->ChangeNick(params[0]); + } +} + +void bahamut::ServerMessage::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + unsigned int hops = 0; - void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override + try { - unsigned int hops = Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0; - new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[2]); + hops = convertTo<unsigned>(params[1]); } -}; + catch (const ConvertException &) { } + + new Server(source.GetServer(), params[0], hops, params[2]); +} -struct IRCDMessageSJoin : IRCDMessage +void bahamut::SJoin::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - IRCDMessageSJoin(Module *creator) : IRCDMessage(creator, "SJOIN", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + Anope::string modes; + if (params.size() >= 4) + for (unsigned i = 2; i < params.size(); ++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() >= 4) - for (unsigned i = 2; i < params.size(); ++i) - modes += " " + params[i]; - if (!modes.empty()) - modes.erase(modes.begin()); + std::list<rfc1459::Join::SJoinUser> users; - std::list<rfc1459::Join::SJoinUser> users; + /* For some reason, bahamut will send a SJOIN from the user joining a channel + * if the channel already existed + */ + if (source.GetUser()) + { + rfc1459::Join::SJoinUser sju; + sju.second = source.GetUser(); + users.push_back(sju); + } + else + { + spacesepstream sep(params[params.size() - 1]); + Anope::string buf; - /* For some reason, bahamut will send a SJOIN from the user joining a channel - * if the channel already existed - */ - if (source.GetUser()) + while (sep.GetToken(buf)) { rfc1459::Join::SJoinUser sju; - sju.second = source.GetUser(); - users.push_back(sju); - } - else - { - spacesepstream sep(params[params.size() - 1]); - Anope::string buf; - while (sep.GetToken(buf)) + /* Get prefixes from the nick */ + for (char ch; !buf.empty() && (ch = ModeManager::GetStatusChar(buf[0]));) + { + buf.erase(buf.begin()); + sju.first.AddMode(ch); + } + + sju.second = User::Find(buf); + if (!sju.second) { - rfc1459::Join::SJoinUser sju; - |
