diff options
author | Adam <Adam@anope.org> | 2016-12-17 21:44:22 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2016-12-17 21:44:22 -0500 |
commit | 4fcbbbe4fbc137841b47c8e2372477b85649270a (patch) | |
tree | f2a5fd3b5a77ef0384df6e2712fdd74f832d7dfe /modules/protocol/inspircd20.cpp | |
parent | ed08d1a31119adb379f8bec46d7ad47ee35c4c92 (diff) |
Split ircdproto send functions out into separate services
This makes it easier to see which send functions a protocol module
implements as they are all explicitly registered by the module, and
avoids the problem of subtly breaking other protocol modules when
using inheritance.
Also split the old "core" send implementations out into a module, and
the TS6 ID generator
Diffstat (limited to 'modules/protocol/inspircd20.cpp')
-rw-r--r-- | modules/protocol/inspircd20.cpp | 581 |
1 files changed, 318 insertions, 263 deletions
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index a8caac27a..011ecfd13 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -17,7 +17,7 @@ * along with this program; if not, see see <http://www.gnu.org/licenses/>. */ -/* Dependencies: anope_protocol.rfc1459 */ +/* Dependencies: anope_protocol.rfc1459,anope_protocol.ts6,anope_protocol.hybrid,anope_protocol.bahamut */ #include "module.h" #include "modules/sasl.h" @@ -25,6 +25,8 @@ #include "modules/chanserv/set.h" #include "modules/protocol/rfc1459.h" #include "modules/protocol/inspircd20.h" +#include "modules/protocol/bahamut.h" +#include "modules/protocol/hybrid.h" struct SASLUser { @@ -37,129 +39,7 @@ static std::list<SASLUser> saslusers; static Anope::string rsquit_server, rsquit_id; static unsigned int spanningtree_proto_ver = 0; -void inspircd20::Proto::SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) -{ - IRCDProto::SendSVSKill(source, user, buf); - user->KillInternal(source, buf); -} - -void inspircd20::Proto::SendChgIdentInternal(const Anope::string &nick, const Anope::string &vIdent) -{ - if (!Servers::Capab.count("CHGIDENT")) - Log() << "CHGIDENT not loaded!"; - else - Uplink::Send(Me, "CHGIDENT", nick, vIdent); -} - -void inspircd20::Proto::SendChgHostInternal(const Anope::string &nick, const Anope::string &vhost) -{ - if (!Servers::Capab.count("CHGHOST")) - Log() << "CHGHOST not loaded!"; - else - Uplink::Send(Me, "CHGHOST", nick, vhost); -} - -void inspircd20::Proto::SendAddLine(const Anope::string &xtype, const Anope::string &mask, time_t duration, const Anope::string &addedby, const Anope::string &reason) -{ - Uplink::Send(Me, "ADDLINE", xtype, mask, addedby, Anope::CurTime, duration, reason); -} - -void inspircd20::Proto::SendDelLine(const Anope::string &xtype, const Anope::string &mask) -{ - Uplink::Send(Me, "DELLINE", xtype, mask); -} - -inspircd20::Proto::Proto(Module *creator) : IRCDProto(creator, "InspIRCd 2.0") -{ - DefaultPseudoclientModes = "+I"; - CanSVSNick = true; - CanSVSJoin = true; - CanSetVHost = true; - CanSetVIdent = true; - CanSQLine = true; - CanSZLine = true; - CanSVSHold = true; - CanCertFP = true; - RequiresID = true; - MaxModes = 20; -} - -void inspircd20::Proto::SendConnect() -{ - Uplink::Send("CAPAB START 1202"); - Uplink::Send("CAPAB CAPABILITIES :PROTOCOL=1202"); - Uplink::Send("CAPAB END"); - SendServer(Me); -} - -void inspircd20::Proto::SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) -{ - Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); -} - -void inspircd20::Proto::SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) -{ - Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); -} - -void inspircd20::Proto::SendAkillDel(XLine *x) -{ - /* InspIRCd may support regex bans */ - if (x->IsRegex() && Servers::Capab.count("RLINE")) - { - Anope::string mask = x->GetMask(); - size_t h = mask.find('#'); - if (h != Anope::string::npos) - mask = mask.replace(h, 1, ' '); - SendDelLine("R", mask); - return; - } - else if (x->IsRegex() || x->HasNickOrReal()) - return; - - /* ZLine if we can instead */ - if (x->GetUser() == "*") - { - cidr addr(x->GetHost()); - if (addr.valid()) - { - IRCD->SendSZLineDel(x); - return; - } - } - - SendDelLine("G", x->GetUser() + "@" + x->GetHost()); -} - -void inspircd20::Proto::SendTopic(const MessageSource &source, Channel *c) -{ - if (Servers::Capab.count("SVSTOPIC")) - { - Uplink::Send(c->ci->WhoSends(), "SVSTOPIC", c->name, c->topic_ts, c->topic_setter, c->topic); - } - else - { - /* If the last time a topic was set is after the TS we want for this topic we must bump this topic's timestamp to now */ - time_t ts = c->topic_ts; - if (c->topic_time > ts) - ts = Anope::CurTime; - /* But don't modify c->topic_ts, it should remain set to the real TS we want as ci->last_topic_time pulls from it */ - Uplink::Send(source, "FTOPIC", c->name, ts, c->topic_setter, c->topic); - } -} - -void inspircd20::Proto::SendVhostDel(User *u) -{ - if (u->HasMode("CLOAK")) - this->SendChgHostInternal(u->nick, u->chost); - else - this->SendChgHostInternal(u->nick, u->host); - - if (Servers::Capab.count("CHGIDENT") && u->GetIdent() != u->GetVIdent()) - this->SendChgIdentInternal(u->nick, u->GetIdent()); -} - -void inspircd20::Proto::SendAkill(User *u, XLine *x) +void inspircd20::senders::Akill::Send(User* u, XLine* x) { // Calculate the time left before this would expire, capping it at 2 days time_t timeleft = x->GetExpires() - Anope::CurTime; @@ -173,7 +53,7 @@ void inspircd20::Proto::SendAkill(User *u, XLine *x) size_t h = mask.find('#'); if (h != Anope::string::npos) mask = mask.replace(h, 1, ' '); - SendAddLine("R", mask, timeleft, x->GetBy(), x->GetReason()); + proto->SendAddLine("R", mask, timeleft, x->GetBy(), x->GetReason()); return; } else if (x->IsRegex() || x->HasNickOrReal()) @@ -183,7 +63,7 @@ void inspircd20::Proto::SendAkill(User *u, XLine *x) /* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) if (x->GetManager()->Check(it->second, x)) - this->SendAkill(it->second, x); + this->Send(it->second, x); return; } @@ -209,70 +89,49 @@ void inspircd20::Proto::SendAkill(User *u, XLine *x) cidr addr(x->GetHost()); if (addr.valid()) { - IRCD->SendSZLine(u, x); + IRCD->Send<messages::SZLine>(u, x); return; } } - SendAddLine("G", x->GetUser() + "@" + x->GetHost(), timeleft, x->GetBy(), x->GetReason()); + proto->SendAddLine("G", x->GetUser() + "@" + x->GetHost(), timeleft, x->GetBy(), x->GetReason()); } -void inspircd20::Proto::SendNumeric(int numeric, User *dest, IRCMessage &message) +void inspircd20::senders::AkillDel::Send(XLine* x) { - std::vector<Anope::string> params = message.GetParameters(); - if (params.empty()) + /* InspIRCd may support regex bans */ + if (x->IsRegex() && Servers::Capab.count("RLINE")) + { + Anope::string mask = x->GetMask(); + size_t h = mask.find('#'); + if (h != Anope::string::npos) + mask = mask.replace(h, 1, ' '); + proto->SendDelLine("R", mask); + return; + } + else if (x->IsRegex() || x->HasNickOrReal()) return; - /* First parameter is the UID, change it to nick because it is pushed */ - params[0] = dest->nick; - - IRCMessage m(message.GetSource(), message.GetCommand()); - for (const Anope::string &s : params) - m.Push(s); - - Uplink::Send("PUSH", dest->GetUID(), Format(m)); -} - -void inspircd20::Proto::SendMode(const MessageSource &source, Channel *dest, const Anope::string &buf) -{ - IRCMessage message(source, "FMODE", dest->name, dest->creation_time); - message.TokenizeAndPush(buf); - Uplink::SendMessage(message); -} - -void inspircd20::Proto::SendClientIntroduction(User *u) -{ - Anope::string modes = "+" + u->GetModes(); - Uplink::Send(Me, "UID", u->GetUID(), u->timestamp, u->nick, u->host, u->host, u->GetIdent(), "0.0.0.0", u->timestamp, modes, u->realname); - if (modes.find('o') != Anope::string::npos) - Uplink::Send(u, "OPERTYPE", "services"); -} + /* ZLine if we can instead */ + if (x->GetUser() == "*") + { + cidr addr(x->GetHost()); + if (addr.valid()) + { + IRCD->Send<messages::SZLineDel>(x); + return; + } + } -/* SERVER services-dev.chatspike.net password 0 :Description here */ -void inspircd20::Proto::SendServer(Server *server) -{ - /* if rsquit is set then we are waiting on a squit */ - if (rsquit_id.empty() && rsquit_server.empty()) - Uplink::Send("SERVER", server->GetName(), Config->Uplinks[Anope::CurrentUplink].password, server->GetHops(), server->GetSID(), server->GetDescription()); + proto->SendDelLine("G", x->GetUser() + "@" + x->GetHost()); } -void inspircd20::Proto::SendSquit(Server *s, const Anope::string &message) +void inspircd20::senders::MessageChannel::Send(Channel* c) { - if (s != Me) - { - rsquit_id = s->GetSID(); - rsquit_server = s->GetName(); - - Uplink::Send("RSQUIT", s->GetName(), message); - } - else - { - Uplink::Send("SQUIT", s->GetName(), message); - } + Uplink::Send(Me, "FJOIN", c->name, c->creation_time, "+" + c->GetModes(true, true), ""); } -/* JOIN */ -void inspircd20::Proto::SendJoin(User *user, Channel *c, const ChannelStatus *status) +void inspircd20::senders::Join::Send(User* user, Channel* c, const ChannelStatus* status) { Uplink::Send(Me, "FJOIN", c->name, c->creation_time, "+" + c->GetModes(true, true), "," + user->GetUID()); @@ -300,159 +159,264 @@ void inspircd20::Proto::SendJoin(User *user, Channel *c, const ChannelStatus *st } } -/* UNSQLINE */ -void inspircd20::Proto::SendSQLineDel(XLine *x) +void inspircd20::senders::Login::Send(User *u, NickServ::Nick *na) { - SendDelLine("Q", x->GetMask()); + /* InspIRCd uses an account to bypass chmode +R, not umode +r, so we can't send this here */ + if (na->GetAccount()->IsUnconfirmed()) + return; + + Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", na->GetAccount()->GetDisplay()); } -/* SQLINE */ -void inspircd20::Proto::SendSQLine(User *, XLine *x) +void inspircd20::senders::Logout::Send(User *u) { - // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->GetExpires() - Anope::CurTime; - if (timeleft > 172800 || !x->GetExpires()) - timeleft = 172800; - SendAddLine("Q", x->GetMask(), timeleft, x->GetBy(), x->GetReason()); + Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", ""); } -void inspircd20::Proto::SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) +void inspircd20::senders::ModeChannel::Send(const MessageSource &source, Channel *channel, const Anope::string &modes) { - if (!vIdent.empty()) - this->SendChgIdentInternal(u->nick, vIdent); - if (!vhost.empty()) - this->SendChgHostInternal(u->nick, vhost); + IRCMessage message(source, "FMODE", channel->name, channel->creation_time); + message.TokenizeAndPush(modes); + Uplink::SendMessage(message); } -/* SVSHOLD - set */ -void inspircd20::Proto::SendSVSHold(const Anope::string &nick, time_t t) +void inspircd20::senders::NickIntroduction::Send(User *user) { - Uplink::Send(Config->GetClient("NickServ"), "SVSHOLD", nick, t, "Being held for registered user"); + Anope::string modes = "+" + user->GetModes(); + Uplink::Send(Me, "UID", user->GetUID(), user->timestamp, user->nick, user->host, user->host, user->GetIdent(), "0.0.0.0", user->timestamp, modes, user->realname); + if (modes.find('o') != Anope::string::npos) + Uplink::Send(user, "OPERTYPE", "services"); } -/* SVSHOLD - release */ -void inspircd20::Proto::SendSVSHoldDel(const Anope::string &nick) + +void inspircd20::senders::SASL::Send(const ::SASL::Message& message) { - Uplink::Send(Config->GetClient("NickServ"), "SVSHOLD", nick); + if (!message.ext.empty()) + Uplink::Send(Me, "ENCAP", message.target.substr(0, 3), "SASL", + message.source, message.target, + message.type, message.data, message.ext); + else + Uplink::Send(Me, "ENCAP", message.target.substr(0, 3), "SASL", + message.source, message.target, + message.type, message.data); } -/* UNSZLINE */ -void inspircd20::Proto::SendSZLineDel(XLine *x) +void inspircd20::senders::SASLMechanisms::Send(const std::vector<Anope::string>& mechanisms) { - SendDelLine("Z", x->GetHost()); + Anope::string mechlist; + for (unsigned int i = 0; i < mechanisms.size(); ++i) + mechlist += "," + mechanisms[i]; + + Uplink::Send(Me, "METADATA", "*", "saslmechlist", mechlist.empty() ? "" : mechlist.substr(1)); +} + +void inspircd20::senders::MessageServer::Send(Server* server) +{ + /* if rsquit is set then we are waiting on a squit */ + if (rsquit_id.empty() && rsquit_server.empty()) + Uplink::Send("SERVER", server->GetName(), Config->Uplinks[Anope::CurrentUplink].password, server->GetHops(), server->GetSID(), server->GetDescription()); } -/* SZLINE */ -void inspircd20::Proto::SendSZLine(User *, XLine *x) +void inspircd20::senders::SQLine::Send(User*, XLine* x) { // Calculate the time left before this would expire, capping it at 2 days time_t timeleft = x->GetExpires() - Anope::CurTime; if (timeleft > 172800 || !x->GetExpires()) timeleft = 172800; - SendAddLine("Z", x->GetHost(), timeleft, x->GetBy(), x->GetReason()); + proto->SendAddLine("Q", x->GetMask(), timeleft, x->GetBy(), x->GetReason()); } -void inspircd20::Proto::SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) +void inspircd20::senders::SQLineDel::Send(XLine* x) { - Uplink::Send(source, "SVSJOIN", u->GetUID(), chan); + proto->SendDelLine("Q", x->GetMask()); } -void inspircd20::Proto::SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) +void inspircd20::senders::SQuit::Send(Server *s, const Anope::string &message) { - if (!param.empty()) - Uplink::Send(source, "SVSPART", u->GetUID(), chan, param); + if (s != Me) + { + rsquit_id = s->GetSID(); + rsquit_server = s->GetName(); + + Uplink::Send("RSQUIT", s->GetName(), message); + } else - Uplink::Send(source, "SVSPART", u->GetUID(), chan); + { + Uplink::Send("SQUIT", s->GetName(), message); + } } -void inspircd20::Proto::SendSWhois(const MessageSource &, const Anope::string &who, const Anope::string &mask) +void inspircd20::senders::SZLine::Send(User*, XLine* x) { - User *u = User::Find(who); + // Calculate the time left before this would expire, capping it at 2 days + time_t timeleft = x->GetExpires() - Anope::CurTime; + if (timeleft > 172800 || !x->GetExpires()) + timeleft = 172800; + proto->SendAddLine("Z", x->GetHost(), timeleft, x->GetBy(), x->GetReason()); +} - Uplink::Send(Me, "METADATA", u->GetUID(), "swhois", mask); +void inspircd20::senders::SZLineDel::Send(XLine* x) +{ + proto->SendDelLine("Z", x->GetHost()); } -void inspircd20::Proto::SendBOB() +void inspircd20::senders::SVSHold::Send(const Anope::string& nick, time_t t) { - Uplink::Send(Me, "BURST", Anope::CurTime); - Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); - Uplink::Send(Me, "VERSION", Anope::Format("Anope-{0} {1} {2} - {3} - Built: {4} - Flags: {5}", - Anope::Version(), Me->GetName(), IRCD->GetProtocolName(), enc ? enc->name : "(none)", Anope::VersionBuildTime(), Anope::VersionFlags())); + Uplink::Send(Config->GetClient("NickServ"), "SVSHOLD", nick, t, "Being held for registered user"); } -void inspircd20::Proto::SendEOB() +void inspircd20::senders::SVSHoldDel::Send(const Anope::string& nick) { - Uplink::Send(Me, "ENDBURST"); + Uplink::Send(Config->GetClient("NickServ"), "SVSHOLD", nick); } -void inspircd20::Proto::SendGlobops(const MessageSource &source, const Anope::string &buf) +void inspircd20::senders::SVSLogin::Send(const Anope::string& uid, const Anope::string& acc, const Anope::string& vident, const Anope::string& vhost) { - if (Servers::Capab.count("GLOBOPS")) - Uplink::Send(source, "SNONOTICE", "g", buf); - else - Uplink::Send(source, "SNONOTICE", "A", buf); + Uplink::Send(Me, "METADATA", uid, "accountname", acc); + + SASLUser su; + su.uid = uid; + su.acc = acc; + su.created = Anope::CurTime; + + for (std::list<SASLUser>::iterator it = saslusers.begin(); it != saslusers.end();) + { + SASLUser &u = *it; + + if (u.created + 30 < Anope::CurTime || u.uid == uid) + it = saslusers.erase(it); + else + ++it; + } + + saslusers.push_back(su); } -void inspircd20::Proto::SendLogin(User *u, NickServ::Nick *na) +void inspircd20::senders::SWhois::Send(const MessageSource&, User *user, const Anope::string& swhois) { - /* InspIRCd uses an account to bypass chmode +R, not umode +r, so we can't send this here */ - if (na->GetAccount()->IsUnconfirmed()) - return; + Uplink::Send(Me, "METADATA", user->GetUID(), "swhois", swhois); +} - Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", na->GetAccount()->GetDisplay()); +void inspircd20::senders::Topic::Send(const MessageSource &source, Channel *channel, const Anope::string &topic, time_t topic_ts, const Anope::string &topic_setter) +{ + if (Servers::Capab.count("SVSTOPIC")) + { + Uplink::Send(source, "SVSTOPIC", channel->name, topic_ts, topic_setter, topic); + } + else + { + /* If the last time a topic was set is after the TS we want for this topic we must bump this topic's timestamp to now */ + time_t ts = topic_ts; + if (channel->topic_time > ts) + ts = Anope::CurTime; + /* But don't modify c->topic_ts, it should remain set to the real TS we want as ci->last_topic_time pulls from it */ + Uplink::Send(source, "FTOPIC", channel->name, ts, topic_setter, topic); + } } -void inspircd20::Proto::SendLogout(User *u) +void inspircd20::senders::VhostDel::Send(User* u) { - Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", ""); + if (u->HasMode("CLOAK")) + proto->SendChgHostInternal(u->nick, u->chost); + else + proto->SendChgHostInternal(u->nick, u->host); + + if (Servers::Capab.count("CHGIDENT") && u->GetIdent() != u->GetVIdent()) + proto->SendChgIdentInternal(u->nick, u->GetIdent()); } -void inspircd20::Proto::SendChannel(Channel *c) +void inspircd20::senders::VhostSet::Send(User* u, const Anope::string& vident, const Anope::string& vhost) { - Uplink::Send(Me, "FJOIN", c->name, c->creation_time, "+" + c->GetModes(true, true), ""); + if (!vident.empty()) + proto->SendChgIdentInternal(u->nick, vident); + if (!vhost.empty()) + proto->SendChgHostInternal(u->nick, vhost); } -void inspircd20::Proto::SendSASLMechanisms(std::vector<Anope::string> &mechanisms) +void inspircd20::senders::Wallops::Send(const MessageSource &source, const Anope::string &msg) { - Anope::string mechlist; - for (unsigned i = 0; i < mechanisms.size(); ++i) - mechlist += "," + mechanisms[i]; + if (Servers::Capab.count("GLOBOPS")) + Uplink::Send(source, "SNONOTICE", "g", msg); + else + Uplink::Send(source, "SNONOTICE", "A", msg); +} - Uplink::Send(Me, "METADATA", "*", "saslmechlist", mechlist.empty() ? "" : mechlist.substr(1)); +void inspircd20::Proto::SendChgIdentInternal(const Anope::string &nick, const Anope::string &vIdent) +{ + if (!Servers::Capab.count("CHGIDENT")) + Log() << "CHGIDENT not loaded!"; + else + Uplink::Send(Me, "CHGIDENT", nick, vIdent); } -void inspircd20::Proto::SendSASLMessage(const SASL::Message &message) +void inspircd20::Proto::SendChgHostInternal(const Anope::string &nick, const Anope::string &vhost) { - if (!message.ext.empty()) - Uplink::Send(Me, "ENCAP", message.target.substr(0, 3), "SASL", - message.source, message.target, - message.type, message.data, message.ext); + if (!Servers::Capab.count("CHGHOST")) + Log() << "CHGHOST not loaded!"; else - Uplink::Send(Me, "ENCAP", message.target.substr(0, 3), "SASL", - message.source, message.target, - message.type, message.data); + Uplink::Send(Me, "CHGHOST", nick, vhost); } -void inspircd20::Proto::SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) +void inspircd20::Proto::SendAddLine(const Anope::string &xtype, const Anope::string &mask, time_t duration, const Anope::string &addedby, const Anope::string &reason) { - Uplink::Send(Me, "METADATA", uid, "accountname", acc); + Uplink::Send(Me, "ADDLINE", xtype, mask, addedby, Anope::CurTime, duration, reason); +} - SASLUser su; - su.uid = uid; - su.acc = acc; - su.created = Anope::CurTime; +void inspircd20::Proto::SendDelLine(const Anope::string &xtype, const Anope::string &mask) +{ + Uplink::Send(Me, "DELLINE", xtype, mask); +} - for (std::list<SASLUser>::iterator it = saslusers.begin(); it != saslusers.end();) - { - SASLUser &u = *it; +inspircd20::Proto::Proto(Module *creator) : ts6::Proto(creator, "InspIRCd 2.0") +{ + DefaultPseudoclientModes = "+I"; + CanSVSNick = true; + CanSVSJoin = true; + CanSetVHost = true; + CanSetVIdent = true; + CanSQLine = true; + CanSZLine = true; + CanSVSHold = true; + CanCertFP = true; + RequiresID = true; + MaxModes = 20; +} - if (u.created + 30 < Anope::CurTime || u.uid == uid) - it = saslusers.erase(it); - else - ++it; - } +void inspircd20::Proto::Handshake() +{ + Uplink::Send("CAPAB START 1202"); + Uplink::Send("CAPAB CAPABILITIES :PROTOCOL=1202"); + Uplink::Send("CAPAB END"); + IRCD->Send<messages::MessageServer>(Me); +} - saslusers.push_back(su); +void inspircd20::Proto::SendNumeric(int numeric, User *dest, IRCMessage &message) +{ + std::vector<Anope::string> params = message.GetParameters(); + if (params.empty()) + return; + + /* First parameter is the UID, change it to nick because it is pushed */ + params[0] = dest->nick; + + IRCMessage m(message.GetSource(), message.GetCommand()); + for (const Anope::string &s : params) + m.Push(s); + + Uplink::Send("PUSH", dest->GetUID(), Format(m)); +} + +void inspircd20::Proto::SendBOB() +{ + Uplink::Send(Me, "BURST", Anope::CurTime); + Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); + Uplink::Send(Me, "VERSION", Anope::Format("Anope-{0} {1} {2} - {3} - Built: {4} - Flags: {5}", + Anope::Version(), Me->GetName(), IRCD->GetProtocolName(), enc ? enc->name : "(none)", Anope::VersionBuildTime(), Anope::VersionFlags())); +} + +void inspircd20::Proto::SendEOB() +{ + Uplink::Send(Me, "ENDBURST"); } bool inspircd20::Proto::IsExtbanValid(const Anope::string &mask) @@ -1162,8 +1126,9 @@ void inspircd20::Save::Run(MessageSource &source, const std::vector<Anope::strin return; } - IRCD->SendKill(Me, targ->nick, "Nick collision"); - IRCD->SendNickChange(targ, targ->nick); + IRCD->Send<messages::Kill>(Me, targ->nick, "Nick collision"); + IRCD->Send<messages::NickChange>(targ, targ->nick, Anope::CurTime); + targ->timestamp = Anope::CurTime; last_collide = Anope::CurTime; } else @@ -1202,7 +1167,7 @@ void inspircd20::SQuit::Run(MessageSource &source, const std::vector<Anope::stri rsquit_server.clear(); if (s && s->IsJuped()) - IRCD->SendServer(s); + IRCD->Send<messages::MessageServer>(s); } else rfc1459::SQuit::Run(source, params); @@ -1318,6 +1283,49 @@ class ProtoInspIRCd20 : public Module inspircd20::Time message_time; inspircd20::UID message_uid; + rfc1459::senders::GlobalNotice sender_global_notice; + rfc1459::senders::GlobalPrivmsg sender_global_privmsg; + rfc1459::senders::Invite sender_invite; + rfc1459::senders::Kick sender_kick; + rfc1459::senders::Kill sender_svskill; + rfc1459::senders::ModeChannel sender_mode_chan; + rfc1459::senders::ModeUser sender_mode_user; + rfc1459::senders::NickChange sender_nickchange; + rfc1459::senders::Notice sender_notice; + rfc1459::senders::Part sender_part; + rfc1459::senders::Ping sender_ping; + rfc1459::senders::Pong sender_pong; + rfc1459::senders::Privmsg sender_privmsg; + rfc1459::senders::Quit sender_quit; + + hybrid::senders::SVSJoin sender_svsjoin; + hybrid::senders::SVSPart sender_svspart; + + bahamut::senders::SVSNick sender_svsnick; + + inspircd20::senders::Akill sender_akill; + inspircd20::senders::AkillDel sender_akill_del; + inspircd20::senders::MessageChannel sender_channel; + inspircd20::senders::Login sender_login; + inspircd20::senders::Logout sender_logout; + inspircd20::senders::NickIntroduction sender_nickintroduction; + inspircd20::senders::MessageServer sender_server; + inspircd20::senders::SASL sender_sasl; + inspircd20::senders::SASLMechanisms sender_sasl_mechs; + inspircd20::senders::SQLine sender_sqline; + inspircd20::senders::SQLineDel sender_sqline_del; + inspircd20::senders::SQuit sender_squit; + inspircd20::senders::SZLine sender_szline; + inspircd20::senders::SZLineDel sender_szline_del; + inspircd20::senders::SVSHold sender_svshold; + inspircd20::senders::SVSHoldDel sender_svsholddel; + inspircd20::senders::SVSLogin sender_svslogin; + inspircd20::senders::SWhois sender_swhois; + inspircd20::senders::Topic sender_topic; + inspircd20::senders::VhostDel sender_vhost_del; + inspircd20::senders::VhostSet sender_vhost_set; + inspircd20::senders::Wallops sender_wallops; + bool use_server_side_topiclock, use_server_side_mlock; void SendChannelMetadata(Channel *c, const Anope::string &metadataname, const Anope::string &value) @@ -1336,6 +1344,7 @@ class ProtoInspIRCd20 : public Module , ircd_proto(this) , ssl(this, "ssl") + , message_away(this) , message_error(this) , message_invite(this) @@ -1373,7 +1382,53 @@ class ProtoInspIRCd20 : public Module , message_squit(this) , message_time(this) , message_uid(this) + + , sender_akill(this, &ircd_proto) + , sender_akill_del(this, &ircd_proto) + , sender_channel(this) + , sender_global_notice(this) + , sender_global_privmsg(this) + , sender_invite(this) + , sender_kick(this) + , sender_svskill(this) + , sender_login(this) + , sender_logout(this) + , sender_mode_chan(this) + , sender_mode_user(this) + , sender_nickchange(this) + , sender_nickintroduction(this) + , sender_notice(this) + , sender_part(this) + , sender_ping(this) + , sender_pong(this) + , sender_privmsg(this) + , sender_quit(this) + , sender_server(this) + , sender_sasl(this) + , sender_sasl_mechs(this) + , sender_sqline(this, &ircd_proto) + , sender_sqline_del(this, &ircd_proto) + , sender_squit(this) + , sender_szline(this, &ircd_proto) + , sender_szline_del(this, &ircd_proto) + , sender_svshold(this) + , sender_svsholddel(this) + , sender_svslogin(this) + , sender_svsjoin(this) + , sender_svsnick(this) + , sender_svspart(this) + , sender_swhois(this) + , sender_topic(this) + , sender_vhost_del(this, &ircd_proto) + , sender_vhost_set(this, &ircd_proto) + , sender_wallops(this) + { + IRCD = &ircd_proto; + } + + ~ProtoInspIRCd20() { + IRCD = nullptr; } void OnReload(Configuration::Conf *conf) override |