diff options
-rw-r--r-- | include/modules/protocol/bahamut.h | 60 | ||||
-rw-r--r-- | include/modules/protocol/charybdis.h | 46 | ||||
-rw-r--r-- | include/modules/protocol/hybrid.h | 68 | ||||
-rw-r--r-- | include/modules/protocol/inspircd20.h | 85 | ||||
-rw-r--r-- | include/modules/protocol/ngircd.h | 46 | ||||
-rw-r--r-- | include/modules/protocol/plexus.h | 48 | ||||
-rw-r--r-- | include/modules/protocol/ratbox.h | 39 | ||||
-rw-r--r-- | include/modules/protocol/unreal.h | 77 | ||||
-rw-r--r-- | modules/protocol/bahamut.cpp | 452 | ||||
-rw-r--r-- | modules/protocol/charybdis.cpp | 222 | ||||
-rw-r--r-- | modules/protocol/hybrid.cpp | 499 | ||||
-rw-r--r-- | modules/protocol/inspircd20.cpp | 723 | ||||
-rw-r--r-- | modules/protocol/ngircd.cpp | 236 | ||||
-rw-r--r-- | modules/protocol/plexus.cpp | 266 | ||||
-rw-r--r-- | modules/protocol/ratbox.cpp | 216 | ||||
-rw-r--r-- | modules/protocol/unreal.cpp | 660 |
16 files changed, 2060 insertions, 1683 deletions
diff --git a/include/modules/protocol/bahamut.h b/include/modules/protocol/bahamut.h index 634360f99..f120c7d4c 100644 --- a/include/modules/protocol/bahamut.h +++ b/include/modules/protocol/bahamut.h @@ -22,6 +22,64 @@ namespace bahamut { +class Proto : public IRCDProto +{ + public: + Proto(Module *creator); + + void SendMode(const MessageSource &source, Channel *dest, const Anope::string &buf) override; + + void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override; + + void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override; + + void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override; + + void SendSVSHold(const Anope::string &nick, time_t time) override; + + void SendSVSHoldDel(const Anope::string &nick) override; + + void SendSQLine(User *, XLine *x) override; + + void SendSGLineDel(XLine *x) override; + + void SendSZLineDel(XLine *x) override; + + void SendSZLine(User *, XLine *x) override; + + void SendSVSNOOP(Server *server, bool set) override; + + void SendSGLine(User *, XLine *x) override; + + void SendAkillDel(XLine *x) override; + + void SendTopic(const MessageSource &source, Channel *c) override; + + void SendSQLineDel(XLine *x) override; + + void SendJoin(User *user, Channel *c, const ChannelStatus *status) override; + + void SendAkill(User *u, XLine *x) override; + + void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override; + + void SendBOB() override; + + void SendEOB() override; + + void SendClientIntroduction(User *u) override; + + void SendServer(Server *server) override; + + void SendConnect() override; + + void SendChannel(Channel *c) override; + + void SendLogin(User *u, NickServ::Nick *) override; + + void SendLogout(User *u) override; +}; + class Burst : public IRCDMessage { public: @@ -70,4 +128,4 @@ class Topic : public IRCDMessage void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; }; -} // namespace bahamut
\ No newline at end of file +} // namespace bahamut diff --git a/include/modules/protocol/charybdis.h b/include/modules/protocol/charybdis.h index d65e094a0..ee81a60a1 100644 --- a/include/modules/protocol/charybdis.h +++ b/include/modules/protocol/charybdis.h @@ -22,6 +22,52 @@ namespace charybdis { +class Proto : public IRCDProto +{ + ServiceReference<IRCDProto> ratbox; // XXX + + public: + Proto(Module *creator); + + void SendSVSKill(const MessageSource &source, User *targ, const Anope::string &reason) override { ratbox->SendSVSKill(source, targ, reason); } + void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override { ratbox->SendGlobalNotice(bi, dest, msg); } + void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override { ratbox->SendGlobalPrivmsg(bi, dest, msg); } + void SendGlobops(const MessageSource &source, const Anope::string &buf) override { ratbox->SendGlobops(source, buf); } + void SendSGLine(User *u, XLine *x) override { ratbox->SendSGLine(u, x); } + void SendSGLineDel(XLine *x) override { ratbox->SendSGLineDel(x); } + void SendAkill(User *u, XLine *x) override { ratbox->SendAkill(u, x); } + void SendAkillDel(XLine *x) override { ratbox->SendAkillDel(x); } + void SendSQLine(User *u, XLine *x) override { ratbox->SendSQLine(u, x); } + void SendSQLineDel(XLine *x) override { ratbox->SendSQLineDel(x); } + void SendJoin(User *user, Channel *c, const ChannelStatus *status) override { ratbox->SendJoin(user, c, status); } + void SendServer(Server *server) override { ratbox->SendServer(server); } + void SendChannel(Channel *c) override { ratbox->SendChannel(c); } + void SendTopic(const MessageSource &source, Channel *c) override { ratbox->SendTopic(source, c); } + bool IsIdentValid(const Anope::string &ident) override { return ratbox->IsIdentValid(ident); } + void SendLogin(User *u, NickServ::Nick *na) override { ratbox->SendLogin(u, na); } + void SendLogout(User *u) override { ratbox->SendLogout(u); } + + void SendConnect() override; + + void SendClientIntroduction(User *u) override; + + void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override; + + void SendSVSHold(const Anope::string &nick, time_t delay) override; + + void SendSVSHoldDel(const Anope::string &nick) override; + + void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) override; + + void SendVhostDel(User *u) override; + + void SendSASLMechanisms(std::vector<Anope::string> &mechanisms) override; + + void SendSASLMessage(const SASL::Message &message) override; + + void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) override; +}; + class Encap : public IRCDMessage { ServiceReference<SASL::Service> sasl; diff --git a/include/modules/protocol/hybrid.h b/include/modules/protocol/hybrid.h index 943480f54..a0a9143a8 100644 --- a/include/modules/protocol/hybrid.h +++ b/include/modules/protocol/hybrid.h @@ -24,6 +24,74 @@ namespace hybrid { +class Proto : public IRCDProto +{ + ServiceBot *FindIntroduced(); + + void SendSVSKill(const MessageSource &source, User *u, const Anope::string &buf) override; + + public: + Proto(Module *creator); + + void SendInvite(const MessageSource &source, Channel *c, User *u) override; + + void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override; + + void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override; + + void SendSQLine(User *, XLine *x) override; + + void SendSGLineDel(XLine *x) override; + + void SendSGLine(User *, XLine *x) override; + + void SendSZLineDel(XLine *x) override; + + void SendSZLine(User *, XLine *x) override; + + void SendAkillDel(XLine *x) override; + + void SendSQLineDel(XLine *x) override; + + void SendJoin(User *u, Channel *c, const ChannelStatus *status) override; + + void SendAkill(User *u, XLine *x) override; + + void SendServer(Server *server) override; + + void SendConnect() override; + + void SendClientIntroduction(User *u) override; + + void SendEOB() override; + + void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override; + + void SendLogin(User *u, NickServ::Nick *na) override; + + void SendLogout(User *u) override; + + void SendChannel(Channel *c) override; + + void SendTopic(const MessageSource &source, Channel *c) override; + + void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override; + + void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) override; + + void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) override; + + void SendSVSHold(const Anope::string &nick, time_t t) override; + + void SendSVSHoldDel(const Anope::string &nick) override; + + void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) override; + + void SendVhostDel(User *u) override; + + bool IsIdentValid(const Anope::string &ident) override; +}; + class BMask : public IRCDMessage { public: diff --git a/include/modules/protocol/inspircd20.h b/include/modules/protocol/inspircd20.h index 9489353d0..f2126a931 100644 --- a/include/modules/protocol/inspircd20.h +++ b/include/modules/protocol/inspircd20.h @@ -22,6 +22,91 @@ namespace inspircd20 { +class Proto : public IRCDProto +{ + private: + void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override; + + void SendChgIdentInternal(const Anope::string &nick, const Anope::string &vIdent); + + void SendChgHostInternal(const Anope::string &nick, const Anope::string &vhost); + + void SendAddLine(const Anope::string &xtype, const Anope::string &mask, time_t duration, const Anope::string &addedby, const Anope::string &reason); + + void SendDelLine(const Anope::string &xtype, const Anope::string &mask); + + public: + Proto(Module *creator); + + void SendConnect() override; + + void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override; + + void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override; + + void SendAkillDel(XLine *x) override; + + void SendTopic(const MessageSource &source, Channel *c) override; + + void SendVhostDel(User *u) override; + + void SendAkill(User *u, XLine *x) override; + + void SendNumeric(int numeric, User *dest, IRCMessage &message); + + void SendMode(const MessageSource &source, Channel *dest, const Anope::string &buf) override; + + void SendClientIntroduction(User *u) override; + + void SendServer(Server *server) override; + + void SendSquit(Server *s, const Anope::string &message) override; + + void SendJoin(User *user, Channel *c, const ChannelStatus *status) override; + + void SendSQLineDel(XLine *x) override; + + void SendSQLine(User *, XLine *x) override; + + void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) override; + + void SendSVSHold(const Anope::string &nick, time_t t) override; + + void SendSVSHoldDel(const Anope::string &nick) override; + + void SendSZLineDel(XLine *x) override; + + void SendSZLine(User *, XLine *x) override; + + void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) override; + + void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) override; + + void SendSWhois(const MessageSource &, const Anope::string &who, const Anope::string &mask) override; + + void SendBOB() override; + + void SendEOB() override; + + void SendGlobops(const MessageSource &source, const Anope::string &buf) override; + + void SendLogin(User *u, NickServ::Nick *na) override; + + void SendLogout(User *u) override; + + void SendChannel(Channel *c) override; + + void SendSASLMechanisms(std::vector<Anope::string> &mechanisms) override; + + void SendSASLMessage(const SASL::Message &message) override; + + void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) override; + + bool IsExtbanValid(const Anope::string &mask) override; + + bool IsIdentValid(const Anope::string &ident) override; +}; + class Capab : public rfc1459::Capab { public: diff --git a/include/modules/protocol/ngircd.h b/include/modules/protocol/ngircd.h index 0bfebea9f..fef637aca 100644 --- a/include/modules/protocol/ngircd.h +++ b/include/modules/protocol/ngircd.h @@ -23,6 +23,50 @@ namespace ngircd { +class Proto : public IRCDProto +{ + void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override; + + public: + Proto(Module *creator); + + void SendAkill(User *u, XLine *x) override; + + void SendAkillDel(XLine *x) override; + + void SendChannel(Channel *c) override; + + // Received: :dev.anope.de NICK DukeP 1 ~DukePyro p57ABF9C9.dip.t-dialin.net 1 +i :DukePyrolator + void SendClientIntroduction(User *u) override; + + void SendConnect() override; + + void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override; + + void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override; + + void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override; + + void SendGlobops(const MessageSource &source, const Anope::string &buf) override; + + void SendJoin(User *user, Channel *c, const ChannelStatus *status) override; + + void SendLogin(User *u, NickServ::Nick *na) override; + + void SendLogout(User *u) override; + + /* SERVER name hop descript */ + void SendServer(Server *server) override; + + void SendTopic(const MessageSource &source, Channel *c) override; + + void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) override; + + void SendVhostDel(User *u) override; + + Anope::string Format(IRCMessage &message) override; +}; + class Numeric005 : public IRCDMessage { public: @@ -92,7 +136,7 @@ struct Nick : public IRCDMessage class NJoin : public IRCDMessage { public: - NJoin(Module *creator) : IRCDMessage(creator, "NJOIN",2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }; + NJoin(Module *creator) : IRCDMessage(creator, "NJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }; /* * RFC 2813, 4.2.2: Njoin Message: diff --git a/include/modules/protocol/plexus.h b/include/modules/protocol/plexus.h index 0c5d8d8c0..69be3d713 100644 --- a/include/modules/protocol/plexus.h +++ b/include/modules/protocol/plexus.h @@ -22,6 +22,54 @@ namespace plexus { +class Proto : public IRCDProto +{ + ServiceReference<IRCDProto> hybrid; // XXX use moddeps + inheritance here + + public: + Proto(Module *creator); + + void SendSVSKill(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKill(source, targ, reason); } + void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override { hybrid->SendGlobalNotice(bi, dest, msg); } + void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override { hybrid->SendGlobalPrivmsg(bi, dest, msg); } + void SendSQLine(User *u, XLine *x) override { hybrid->SendSQLine(u, x); } + void SendSQLineDel(XLine *x) override { hybrid->SendSQLineDel(x); } + void SendSGLineDel(XLine *x) override { hybrid->SendSGLineDel(x); } + void SendSGLine(User *u, XLine *x) override { hybrid->SendSGLine(u, x); } + void SendAkillDel(XLine *x) override { hybrid->SendAkillDel(x); } + void SendAkill(User *u, XLine *x) override { hybrid->SendAkill(u, x); } + void SendServer(Server *server) override { hybrid->SendServer(server); } + void SendChannel(Channel *c) override { hybrid->SendChannel(c); } + void SendSVSHold(const Anope::string &nick, time_t t) override { hybrid->SendSVSHold(nick, t); } + void SendSVSHoldDel(const Anope::string &nick) override { hybrid->SendSVSHoldDel(nick); } + + void SendGlobops(const MessageSource &source, const Anope::string &buf) override; + + void SendJoin(User *user, Channel *c, const ChannelStatus *status) override; + + void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override; + + void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) override; + + void SendVhostDel(User *u) override; + + void SendConnect() override; + + void SendClientIntroduction(User *u) override; + + void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override; + + void SendLogin(User *u, NickServ::Nick *na) override; + + void SendLogout(User *u) override; + + void SendTopic(const MessageSource &source, Channel *c) override; + + void SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) override; + + void SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) override; +}; + class Encap : public IRCDMessage { public: diff --git a/include/modules/protocol/ratbox.h b/include/modules/protocol/ratbox.h index 2ad4a5529..ba7a7f19f 100644 --- a/include/modules/protocol/ratbox.h +++ b/include/modules/protocol/ratbox.h @@ -24,6 +24,45 @@ namespace ratbox { +class Proto : public IRCDProto +{ + ServiceReference<IRCDProto> hybrid; // XXX + + ServiceBot *FindIntroduced(); + + public: + Proto(Module *creator); + + void SendSVSKill(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKill(source, targ, reason); } + void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override { hybrid->SendGlobalNotice(bi, dest, msg); } + void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override { hybrid->SendGlobalPrivmsg(bi, dest, msg); } + void SendSGLine(User *u, XLine *x) override { hybrid->SendSGLine(u, x); } + void SendSGLineDel(XLine *x) override { hybrid->SendSGLineDel(x); } + void SendAkill(User *u, XLine *x) override { hybrid->SendAkill(u, x); } + void SendAkillDel(XLine *x) override { hybrid->SendAkillDel(x); } + void SendJoin(User *user, Channel *c, const ChannelStatus *status) override { hybrid->SendJoin(user, c, status); } + void SendServer(Server *server) override { hybrid->SendServer(server); } + void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override { hybrid->SendMode(source, u, buf); } + void SendChannel(Channel *c) override { hybrid->SendChannel(c); } + bool IsIdentValid(const Anope::string &ident) override { return hybrid->IsIdentValid(ident); } + + void SendGlobops(const MessageSource &source, const Anope::string &buf) override; + + void SendConnect() override; + + void SendClientIntroduction(User *u) override; + + void SendLogin(User *u, NickServ::Nick *na) override; + + void SendLogout(User *u) override; + + void SendTopic(const MessageSource &source, Channel *c) override; + + void SendSQLine(User *, XLine *x) override; + + void SendSQLineDel(XLine *x) override; +}; + class Encap : public IRCDMessage { public: diff --git a/include/modules/protocol/unreal.h b/include/modules/protocol/unreal.h index 88ed05997..0a01cb4be 100644 --- a/include/modules/protocol/unreal.h +++ b/include/modules/protocol/unreal.h @@ -22,6 +22,83 @@ namespace unreal { +class Proto : public IRCDProto +{ + public: + Proto(Module *creator); + + private: + void SendSVSNOOP(Server *server, bool set) override; + + void SendAkillDel(XLine *x) override; + + void SendTopic(const MessageSource &source, Channel *c) override; + + void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override; + + void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override; + + void SendVhostDel(User *u) override; + + void SendAkill(User *u, XLine *x) override; + + void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override; + + void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override; + + void SendClientIntroduction(User *u) override; + + void SendServer(Server *server) override; + + void SendJoin(User *user, Channel *c, const ChannelStatus *status) override; + + void SendSQLineDel(XLine *x) override; + + void SendSQLine(User *, XLine *x) override; + + void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) override; + + void SendConnect() override; + + void SendSVSHold(const Anope::string &nick, time_t t) override; + + void SendSVSHoldDel(const Anope::string &nick) override; + + void SendSGLineDel(XLine *x) override; + + void SendSZLineDel(XLine *x) override; + + void SendSZLine(User *, XLine *x) override; + + void SendSGLine(User *, XLine *x) override; + + void SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) override; + + void SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) override; + + void SendSWhois(const MessageSource &source, const Anope::string &who, const Anope::string &mask) override; + + void SendEOB() override; + + bool IsNickValid(const Anope::string &nick) override; + + bool IsChannelValid(const Anope::string &chan) override; + + bool IsExtbanValid(const Anope::string &mask) override; + + void SendLogin(User *u, NickServ::Nick *na) override; + + void SendLogout(User *u) override; + + void SendChannel(Channel *c) override; + + void SendSASLMessage(const ::SASL::Message &message) override; + + void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) override; + + bool IsIdentValid(const Anope::string &ident) override; +}; + class ChgHost : public IRCDMessage { public: diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 7ab9dd9b2..46ffb3ea2 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -42,281 +42,277 @@ class ChannelModeFlood : public ChannelModeParam } }; -class BahamutIRCdProto : public IRCDProto +bahamut::Proto::Proto(Module *creator) : IRCDProto(creator, "Bahamut 1.8.x") { - public: - BahamutIRCdProto(Module *creator) : IRCDProto(creator, "Bahamut 1.8.x") - { - DefaultPseudoclientModes = "+"; - CanSVSNick = true; - CanSNLine = true; - CanSQLine = true; - CanSQLineChannel = true; - CanSZLine = true; - CanSVSHold = true; - MaxModes = 60; - } - - void SendMode(const MessageSource &source, Channel *dest, const Anope::string &buf) override - { - if (Servers::Capab.count("TSMODE") > 0) - { - IRCMessage message(source, "MODE", dest->name, dest->creation_time); - message.TokenizeAndPush(buf); - Uplink::SendMessage(message); - } - else - { - IRCDProto::SendMode(source, dest, buf); - } - } + DefaultPseudoclientModes = "+"; + CanSVSNick = true; + CanSNLine = true; + CanSQLine = true; + CanSQLineChannel = true; + CanSZLine = true; + CanSVSHold = true; + MaxModes = 60; +} - void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override +void bahamut::Proto::SendMode(const MessageSource &source, Channel *dest, const Anope::string &buf) +{ + if (Servers::Capab.count("TSMODE") > 0) { - IRCMessage message(source, "SVSMODE", u->nick, u->timestamp); + IRCMessage message(source, "MODE", dest->name, dest->creation_time); message.TokenizeAndPush(buf); Uplink::SendMessage(message); } - - void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override + else { - Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); + IRCDProto::SendMode(source, dest, buf); } +} - void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); - } +void bahamut::Proto::SendMode(const MessageSource &source, User *u, const Anope::string &buf) +{ + IRCMessage message(source, "SVSMODE", u->nick, u->timestamp); + message.TokenizeAndPush(buf); + Uplink::SendMessage(message); +} - /* SVSHOLD - set */ - void SendSVSHold(const Anope::string &nick, time_t time) override - { - Uplink::Send(Me, "SVSHOLD", nick, time, "Being held for registered user"); - } +void bahamut::Proto::SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); +} - /* SVSHOLD - release */ - void SendSVSHoldDel(const Anope::string &nick) override - { - Uplink::Send(Me, "SVSHOLD", nick, 0); - } +void bahamut::Proto::SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); +} - /* SQLINE */ - void SendSQLine(User *, XLine *x) override - { - Uplink::Send(Me, "SQLINE", x->GetMask(), x->GetReason()); - } +/* SVSHOLD - set */ +void bahamut::Proto::SendSVSHold(const Anope::string &nick, time_t time) +{ + Uplink::Send(Me, "SVSHOLD", nick, time, "Being held for registered user"); +} - /* UNSLINE */ - void SendSGLineDel(XLine *x) override - { - Uplink::Send("UNSGLINE", 0, x->GetMask()); - } +/* SVSHOLD - release */ +void bahamut::Proto::SendSVSHoldDel(const Anope::string &nick) +{ + Uplink::Send(Me, "SVSHOLD", nick, 0); +} - /* UNSZLINE */ - void SendSZLineDel(XLine *x) override - { - /* this will likely fail so its only here for legacy */ - Uplink::Send("UNSZLINE", 0, x->GetHost()); - /* this is how we are supposed to deal with it */ - Uplink::Send("RAKILL", x->GetHost(), "*"); - } +/* SQLINE */ +void bahamut::Proto::SendSQLine(User *, XLine *x) +{ + Uplink::Send(Me, "SQLINE", x->GetMask(), x->GetReason()); +} - /* SZLINE */ - void SendSZLine(User *, XLine *x) override - { - // 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; - /* this will likely fail so its only here for legacy */ - Uplink::Send("SZLINE", x->GetHost(), x->GetReason()); - /* this is how we are supposed to deal with it */ - Uplink::Send("AKILL", x->GetHost(), "*", timeleft, x->GetBy(), Anope::CurTime, x->GetReason()); - } +/* UNSLINE */ +void bahamut::Proto::SendSGLineDel(XLine *x) +{ + Uplink::Send("UNSGLINE", 0, x->GetMask()); +} - /* SVSNOOP */ - void SendSVSNOOP(Server *server, bool set) override - { - Uplink::Send("SVSNOOP", server->GetName(), set ? "+" : "-"); - } +/* UNSZLINE */ +void bahamut::Proto::SendSZLineDel(XLine *x) +{ + /* this will likely fail so its only here for legacy */ + Uplink::Send("UNSZLINE", 0, x->GetHost()); + /* this is how we are supposed to deal with it */ + Uplink::Send("RAKILL", x->GetHost(), "*"); +} - /* SGLINE */ - void SendSGLine(User *, XLine *x) override - { - Uplink::Send("SGLINE", x->GetMask().length(), x->GetMask() + ":" + x->GetReason()); - } +/* SZLINE */ +void bahamut::Proto::SendSZLine(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; + /* this will likely fail so its only here for legacy */ + Uplink::Send("SZLINE", x->GetHost(), x->GetReason()); + /* this is how we are supposed to deal with it */ + Uplink::Send("AKILL", x->GetHost(), "*", timeleft, x->GetBy(), Anope::CurTime, x->GetReason()); +} - /* RAKILL */ - void SendAkillDel(XLine *x) override - { - if (x->IsRegex() || x->HasNickOrReal()) - return; +/* SVSNOOP */ +void bahamut::Proto::SendSVSNOOP(Server *server, bool set) +{ + Uplink::Send("SVSNOOP", server->GetName(), set ? "+" : "-"); +} - /* ZLine if we can instead */ - if (x->GetUser() == "*") - { - cidr a(x->GetHost()); - if (a.valid()) - { - IRCD->SendSZLineDel(x); - return; - } - } +/* SGLINE */ +void bahamut::Proto::SendSGLine(User *, XLine *x) +{ + Uplink::Send("SGLINE", x->GetMask().length(), x->GetMask() + ":" + x->GetReason()); +} - Uplink::Send("RAKKILL", x->GetHost(), x->GetUser()); - } +/* RAKILL */ +void bahamut::Proto::SendAkillDel(XLine *x) +{ + if (x->IsRegex() || x->HasNickOrReal()) + return; - /* TOPIC */ - void SendTopic(const MessageSource &source, Channel *c) override + /* ZLine if we can instead */ + if (x->GetUser() == "*") { - Uplink::Send(source, "TOPIC", c->name, c->topic_setter, c->topic_ts, c->topic); + cidr a(x->GetHost()); + if (a.valid()) + { + IRCD->SendSZLineDel(x); + return; + } } - /* UNSQLINE */ - void SendSQLineDel(XLine *x) override - { - Uplink::Send("UNSQLINE", x->GetMask()); - } + Uplink::Send("RAKKILL", x->GetHost(), x->GetUser()); +} + +/* TOPIC */ +void bahamut::Proto::SendTopic(const MessageSource &source, Channel *c) +{ + Uplink::Send(source, "TOPIC", c->name, c->topic_setter, c->topic_ts, c->topic); +} + +/* UNSQLINE */ +void bahamut::Proto::SendSQLineDel(XLine *x) +{ + Uplink::Send("UNSQLINE", x->GetMask()); +} - /* JOIN - SJOIN */ - void SendJoin(User *user, Channel *c, const ChannelStatus *status) override +/* JOIN - SJOIN */ +void bahamut::Proto::SendJoin(User *user, Channel *c, const ChannelStatus *status) +{ + Uplink::Send(user, "SJOIN", c->creation_time, c->name); + + if (status) { - Uplink::Send(user, "SJOIN", c->creation_time, c->name); + /* First save the channel status incase uc->Status == status */ + ChannelStatus cs = *status; + /* If the user is internally on the channel with flags, kill them so that + * the stacker will allow this. + */ + ChanUserContainer *uc = c->FindUser(user); + if (uc != NULL) + uc->status.Clear(); - if (status) - { - /* First save the channel status incase uc->Status == status */ - ChannelStatus cs = *status; - /* If the user is internally on the channel with flags, kill them so that - * the stacker will allow this. - */ - ChanUserContainer *uc = c->FindUser(user); - if (uc != NULL) - uc->status.Clear(); - - ServiceBot *setter = ServiceBot::Find(user->GetUID()); - for (size_t i = 0; i < cs.Modes().length(); ++i) - c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); - - if (uc != NULL) - uc->status = cs; - } + ServiceBot *setter = ServiceBot::Find(user->GetUID()); + for (size_t i = 0; i < cs.Modes().length(); ++i) + c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); + + if (uc != NULL) + uc->status = cs; } +} - void SendAkill(User *u, XLine *x) override +void bahamut::Proto::SendAkill(User *u, XLine *x) +{ + if (x->IsRegex() || x->HasNickOrReal()) { - if (x->IsRegex() || x->HasNickOrReal()) + if (!u) { - if (!u) - { - /* 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); - return; - } + /* 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); + return; + } - XLine *old = x; + XLine *old = x; - if (old->GetManager()->HasEntry("*@" + u->host)) - return; + if (old->GetManager()->HasEntry("*@" + u->host)) + return; - /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ - x = Serialize::New<XLine *>(); - x->SetMask("*@" + u->host); - x->SetBy(old->GetBy()); - x->SetExpires(old->GetExpires()); - x->SetReason(old->GetReason()); - x->SetID(old->GetID()); - old->GetManager()->AddXLine(x); + /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ + x = Serialize::New<XLine *>(); + x->SetMask("*@" + u->host); + x->SetBy(old->GetBy()); + x->SetExpires(old->GetExpires()); + x->SetReason(old->GetReason()); + x->SetID(old->GetID()); + old->GetManager()->AddXLine(x); - Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" << u->realname << " matches " << old->GetMask(); - } + Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" << u->realname << " matches " << old->GetMask(); + } - /* ZLine if we can instead */ - if (x->GetUser() == "*") + /* ZLine if we can instead */ + if (x->GetUser() == "*") + { + cidr a(x->GetHost()); + if (a.valid()) { - cidr a(x->GetHost()); - if (a.valid()) - { - IRCD->SendSZLine(u, x); - return; - } + IRCD->SendSZLine(u, x); + return; } - - // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->GetExpires() - Anope::CurTime; - if (timeleft > 172800) - timeleft = 172800; - - Uplink::Send("AKILL", x->GetHost(), x->GetUser(), timeleft, x->GetBy(), Anope::CurTime, x->GetReason()); } - /* - Note: if the stamp is null 0, the below usage is correct of Bahamut - */ - void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override - { - Uplink::Send(source, "SVSKILL", user->nick, buf); - } + // Calculate the time left before this would expire, capping it at 2 days + time_t timeleft = x->GetExpires() - Anope::CurTime; + if (timeleft > 172800) + timeleft = 172800; - void SendBOB() override - { - Uplink::Send("BURST"); - } + Uplink::Send("AKILL", x->GetHost(), x->GetUser(), timeleft, x->GetBy(), Anope::CurTime, x->GetReason()); +} - void SendEOB() override - { - Uplink::Send("BURST", 0); - } +/* + Note: if the stamp is null 0, the below usage is correct of Bahamut +*/ +void bahamut::Proto::SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) +{ + Uplink::Send(source, "SVSKILL", user->nick, buf); +} - void SendClientIntroduction(User *u) override - { - Anope::string modes = "+" + u->GetModes(); - Uplink::Send("NICK", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, u->server->GetName(), 0, 0, u->realname); - } +void bahamut::Proto::SendBOB() +{ + Uplink::Send("BURST"); +} - /* SERVER */ - void SendServer(Server *server) override - { - Uplink::Send("SERVER", server->GetName(), server->GetHops(), server->GetDescription()); - } +void bahamut::Proto::SendEOB() +{ + Uplink::Send("BURST", 0); +} - void SendConnect() override - { - Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS"); - Uplink::Send("CAPAB", "SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3"); - SendServer(Me); - /* - * SVINFO - * parv[0] = sender prefix - * parv[1] = TS_CURRENT for the server - * parv[2] = TS_MIN for the server - * parv[3] = server is standalone or connected to non-TS only - * parv[4] = server's idea of UTC time - */ - Uplink::Send("SVINFO", 3, 1, 0, Anope::CurTime); - this->SendBOB(); - } +void bahamut::Proto::SendClientIntroduction(User *u) +{ + Anope::string modes = "+" + u->GetModes(); + Uplink::Send("NICK", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, u->server->GetName(), 0, 0, u->realname); +} - void SendChannel(Channel *c) override - { - Anope::string modes = c->GetModes(true, true); - if (modes.empty()) - modes = "+"; - Uplink::Send("SJOIN", c->creation_time, c->name, modes, ""); - } +/* SERVER */ +void bahamut::Proto::SendServer(Server *server) +{ + Uplink::Send("SERVER", server->GetName(), server->GetHops(), server->GetDescription()); +} - void SendLogin(User *u, NickServ::Nick *) override - { - IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", u->signon); - } +void bahamut::Proto::SendConnect() +{ + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS"); + Uplink::Send("CAPAB", "SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3"); + SendServer(Me); + /* + * SVINFO + * parv[0] = sender prefix + * parv[1] = TS_CURRENT for the server + * parv[2] = TS_MIN for the server + * parv[3] = server is standalone or connected to non-TS only + * parv[4] = server's idea of UTC time + */ + Uplink::Send("SVINFO", 3, 1, 0, Anope::CurTime); + this->SendBOB(); +} - void SendLogout(User *u) override - { - IRCD->SendMode(Config->GetClient("NickServ"), u, "+d 1"); - } -}; +void bahamut::Proto::SendChannel(Channel *c) +{ + Anope::string modes = c->GetModes(true, true); + if (modes.empty()) + modes = "+"; + Uplink::Send("SJOIN", c->creation_time, c->name, modes, ""); +} + +void bahamut::Proto::SendLogin(User *u, NickServ::Nick *) +{ + IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", u->signon); +} + +void bahamut::Proto::SendLogout(User *u) +{ + IRCD->SendMode(Config->GetClient("NickServ"), u, "+d 1"); +} void bahamut::Burst::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { @@ -496,7 +492,7 @@ void bahamut::Topic::Run(MessageSource &source, const std::vector<Anope::string> class ProtoBahamut : public Module , public EventHook<Event::UserNickChange> { - BahamutIRCdProto ircd_proto; + bahamut::Proto ircd_proto; /* Core message handlers */ rfc1459::Away message_away; diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp index c111a31d3..4488f5425 100644 --- a/modules/protocol/charybdis.cpp +++ b/modules/protocol/charybdis.cpp @@ -40,143 +40,119 @@ class ChannelModeLargeBan : public ChannelMode }; -class CharybdisProto : public IRCDProto +charybdis::Proto::Proto(Module *creator) : IRCDProto(creator, "Charybdis 3.4+") + , ratbox("ratbox") { - ServiceReference<IRCDProto> ratbox; // XXX - - public: - CharybdisProto(Module *creator) : IRCDProto(creator, "Charybdis 3.4+") - , ratbox("ratbox") - { - DefaultPseudoclientModes = "+oiS"; - CanCertFP = true; - CanSNLine = true; - CanSQLine = true; - CanSQLineChannel = true; - CanSZLine = true; - CanSVSNick = true; - CanSVSHold = true; - CanSetVHost = true; - RequiresID = true; - MaxModes = 4; - } + DefaultPseudoclientModes = "+oiS"; + CanCertFP = true; + CanSNLine = true; + CanSQLine = true; + CanSQLineChannel = true; + CanSZLine = true; + CanSVSNick = true; + CanSVSHold = true; + CanSetVHost = true; + RequiresID = true; + MaxModes = 4; +} - void SendSVSKill(const MessageSource &source, User *targ, const Anope::string &reason) override { ratbox->SendSVSKill(source, targ, reason); } - void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override { ratbox->SendGlobalNotice(bi, dest, msg); } - void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override { ratbox->SendGlobalPrivmsg(bi, dest, msg); } - void SendGlobops(const MessageSource &source, const Anope::string &buf) override { ratbox->SendGlobops(source, buf); } - void SendSGLine(User *u, XLine *x) override { ratbox->SendSGLine(u, x); } - void SendSGLineDel(XLine *x) override { ratbox->SendSGLineDel(x); } - void SendAkill(User *u, XLine *x) override { ratbox->SendAkill(u, x); } - void SendAkillDel(XLine *x) override { ratbox->SendAkillDel(x); } - void SendSQLine(User *u, XLine *x) override { ratbox->SendSQLine(u, x); } - void SendSQLineDel(XLine *x) override { ratbox->SendSQLineDel(x); } - void SendJoin(User *user, Channel *c, const ChannelStatus *status) override { ratbox->SendJoin(user, c, status); } - void SendServer(Server *server) override { ratbox->SendServer(server); } - void SendChannel(Channel *c) override { ratbox->SendChannel(c); } - void SendTopic(const MessageSource &source, Channel *c) override { ratbox->SendTopic(source, c); } - bool IsIdentValid(const Anope::string &ident) override { return ratbox->IsIdentValid(ident); } - void SendLogin(User *u, NickServ::Nick *na) override { ratbox->SendLogin(u, na); } - void SendLogout(User *u) override { ratbox->SendLogout(u); } - - void SendConnect() override - { - Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS", 6, Me->GetSID()); - - /* - * Received: CAPAB :BAN CHW CLUSTER ENCAP EOPMOD EUID EX IE KLN - * KNOCK MLOCK QS RSFNC SAVE SERVICES TB UNKLN - * - * BAN - Can do BAN message - * CHW - Can do channel wall @# - * CLUSTER - Supports umode +l, can send LOCOPS (encap only) - * ENCAP - Can do ENCAP message - * EOPMOD - Can do channel wall =# (for cmode +z) - * EUID - Can do EUID (its similar to UID but includes the ENCAP REALHOST and ENCAP LOGIN information) - * EX - Can do channel +e exemptions - * GLN - Can set G:Lines - * IE - Can do invite exceptions - * KLN - Can set K:Lines (encap only) - * KNOCK - Supports KNOCK - * MLOCK - Supports MLOCK - * RSFNC - Forces a nickname change and propagates it (encap only) - * SERVICES - Support channel mode +r (only registered users may join) - * SAVE - Resolve a nick collision by changing a nickname to the UID. - * TB - Supports topic burst - * UNKLN - Can do UNKLINE (encap only) - * QS - Can handle quit storm removal - */ - Uplink::Send("CAPAB", "BAN CHW CLUSTER ENCAP EOPMOD EUID EX IE KLN KNOCK MLOCK QS RSFNC SERVICES TB UNKLN"); - - /* Make myself known to myself in the serverlist */ - SendServer(Me); - - /* - * Received: SVINFO 6 6 0 :1353235537 - * arg[0] = current TS version - * arg[1] = minimum required TS version - * arg[2] = '0' - * arg[3] = server's idea of UTC time - */ - Uplink::Send("SVINFO", 6, 6, Anope::CurTime); - } +void charybdis::Proto::SendConnect() +{ + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS", 6, Me->GetSID()); - void SendClientIntroduction(User *u) override - { - Anope::string modes = "+" + u->GetModes(); - Uplink::Send(Me, "EUID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, 0, u->GetUID(), "*", "*", u->realname); - } + /* + * Received: CAPAB :BAN CHW CLUSTER ENCAP EOPMOD EUID EX IE KLN + * KNOCK MLOCK QS RSFNC SAVE SERVICES TB UNKLN + * + * BAN - Can do BAN message + * CHW - Can do channel wall @# + * CLUSTER - Supports umode +l, can send LOCOPS (encap only) + * ENCAP - Can do ENCAP message + * EOPMOD - Can do channel wall =# (for cmode +z) + * EUID - Can do EUID (its similar to UID but includes the ENCAP REALHOST and ENCAP LOGIN information) + * EX - Can do channel +e exemptions + * GLN - Can set G:Lines + * IE - Can do invite exceptions + * KLN - Can set K:Lines (encap only) + * KNOCK - Supports KNOCK + * MLOCK - Supports MLOCK + * RSFNC - Forces a nickname change and propagates it (encap only) + * SERVICES - Support channel mode +r (only registered users may join) + * SAVE - Resolve a nick collision by changing a nickname to the UID. + * TB - Supports topic burst + * UNKLN - Can do UNKLINE (encap only) + * QS - Can handle quit storm removal + */ + Uplink::Send("CAPAB", "BAN CHW CLUSTER ENCAP EOPMOD EUID EX IE KLN KNOCK MLOCK QS RSFNC SERVICES TB UNKLN"); + + /* Make myself known to myself in the serverlist */ + SendServer(Me); - void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override - { - Uplink::Send(Me, "ENCAP", u->server->GetName(), "RSFNC", u->GetUID(), - newnick, when, u->timestamp); - } + /* + * Received: SVINFO 6 6 0 :1353235537 + * arg[0] = current TS version + * arg[1] = minimum required TS version + * arg[2] = '0' + * arg[3] = server's idea of UTC time + */ + Uplink::Send("SVINFO", 6, 6, Anope::CurTime); +} - void SendSVSHold(const Anope::string &nick, time_t delay) override - { - Uplink::Send(Me, "ENCAP", "*", "NICKDELAY", delay, nick); - } +void charybdis::Proto::SendClientIntroduction(User *u) +{ + Anope::string modes = "+" + u->GetModes(); + Uplink::Send(Me, "EUID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, 0, u->GetUID(), "*", "*", u->realname); +} - void SendSVSHoldDel(const Anope::string &nick) override - { - Uplink::Send(Me, "ENCAP", "*", "NICKDELAY", 0, nick); - } +void charybdis::Proto::SendForceNickChange(User *u, const Anope::string &newnick, time_t when) +{ + Uplink::Send(Me, "ENCAP", u->server->GetName(), "RSFNC", u->GetUID(), + newnick, when, u->timestamp); +} - void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) override - { - Uplink::Send(Me, "ENCAP", "*", "CHGHOST", u->GetUID(), host); - } +void charybdis::Proto::SendSVSHold(const Anope::string &nick, time_t delay) +{ + Uplink::Send(Me, "ENCAP", "*", "NICKDELAY", delay, nick); +} - void SendVhostDel(User *u) override - { - this->SendVhost(u, "", u->host); - } +void charybdis::Proto::SendSVSHoldDel(const Anope::string &nick) +{ + Uplink::Send(Me, "ENCAP", "*", "NICKDELAY", 0, nick); +} - void SendSASLMechanisms(std::vector<Anope::string> &mechanisms) override - { - Anope::string mechlist; +void charybdis::Proto::SendVhost(User *u, const Anope::string &ident, const Anope::string &host) +{ + Uplink::Send(Me, "ENCAP", "*", "CHGHOST", u->GetUID(), host); +} - for (unsigned i = 0; i < mechanisms.size(); ++i) - { - mechlist += "," + mechanisms[i]; - } +void charybdis::Proto::SendVhostDel(User *u) +{ + this->SendVhost(u, "", u->host); +} - Uplink::Send(Me, "ENCAP", "*", "MECHLIST", mechlist.empty() ? "" : mechlist.substr(1)); - } +void charybdis::Proto::SendSASLMechanisms(std::vector<Anope::string> &mechanisms) +{ + Anope::string mechlist; - void SendSASLMessage(const SASL::Message &message) override + for (unsigned i = 0; i < mechanisms.size(); ++i) { - Server *s = Server::Find(message.target.substr(0, 3)); - Uplink::Send(Me, "ENCAP", s ? s->GetName() : message.target.substr(0, 3), "SASL", message.source, message.target, message.type, message.data, message.ext.empty() ? "" : message.ext); + mechlist += "," + mechanisms[i]; } - void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) override - { - Server *s = Server::Find(uid.substr(0, 3)); - Uplink::Send(Me, "ENCAP", s ? s->GetName() : uid.substr(0, 3), "SVSLOGIN", uid, "*", vident.empty() ? "*" : vident, vhost.empty() ? "*" : vhost, acc); - } -}; + Uplink::Send(Me, "ENCAP", "*", "MECHLIST", mechlist.empty() ? "" : mechlist.substr(1)); +} + +void charybdis::Proto::SendSASLMessage(const SASL::Message &message) +{ + Server *s = Server::Find(message.target.substr(0, 3)); + Uplink::Send(Me, "ENCAP", s ? s->GetName() : message.target.substr(0, 3), "SASL", message.source, message.target, message.type, message.data, message.ext.empty() ? "" : message.ext); +} + +void charybdis::Proto::SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) +{ + Server *s = Server::Find(uid.substr(0, 3)); + Uplink::Send(Me, "ENCAP", s ? s->GetName() : uid.substr(0, 3), "SVSLOGIN", uid, "*", vident.empty() ? "*" : vident, vhost.empty() ? "*" : vhost, acc); +} void charybdis::Encap::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) @@ -268,7 +244,7 @@ class ProtoCharybdis : public Module { ServiceReference<ModeLocks> mlocks; - CharybdisProto ircd_proto; + charybdis::Proto ircd_proto; /* Core message handlers */ rfc1459::Away message_away; diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index 2af72ed4c..922083587 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -25,319 +25,316 @@ static Anope::string UplinkSID; -class HybridProto : public IRCDProto + +ServiceBot *hybrid::Proto::FindIntroduced() { - ServiceBot *FindIntroduced() - { - ServiceBot *bi = Config->GetClient("OperServ"); - if (bi && bi->introduced) - return bi; + ServiceBot *bi = Config->GetClient("OperServ"); + if (bi && bi->introduced) + return bi; - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + { + User *u = it->second; + if (u->type == UserType::BOT) { - User *u = it->second; - if (u->type == UserType::BOT) - { - bi = anope_dynamic_static_cast<ServiceBot *>(u); - if (bi->introduced) - return bi; - } + bi = anope_dynamic_static_cast<ServiceBot *>(u); + if (bi->introduced) + return bi; } - - return NULL; } - void SendSVSKill(const MessageSource &source, User *u, const Anope::string &buf) override - { - IRCDProto::SendSVSKill(source, u, buf); - u->KillInternal(source, buf); - } + return NULL; +} - public: - HybridProto(Module *creator) : IRCDProto(creator, "Hybrid 8.2.x") - { - DefaultPseudoclientModes = "+oi"; - CanSVSNick = true; - CanSVSHold = true; - CanSVSJoin = true; - CanSNLine = true; - CanSQLine = true; - CanSQLineChannel = true; - CanSZLine = true; - CanCertFP = true; - CanSetVHost = true; - RequiresID = true; - MaxModes = 6; - } +void hybrid::Proto::SendSVSKill(const MessageSource &source, User *u, const Anope::string &buf) +{ + IRCDProto::SendSVSKill(source, u, buf); + u->KillInternal(source, buf); +} - void SendInvite(const MessageSource &source, Channel *c, User *u) override - { - Uplink::Send(source, "INVITE", u->GetUID(), c->name, c->creation_time); - } +hybrid::Proto::Proto(Module *creator) : IRCDProto(creator, "Hybrid 8.2.x") +{ + DefaultPseudoclientModes = "+oi"; + CanSVSNick = true; + CanSVSHold = true; + CanSVSJoin = true; + CanSNLine = true; + CanSQLine = true; + CanSQLineChannel = true; + CanSZLine = true; + CanCertFP = true; + CanSetVHost = true; + RequiresID = true; + MaxModes = 6; +} - void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "NOTICE", "$$" + dest->GetName(), msg); - } +void hybrid::Proto::SendInvite(const MessageSource &source, Channel *c, User *u) +{ + Uplink::Send(source, "INVITE", u->GetUID(), c->name, c->creation_time); +} - void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "PRIVMSG", "$$" + dest->GetName(), msg); - } +void hybrid::Proto::SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "NOTICE", "$$" + dest->GetName(), msg); +} - void SendSQLine(User *, XLine *x) override - { - Uplink::Send(FindIntroduced(), "RESV", "*", x->GetExpires() ? x->GetExpires() - Anope::CurTime : 0, x->GetMask(), x->GetReason()); - } +void hybrid::Proto::SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "PRIVMSG", "$$" + dest->GetName(), msg); +} - void SendSGLineDel(XLine *x) override - { - Uplink::Send(Config->GetClient("OperServ"), "UNXLINE", "*", x->GetMask()); - } +void hybrid::Proto::SendSQLine(User *, XLine *x) +{ + Uplink::Send(FindIntroduced(), "RESV", "*", x->GetExpires() ? x->GetExpires() - Anope::CurTime : 0, x->GetMask(), x->GetReason()); +} - void SendSGLine(User *, XLine *x) override - { - Uplink::Send(Config->GetClient("OperServ"), "XLINE", "*", x->GetMask(), x->GetExpires() ? x->GetExpires() - Anope::CurTime : 0, x->GetReason()); - } +void hybrid::Proto::SendSGLineDel(XLine *x) +{ + Uplink::Send(Config->GetClient("OperServ"), "UNXLINE", "*", x->GetMask()); +} - void SendSZLineDel(XLine *x) override - { - Uplink::Send(Config->GetClient("OperServ"), "UNDLINE", "*", x->GetHost()); - } +void hybrid::Proto::SendSGLine(User *, XLine *x) +{ + Uplink::Send(Config->GetClient("OperServ"), "XLINE", "*", x->GetMask(), x->GetExpires() ? x->GetExpires() - Anope::CurTime : 0, x->GetReason()); +} - void SendSZLine(User *, XLine *x) override - { - /* Calculate the time left before this would expire, capping it at 2 days */ - time_t timeleft = x->GetExpires() - Anope::CurTime; +void hybrid::Proto::SendSZLineDel(XLine *x) +{ + Uplink::Send(Config->GetClient("OperServ"), "UNDLINE", "*", x->GetHost()); +} - if (timeleft > 172800 || !x->GetExpires()) - timeleft = 172800; +void hybrid::Proto::SendSZLine(User *, XLine *x) +{ + /* Calculate the time left before this would expire, capping it at 2 days */ + time_t timeleft = x->GetExpires() - Anope::CurTime; - Uplink::Send(Config->GetClient("OperServ"), "DLINE", "*", timeleft, x->GetHost(), x->GetReason()); - } + if (timeleft > 172800 || !x->GetExpires()) + timeleft = 172800; - void SendAkillDel(XLine *x) override - { - if (x->IsRegex() || x->HasNickOrReal()) - return; + Uplink::Send(Config->GetClient("OperServ"), "DLINE", "*", timeleft, x->GetHost(), x->GetReason()); +} - Uplink::Send(Config->GetClient("OperServ"), "UNKLINE", "*", x->GetUser(), x->GetHost()); - } +void hybrid::Proto::SendAkillDel(XLine *x) +{ + if (x->IsRegex() || x->HasNickOrReal()) + return; - void SendSQLineDel(XLine *x) override - { - Uplink::Send(Config->GetClient("OperServ"), "UNRESV", "*", x->GetMask()); - } + Uplink::Send(Config->GetClient("OperServ"), "UNKLINE", "*", x->GetUser(), x->GetHost()); +} + +void hybrid::Proto::SendSQLineDel(XLine *x) +{ + Uplink::Send(Config->GetClient("OperServ"), "UNRESV", "*", x->GetMask()); +} + +void hybrid::Proto::SendJoin(User *u, Channel *c, const ChannelStatus *status) +{ + /* + * Note that we must send our modes with the SJOIN and can not add them to the + * mode stacker because ircd-hybrid does not allow *any* client to op itself + */ + Uplink::Send("SJOIN", c->creation_time, c->name, "+" + c->GetModes(true, true), (status != NULL ? status->BuildModePrefixList() : "") + u->GetUID()); - void SendJoin(User *u, Channel *c, const ChannelStatus *status) override + /* And update our internal status for this user since this is not going through our mode handling system */ + if (status) { - /* - * Note that we must send our modes with the SJOIN and can not add them to the - * mode stacker because ircd-hybrid does not allow *any* client to op itself - */ - Uplink::Send("SJOIN", c->creation_time, c->name, "+" + c->GetModes(true, true), (status != NULL ? status->BuildModePrefixList() : "") + u->GetUID()); - - /* And update our internal status for this user since this is not going through our mode handling system */ - if (status) - { - ChanUserContainer *uc = c->FindUser(u); + ChanUserContainer *uc = c->FindUser(u); - if (uc) - uc->status = *status; - } + if (uc) + uc->status = *status; } +} - void SendAkill(User *u, XLine *x) override +void hybrid::Proto::SendAkill(User *u, XLine *x) +{ + if (x->IsRegex() || x->HasNickOrReal()) { - if (x->IsRegex() || x->HasNickOrReal()) + if (!u) { - if (!u) - { - /* - * 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); - - return; - } - - XLine *old = x; - - if (old->GetManager()->HasEntry("*@" + u->host)) - return; - - /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ - XLine *xl = Serialize::New<XLine *>(); - xl->SetMask("*@" + u->host); - xl->SetBy(old->GetBy()); - xl->SetExpires(old->GetExpires()); - xl->SetReason(old->GetReason()); - xl->SetID(old->GetID()); - - old->GetManager()->AddXLine(xl); - x = xl; - - Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" - << u->realname << " matches " << old->GetMask(); + /* + * 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); + + return; } - /* Calculate the time left before this would expire, capping it at 2 days */ - time_t timeleft = x->GetExpires() - Anope::CurTime; + XLine *old = x; - if (timeleft > 172800 || !x->GetExpires()) - timeleft = 172800; + if (old->GetManager()->HasEntry("*@" + u->host)) + return; - Uplink::Send(Config->GetClient("OperServ"), "KLINE", timeleft, x->GetUser(), x->GetHost(), x->GetReason()); - } + /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ + XLine *xl = Serialize::New<XLine *>(); + xl->SetMask("*@" + u->host); + xl->SetBy(old->GetBy()); + xl->SetExpires(old->GetExpires()); + xl->SetReason(old->GetReason()); + xl->SetID(old->GetID()); - void SendServer(Server *server) override - { - if (server == Me) - Uplink::Send("SERVER", server->GetName(), server->GetHops() + 1, server->GetDescription()); - else - Uplink::Send(Me, "SID", server->GetName(), server->GetHops() + 1, server->GetSID(), server->GetDescription()); - } + old->GetManager()->AddXLine(xl); + x = xl; - void SendConnect() override - { - Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS", 6, Me->GetSID()); - - /* - * As of January 13, 2016, ircd-hybrid-8 supports the following capabilities - * which are required to work with IRC-services: - * - * QS - Can handle quit storm removal - * EX - Can do channel +e exemptions - * IE - Can do invite exceptions - * CHW - Can do channel wall @# - * TBURST - Supports topic burst - * ENCAP - Supports ENCAP - * HOPS - Supports HalfOps - * SVS - Supports services - * EOB - Supports End Of Burst message - */ - Uplink::Send("CAPAB", "QS EX CHW IE ENCAP TBURST SVS HOPS EOB"); - - SendServer(Me); - - Uplink::Send("SVINFO", 6, 6, 0, Anope::CurTime); + Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" + << u->realname << " matches " << old->GetMask(); } - void SendClientIntroduction(User *u) override - { - Anope::string modes = "+" + u->GetModes(); + /* Calculate the time left before this would expire, capping it at 2 days */ + time_t timeleft = x->GetExpires() - Anope::CurTime; - Uplink::Send(Me, "UID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, "0.0.0.0", u->GetUID(), "*", u->realname); - } + if (timeleft > 172800 || !x->GetExpires()) + timeleft = 172800; - void SendEOB() override - { - Uplink::Send(Me, "EOB"); - } + Uplink::Send(Config->GetClient("OperServ"), "KLINE", timeleft, x->GetUser(), x->GetHost(), x->GetReason()); +} - void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override - { - IRCMessage message(source, "SVSMODE", u->GetUID(), u->timestamp); - message.TokenizeAndPush(buf); - Uplink::SendMessage(message); - } +void hybrid::Proto::SendServer(Server *server) +{ + if (server == Me) + Uplink::Send("SERVER", server->GetName(), server->GetHops() + 1, server->GetDescription()); + else + Uplink::Send(Me, "SID", server->GetName(), server->GetHops() + 1, server->GetSID(), server->GetDescription()); +} - void SendLogin(User *u, NickServ::Nick *na) override - { - IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", na->GetAccount()->GetDisplay()); - } +void hybrid::Proto::SendConnect() +{ + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS", 6, Me->GetSID()); + + /* + * As of January 13, 2016, ircd-hybrid-8 supports the following capabilities + * which are required to work with IRC-services: + * + * QS - Can handle quit storm removal + * EX - Can do channel +e exemptions + * IE - Can do invite exceptions + * CHW - Can do channel wall @# + * TBURST - Supports topic burst + * ENCAP - Supports ENCAP + * HOPS - Supports HalfOps + * SVS - Supports services + * EOB - Supports End Of Burst message + */ + Uplink::Send("CAPAB", "QS EX CHW IE ENCAP TBURST SVS HOPS EOB"); + + SendServer(Me); + + Uplink::Send("SVINFO", 6, 6, 0, Anope::CurTime); +} - void SendLogout(User *u) override - { - IRCD->SendMode(Config->GetClient("NickServ"), u, "+d *"); - } +void hybrid::Proto::SendClientIntroduction(User *u) +{ + Anope::string modes = "+" + u->GetModes(); - void SendChannel(Channel *c) override - { - Anope::string modes = c->GetModes(true, true); + Uplink::Send(Me, "UID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, "0.0.0.0", u->GetUID(), "*", u->realname); +} - if (modes.empty()) - modes = "+"; +void hybrid::Proto::SendEOB() +{ + Uplink::Send(Me, "EOB"); +} - Uplink::Send("SJOIN", c->creation_time, c->name, modes, ""); - } +void hybrid::Proto::SendMode(const MessageSource &source, User *u, const Anope::string &buf) +{ + IRCMessage message(source, "SVSMODE", u->GetUID(), u->timestamp); + message.TokenizeAndPush(buf); + Uplink::SendMessage(message); +} - void SendTopic(const MessageSource &source, Channel *c) override - { - Uplink::Send(source, "TBURST", c->creation_time, c->name, c->topic_ts, c->topic_setter, c->topic); - } +void hybrid::Proto::SendLogin(User *u, NickServ::Nick *na) +{ + IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", na->GetAccount()->GetDisplay()); +} - void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override - { - Uplink::Send(Me, "SVSNICK", u->GetUID(), newnick, when); - } +void hybrid::Proto::SendLogout(User *u) +{ + IRCD->SendMode(Config->GetClient("NickServ"), u, "+d *"); +} - void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) override - { - Uplink::Send(source, "SVSJOIN", u->GetUID(), chan); - } +void hybrid::Proto::SendChannel(Channel *c) +{ + Anope::string modes = c->GetModes(true, true); - void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) override - { - if (!param.empty()) - Uplink::Send(source, "SVSPART", u->GetUID(), chan, param); - else - Uplink::Send(source, "SVSPART", u->GetUID(), chan); - } + if (modes.empty()) + modes = "+"; - void SendSVSHold(const Anope::string &nick, time_t t) override - { + Uplink::Send("SJOIN", c->creation_time, c->name, modes, ""); +} + +void hybrid::Proto::SendTopic(const MessageSource &source, Channel *c) +{ + Uplink::Send(source, "TBURST", c->creation_time, c->name, c->topic_ts, c->topic_setter, c->topic); +} + +void hybrid::Proto::SendForceNickChange(User *u, const Anope::string &newnick, time_t when) +{ + Uplink::Send(Me, "SVSNICK", u->GetUID(), newnick, when); +} + +void hybrid::Proto::SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) +{ + Uplink::Send(source, "SVSJOIN", u->GetUID(), chan); +} + +void hybrid::Proto::SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) +{ + if (!param.empty()) + Uplink::Send(source, "SVSPART", u->GetUID(), chan, param); + else + Uplink::Send(source, "SVSPART", u->GetUID(), chan); +} + +void hybrid::Proto::SendSVSHold(const Anope::string &nick, time_t t) +{ #if 0 - XLine x(nick, Me->GetName(), Anope::CurTime + t, "Being held for registered user"); - this->SendSQLine(NULL, &x); + XLine x(nick, Me->GetName(), Anope::CurTime + t, "Being held for registered user"); + this->SendSQLine(NULL, &x); #endif - } +} #warning "xline on stack" - void SendSVSHoldDel(const Anope::string &nick) override - { +void hybrid::Proto::SendSVSHoldDel(const Anope::string &nick) +{ #if 0 - XLine x(nick); - this->SendSQLineDel(&x); + XLine x(nick); + this->SendSQLineDel(&x); #endif - } - - void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) override - { - u->SetMode(Config->GetClient("HostServ"), "CLOAK", host); - } +} - void SendVhostDel(User *u) override - { - u->RemoveMode(Config->GetClient("HostServ"), "CLOAK", u->host); - } +void hybrid::Proto::SendVhost(User *u, const Anope::string &ident, const Anope::string &host) +{ + u->SetMode(Config->GetClient("HostServ"), "CLOAK", host); +} - bool IsIdentValid(const Anope::string &ident) override - { - if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) - return false; +void hybrid::Proto::SendVhostDel(User *u) +{ + u->RemoveMode(Config->GetClient("HostServ"), "CLOAK", u->host); +} - Anope::string chars = "~}|{ `_^]\\[ .-$"; +bool hybrid::Proto::IsIdentValid(const Anope::string &ident) +{ + if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) + return false; - for (unsigned i = 0; i < ident.length(); ++i) - { - const char &c = ident[i]; + Anope::string chars = "~}|{ `_^]\\[ .-$"; - if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')) - continue; + for (unsigned i = 0; i < ident.length(); ++i) + { + const char &c = ident[i]; - if (chars.find(c) != Anope::string::npos) - continue; + if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')) + continue; - return false; - } + if (chars.find(c) != Anope::string::npos) + continue; - return true; + return false; } -}; + + return true; +} /* 0 1 2 3 */ /* :0MC BMASK 1350157102 #channel b :*!*@*.test.com */ @@ -585,7 +582,7 @@ void hybrid::CertFP::Run(MessageSource &source, const std::vector<Anope::string> class ProtoHybrid : public Module , public EventHook<Event::UserNickChange> { - HybridProto ircd_proto; + hybrid::Proto ircd_proto; /* Core message handlers */ rfc1459::Away message_away; diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 3a3c13619..a8caac27a 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -37,454 +37,449 @@ static std::list<SASLUser> saslusers; static Anope::string rsquit_server, rsquit_id; static unsigned int spanningtree_proto_ver = 0; -class InspIRCd20Proto : public IRCDProto +void inspircd20::Proto::SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) { - private: - void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override - { - IRCDProto::SendSVSKill(source, user, buf); - user->KillInternal(source, buf); - } + IRCDProto::SendSVSKill(source, user, buf); + user->KillInternal(source, buf); +} - void 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::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 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::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 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::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 SendDelLine(const Anope::string &xtype, const Anope::string &mask) - { - Uplink::Send(Me, "DELLINE", xtype, mask); - } +void inspircd20::Proto::SendDelLine(const Anope::string &xtype, const Anope::string &mask) +{ + Uplink::Send(Me, "DELLINE", xtype, mask); +} - public: - InspIRCd20Proto(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; - } +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 SendConnect() override - { - Uplink::Send("CAPAB START 1202"); - Uplink::Send("CAPAB CAPABILITIES :PROTOCOL=1202"); - Uplink::Send("CAPAB END"); - SendServer(Me); - } +void inspircd20::Proto::SendConnect() +{ + Uplink::Send("CAPAB START 1202"); + Uplink::Send("CAPAB CAPABILITIES :PROTOCOL=1202"); + Uplink::Send("CAPAB END"); + SendServer(Me); +} - void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); - } +void inspircd20::Proto::SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); +} - void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "PRIVMSG", "$" + 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; - void SendAkillDel(XLine *x) override + /* ZLine if we can instead */ + if (x->GetUser() == "*") { - /* InspIRCd may support regex bans */ - if (x->IsRegex() && Servers::Capab.count("RLINE")) + cidr addr(x->GetHost()); + if (addr.valid()) { - Anope::string mask = x->GetMask(); - size_t h = mask.find('#'); - if (h != Anope::string::npos) - mask = mask.replace(h, 1, ' '); - SendDelLine("R", mask); + IRCD->SendSZLineDel(x); 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()); +} - 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); } - - void SendTopic(const MessageSource &source, Channel *c) override + else { - 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); - } + /* 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 SendVhostDel(User *u) override - { - if (u->HasMode("CLOAK")) - this->SendChgHostInternal(u->nick, u->chost); - else - this->SendChgHostInternal(u->nick, u->host); +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()); - } + if (Servers::Capab.count("CHGIDENT") && u->GetIdent() != u->GetVIdent()) + this->SendChgIdentInternal(u->nick, u->GetIdent()); +} - void SendAkill(User *u, XLine *x) override +void inspircd20::Proto::SendAkill(User *u, 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; + + /* InspIRCd may support regex bans, if they do we can send this and forget about it */ + 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, ' '); + SendAddLine("R", mask, timeleft, x->GetBy(), x->GetReason()); + return; + } + else if (x->IsRegex() || x->HasNickOrReal()) { - // 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; - - /* InspIRCd may support regex bans, if they do we can send this and forget about it */ - if (x->IsRegex() && Servers::Capab.count("RLINE")) + if (!u) { - Anope::string mask = x->GetMask(); - size_t h = mask.find('#'); - if (h != Anope::string::npos) - mask = mask.replace(h, 1, ' '); - SendAddLine("R", mask, timeleft, x->GetBy(), x->GetReason()); + /* 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); return; } - else if (x->IsRegex() || x->HasNickOrReal()) - { - if (!u) - { - /* 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); - return; - } - XLine *old = x; + XLine *old = x; - if (old->GetManager()->HasEntry("*@" + u->host)) - return; + if (old->GetManager()->HasEntry("*@" + u->host)) + return; - /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ - x = Serialize::New<XLine *>(); - x->SetMask("*@" + u->host); - x->SetBy(old->GetBy()); - x->SetExpires(old->GetExpires()); - x->SetReason(old->GetReason()); - old->GetManager()->AddXLine(x); + /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ + x = Serialize::New<XLine *>(); + x->SetMask("*@" + u->host); + x->SetBy(old->GetBy()); + x->SetExpires(old->GetExpires()); + x->SetReason(old->GetReason()); + old->GetManager()->AddXLine(x); - Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" << u->realname << " matches " << old->GetMask(); - } + Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" << u->realname << " matches " << old->GetMask(); + } - /* ZLine if we can instead */ - if (x->GetUser() == "*") + /* ZLine if we can instead */ + if (x->GetUser() == "*") + { + cidr addr(x->GetHost()); + if (addr.valid()) { - cidr addr(x->GetHost()); - if (addr.valid()) - { - IRCD->SendSZLine(u, x); - return; - } + IRCD->SendSZLine(u, x); + return; } - - SendAddLine("G", x->GetUser() + "@" + x->GetHost(), timeleft, x->GetBy(), x->GetReason()); } - void SendNumeric(int numeric, User *dest, IRCMessage &message) - { - std::vector<Anope::string> params = message.GetParameters(); - if (params.empty()) - return; + SendAddLine("G", x->GetUser() + "@" + x->GetHost(), timeleft, x->GetBy(), x->GetReason()); +} - /* First parameter is the UID, change it to nick because it is pushed */ - params[0] = dest->nick; +void inspircd20::Proto::SendNumeric(int numeric, User *dest, IRCMessage &message) +{ + std::vector<Anope::string> params = message.GetParameters(); + if (params.empty()) + return; - IRCMessage m(message.GetSource(), message.GetCommand()); - for (const Anope::string &s : params) - m.Push(s); + /* First parameter is the UID, change it to nick because it is pushed */ + params[0] = dest->nick; - Uplink::Send("PUSH", dest->GetUID(), Format(m)); - } + IRCMessage m(message.GetSource(), message.GetCommand()); + for (const Anope::string &s : params) + m.Push(s); - void SendMode(const MessageSource &source, Channel *dest, const Anope::string &buf) override - { - IRCMessage message(source, "FMODE", dest->name, dest->creation_time); - message.TokenizeAndPush(buf); - Uplink::SendMessage(message); - } + Uplink::Send("PUSH", dest->GetUID(), Format(m)); +} - void SendClientIntroduction(User *u) override - { - 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"); - } +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); +} - /* SERVER services-dev.chatspike.net password 0 :Description here */ - void SendServer(Server *server) override - { - /* 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()); - } +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"); +} - void SendSquit(Server *s, const Anope::string &message) override - { - if (s != Me) - { - rsquit_id = s->GetSID(); - rsquit_server = s->GetName(); - - Uplink::Send("RSQUIT", s->GetName(), message); - } - else - { - Uplink::Send("SQUIT", s->GetName(), message); - } - } +/* 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()); +} - /* JOIN */ - void SendJoin(User *user, Channel *c, const ChannelStatus *status) override +void inspircd20::Proto::SendSquit(Server *s, const Anope::string &message) +{ + if (s != Me) { - Uplink::Send(Me, "FJOIN", c->name, c->creation_time, "+" + c->GetModes(true, true), "," + user->GetUID()); + rsquit_id = s->GetSID(); + rsquit_server = s->GetName(); - /* Note that we can send this with the FJOIN but choose not to - * because the mode stacker will handle this and probably will - * merge these modes with +nrt and other mlocked modes - */ - if (status) - { - /* First save the channel status incase uc->Status == status */ - ChannelStatus cs = *status; - /* If the user is internally on the channel with flags, kill them so that - * the stacker will allow this. - */ - ChanUserContainer *uc = c->FindUser(user); - if (uc != NULL) - uc->status.Clear(); - - ServiceBot *setter = ServiceBot::Find(user->nick); - for (size_t i = 0; i < cs.Modes().length(); ++i) - c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); - - if (uc != NULL) - uc->status = cs; - } + Uplink::Send("RSQUIT", s->GetName(), message); } - - /* UNSQLINE */ - void SendSQLineDel(XLine *x) override + else { - SendDelLine("Q", x->GetMask()); + Uplink::Send("SQUIT", s->GetName(), message); } +} - /* SQLINE */ - void SendSQLine(User *, XLine *x) override - { - // 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()); - } +/* JOIN */ +void inspircd20::Proto::SendJoin(User *user, Channel *c, const ChannelStatus *status) +{ + Uplink::Send(Me, "FJOIN", c->name, c->creation_time, "+" + c->GetModes(true, true), "," + user->GetUID()); + + /* Note that we can send this with the FJOIN but choose not to + * because the mode stacker will handle this and probably will + * merge these modes with +nrt and other mlocked modes + */ + if (status) + { + /* First save the channel status incase uc->Status == status */ + ChannelStatus cs = *status; + /* If the user is internally on the channel with flags, kill them so that + * the stacker will allow this. + */ + ChanUserContainer *uc = c->FindUser(user); + if (uc != NULL) + uc->status.Clear(); - void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) override - { - if (!vIdent.empty()) - this->SendChgIdentInternal(u->nick, vIdent); - if (!vhost.empty()) - this->SendChgHostInternal(u->nick, vhost); - } + ServiceBot *setter = ServiceBot::Find(user->nick); + for (size_t i = 0; i < cs.Modes().length(); ++i) + c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); - /* SVSHOLD - set */ - void SendSVSHold(const Anope::string &nick, time_t t) override - { - Uplink::Send(Config->GetClient("NickServ"), "SVSHOLD", nick, t, "Being held for registered user"); + if (uc != NULL) + uc->status = cs; } +} - /* SVSHOLD - release */ - void SendSVSHoldDel(const Anope::string &nick) override - { - Uplink::Send(Config->GetClient("NickServ"), "SVSHOLD", nick); - } +/* UNSQLINE */ +void inspircd20::Proto::SendSQLineDel(XLine *x) +{ + SendDelLine("Q", x->GetMask()); +} - /* UNSZLINE */ - void SendSZLineDel(XLine *x) override - { - SendDelLine("Z", x->GetHost()); - } +/* SQLINE */ +void inspircd20::Proto::SendSQLine(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("Q", x->GetMask(), timeleft, x->GetBy(), x->GetReason()); +} - /* SZLINE */ - void SendSZLine(User *, XLine *x) override - { - // 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()); - } +void inspircd20::Proto::SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) +{ + if (!vIdent.empty()) + this->SendChgIdentInternal(u->nick, vIdent); + if (!vhost.empty()) + this->SendChgHostInternal(u->nick, vhost); +} - void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) override - { - Uplink::Send(source, "SVSJOIN", u->GetUID(), chan); - } +/* SVSHOLD - set */ +void inspircd20::Proto::SendSVSHold(const Anope::string &nick, time_t t) +{ + Uplink::Send(Config->GetClient("NickServ"), "SVSHOLD", nick, t, "Being held for registered user"); +} - void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) override - { - if (!param.empty()) - Uplink::Send(source, "SVSPART", u->GetUID(), chan, param); - else - Uplink::Send(source, "SVSPART", u->GetUID(), chan); - } +/* SVSHOLD - release */ +void inspircd20::Proto::SendSVSHoldDel(const Anope::string &nick) +{ + Uplink::Send(Config->GetClient("NickServ"), "SVSHOLD", nick); +} - void SendSWhois(const MessageSource &, const Anope::string &who, const Anope::string &mask) override - { - User *u = User::Find(who); +/* UNSZLINE */ +void inspircd20::Proto::SendSZLineDel(XLine *x) +{ + SendDelLine("Z", x->GetHost()); +} - Uplink::Send(Me, "METADATA", u->GetUID(), "swhois", mask); - } +/* SZLINE */ +void inspircd20::Proto::SendSZLine(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()); +} - void SendBOB() override - { - 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::SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) +{ + Uplink::Send(source, "SVSJOIN", u->GetUID(), chan); +} - void SendEOB() override - { - Uplink::Send(Me, "ENDBURST"); - } +void inspircd20::Proto::SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) +{ + if (!param.empty()) + Uplink::Send(source, "SVSPART", u->GetUID(), chan, param); + else + Uplink::Send(source, "SVSPART", u->GetUID(), chan); +} - void SendGlobops(const MessageSource &source, const Anope::string &buf) override - { - if (Servers::Capab.count("GLOBOPS")) - Uplink::Send(source, "SNONOTICE", "g", buf); - else - Uplink::Send(source, "SNONOTICE", "A", buf); - } +void inspircd20::Proto::SendSWhois(const MessageSource &, const Anope::string &who, const Anope::string &mask) +{ + User *u = User::Find(who); - void SendLogin(User *u, NickServ::Nick *na) override - { - /* 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(), "swhois", mask); +} - Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", na->GetAccount()->GetDisplay()); - } +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 SendLogout(User *u) override - { - Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", ""); - } +void inspircd20::Proto::SendEOB() +{ + Uplink::Send(Me, "ENDBURST"); +} - void SendChannel(Channel *c) override - { - Uplink::Send(Me, "FJOIN", c->name, c->creation_time, "+" + c->GetModes(true, true), ""); - } +void inspircd20::Proto::SendGlobops(const MessageSource &source, const Anope::string &buf) +{ + if (Servers::Capab.count("GLOBOPS")) + Uplink::Send(source, "SNONOTICE", "g", buf); + else + Uplink::Send(source, "SNONOTICE", "A", buf); +} - void SendSASLMechanisms(std::vector<Anope::string> &mechanisms) override - { - Anope::string mechlist; - for (unsigned i = 0; i < mechanisms.size(); ++i) - mechlist += "," + mechanisms[i]; +void inspircd20::Proto::SendLogin(User *u, NickServ::Nick *na) +{ + /* 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", "*", "saslmechlist", mechlist.empty() ? "" : mechlist.substr(1)); - } + Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", na->GetAccount()->GetDisplay()); +} - void SendSASLMessage(const SASL::Message &message) override - { - 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); - } +void inspircd20::Proto::SendLogout(User *u) +{ + Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", ""); +} - void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) override - { - Uplink::Send(Me, "METADATA", uid, "accountname", acc); +void inspircd20::Proto::SendChannel(Channel *c) +{ + Uplink::Send(Me, "FJOIN", c->name, c->creation_time, "+" + c->GetModes(true, true), ""); +} - SASLUser su; - su.uid = uid; - su.acc = acc; - su.created = Anope::CurTime; +void inspircd20::Proto::SendSASLMechanisms(std::vector<Anope::string> &mechanisms) +{ + Anope::string mechlist; + for (unsigned i = 0; i < mechanisms.size(); ++i) + mechlist += "," + mechanisms[i]; - for (std::list<SASLUser>::iterator it = saslusers.begin(); it != saslusers.end();) - { - SASLUser &u = *it; + Uplink::Send(Me, "METADATA", "*", "saslmechlist", mechlist.empty() ? "" : mechlist.substr(1)); +} - if (u.created + 30 < Anope::CurTime || u.uid == uid) - it = saslusers.erase(it); - else - ++it; - } +void inspircd20::Proto::SendSASLMessage(const SASL::Message &message) +{ + 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); +} - saslusers.push_back(su); - } +void inspircd20::Proto::SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) +{ + Uplink::Send(Me, "METADATA", uid, "accountname", acc); - bool IsExtbanValid(const Anope::string &mask) override + SASLUser su; + su.uid = uid; + su.acc = acc; + su.created = Anope::CurTime; + + for (std::list<SASLUser>::iterator it = saslusers.begin(); it != saslusers.end();) { - return mask.length() >= 3 && mask[1] == ':'; + SASLUser &u = *it; + + if (u.created + 30 < Anope::CurTime || u.uid == uid) + it = saslusers.erase(it); + else + ++it; } - bool IsIdentValid(const Anope::string &ident) override - { - if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) - return false; + saslusers.push_back(su); +} - for (unsigned i = 0; i < ident.length(); ++i) - { - const char &c = ident[i]; +bool inspircd20::Proto::IsExtbanValid(const Anope::string &mask) +{ + return mask.length() >= 3 && mask[1] == ':'; +} - if (c >= 'A' && c <= '}') - continue; +bool inspircd20::Proto::IsIdentValid(const Anope::string &ident) +{ + if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned int>("userlen")) + return false; - if ((c >= '0' && c <= '9') || c == '-' || c == '.') - continue; + for (unsigned i = 0; i < ident.length(); ++i) + { + const char &c = ident[i]; - return false; - } + if (c >= 'A' && c <= '}') + continue; + + if ((c >= '0' && c <= '9') || c == '-' || c == '.') + continue; - return true; + return false; } -}; + + return true; +} class InspIRCdExtBan : public ChannelModeVirtual<ChannelModeList> { @@ -1279,7 +1274,7 @@ class ProtoInspIRCd20 : public Module , public EventHook<Event::MLockEvents> , public EventHook<Event::SetChannelOption> { - InspIRCd20Proto ircd_proto; + inspircd20::Proto ircd_proto; ExtensibleItem<bool> ssl; ServiceReference<ModeLocks> mlocks; diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 98509f9a1..1818c1021 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -24,149 +24,145 @@ #include "modules/protocol/rfc1459.h" #include "modules/protocol/ngircd.h" -class ngIRCdProto : public IRCDProto +void ngircd::Proto::SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) { - void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override - { - IRCDProto::SendSVSKill(source, user, buf); - user->KillInternal(source, buf); - } + IRCDProto::SendSVSKill(source, user, buf); + user->KillInternal(source, buf); +} - public: - ngIRCdProto(Module *creator) : IRCDProto(creator, "ngIRCd") - { - DefaultPseudoclientModes = "+oi"; - CanCertFP = true; - CanSVSNick = true; - CanSetVHost = true; - CanSetVIdent = true; - MaxModes = 5; - } +ngircd::Proto::Proto(Module *creator) : IRCDProto(creator, "ngIRCd") +{ + DefaultPseudoclientModes = "+oi"; + CanCertFP = true; + CanSVSNick = true; + CanSetVHost = true; + CanSetVIdent = true; + MaxModes = 5; +} - void SendAkill(User *u, XLine *x) override - { - // 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; - Uplink::Send(Me, "GLINE", x->GetMask(), timeleft, x->GetReason() + " (" + x->GetBy() + ")"); - } +void ngircd::Proto::SendAkill(User *u, 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; + Uplink::Send(Me, "GLINE", x->GetMask(), timeleft, x->GetReason() + " (" + x->GetBy() + ")"); +} - void SendAkillDel(XLine *x) override - { - Uplink::Send(Me, "GLINE", x->GetMask()); - } +void ngircd::Proto::SendAkillDel(XLine *x) +{ + Uplink::Send(Me, "GLINE", x->GetMask()); +} - void SendChannel(Channel *c) override - { - Uplink::Send(Me, "CHANINFO", c->name, "+" + c->GetModes(true, true)); - } +void ngircd::Proto::SendChannel(Channel *c) +{ + Uplink::Send(Me, "CHANINFO", c->name, "+" + c->GetModes(true, true)); +} - // Received: :dev.anope.de NICK DukeP 1 ~DukePyro p57ABF9C9.dip.t-dialin.net 1 +i :DukePyrolator - void SendClientIntroduction(User *u) override - { - Anope::string modes = "+" + u->GetModes(); - Uplink::Send(Me, "NICK", u->nick, 1, u->GetIdent(), u->host, 1, modes, u->realname); - } +// Received: :dev.anope.de NICK DukeP 1 ~DukePyro p57ABF9C9.dip.t-dialin.net 1 +i :DukePyrolator +void ngircd::Proto::SendClientIntroduction(User *u) +{ + Anope::string modes = "+" + u->GetModes(); + Uplink::Send(Me, "NICK", u->nick, 1, u->GetIdent(), u->host, 1, modes, u->realname); +} - void SendConnect() override - { - Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "0210-IRC+", "Anope|" + Anope::VersionShort(), "CLHMSo P"); - /* Make myself known to myself in the serverlist */ - SendServer(Me); - /* finish the enhanced server handshake and register the connection */ - Uplink::Send("376", "*", "End of MOTD command"); - } +void ngircd::Proto::SendConnect() +{ + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "0210-IRC+", "Anope|" + Anope::VersionShort(), "CLHMSo P"); + /* Make myself known to myself in the serverlist */ + SendServer(Me); + /* finish the enhanced server handshake and register the connection */ + Uplink::Send("376", "*", "End of MOTD command"); +} - void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override - { - Uplink::Send(Me, "SVSNICK", u->nick, newnick); - } +void ngircd::Proto::SendForceNickChange(User *u, const Anope::string &newnick, time_t when) +{ + Uplink::Send(Me, "SVSNICK", u->nick, newnick); +} - void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); - } +void ngircd::Proto::SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); +} - void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); - } +void ngircd::Proto::SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); +} - void SendGlobops(const MessageSource &source, const Anope::string &buf) override - { - Uplink::Send(source, "WALLOPS", buf); - } +void ngircd::Proto::SendGlobops(const MessageSource &source, const Anope::string &buf) +{ + Uplink::Send(source, "WALLOPS", buf); +} - void SendJoin(User *user, Channel *c, const ChannelStatus *status) override +void ngircd::Proto::SendJoin(User *user, Channel *c, const ChannelStatus *status) +{ + Uplink::Send(user, "JOIN", c->name); + if (status) { - Uplink::Send(user, "JOIN", c->name); - if (status) - { - /* First save the channel status incase uc->Status == status */ - ChannelStatus cs = *status; - /* If the user is internally on the channel with flags, kill them so that - * the stacker will allow this. - */ - ChanUserContainer *uc = c->FindUser(user); - if (uc != NULL) - uc->status.Clear(); - - ServiceBot *setter = ServiceBot::Find(user->GetUID()); - for (size_t i = 0; i < cs.Modes().length(); ++i) - c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); - - if (uc != NULL) - uc->status = cs; - } - } + /* First save the channel status incase uc->Status == status */ + ChannelStatus cs = *status; + /* If the user is internally on the channel with flags, kill them so that + * the stacker will allow this. + */ + ChanUserContainer *uc = c->FindUser(user); + if (uc != NULL) + uc->status.Clear(); - void SendLogin(User *u, NickServ::Nick *na) override - { - Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", na->GetAccount()->GetDisplay()); - } + ServiceBot *setter = ServiceBot::Find(user->GetUID()); + for (size_t i = 0; i < cs.Modes().length(); ++i) + c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); - void SendLogout(User *u) override - { - Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", ""); + if (uc != NULL) + uc->status = cs; } +} - /* SERVER name hop descript */ - void SendServer(Server *server) override - { - Uplink::Send("SERVER", server->GetName(), server->GetHops(), server->GetDescription()); - } +void ngircd::Proto::SendLogin(User *u, NickServ::Nick *na) +{ + Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", na->GetAccount()->GetDisplay()); +} - void SendTopic(const MessageSource &source, Channel *c) override - { - Uplink::Send(source, "TOPIC", c->name, c->topic); - } +void ngircd::Proto::SendLogout(User *u) +{ + Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", ""); +} - void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) override - { - if (!vIdent.empty()) - Uplink::Send(Me, "METADATA", u->nick, "user", vIdent); +/* SERVER name hop descript */ +void ngircd::Proto::SendServer(Server *server) +{ + Uplink::Send("SERVER", server->GetName(), server->GetHops(), server->GetDescription()); +} - Uplink::Send(Me, "METADATA", u->nick, "cloakhost", vhost); - if (!u->HasMode("CLOAK")) - { - u->SetMode(Config->GetClient("HostServ"), "CLOAK"); - ModeManager::ProcessModes(); - } - } +void ngircd::Proto::SendTopic(const MessageSource &source, Channel *c) +{ + Uplink::Send(source, "TOPIC", c->name, c->topic); +} - void SendVhostDel(User *u) override - { - this->SendVhost(u, u->GetIdent(), ""); - } +void ngircd::Proto::SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) +{ + if (!vIdent.empty()) + Uplink::Send(Me, "METADATA", u->nick, "user", vIdent); - Anope::string Format(IRCMessage &message) + Uplink::Send(Me, "METADATA", u->nick, "cloakhost", vhost); + if (!u->HasMode("CLOAK")) { - if (message.GetSource().GetSource().empty()) - message.SetSource(Me); - return IRCDProto::Format(message); + u->SetMode(Config->GetClient("HostServ"), "CLOAK"); + ModeManager::ProcessModes(); } -}; +} + +void ngircd::Proto::SendVhostDel(User *u) +{ + this->SendVhost(u, u->GetIdent(), ""); +} + +Anope::string ngircd::Proto::Format(IRCMessage &message) +{ + if (message.GetSource().GetSource().empty()) + message.SetSource(Me); + return IRCDProto::Format(message); +} // Please see <http://www.irc.org/tech_docs/005.html> for details. void ngircd::Numeric005::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) @@ -518,7 +514,7 @@ void ngircd::ServerMessage::Run(MessageSource &source, const std::vector<Anope:: class ProtongIRCd : public Module , public EventHook<Event::UserNickChange> { - ngIRCdProto ircd_proto; + ngircd::Proto ircd_proto; /* Core message handlers */ rfc1459::Capab message_capab; diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index cb1509a5e..eb1fe48b5 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -25,164 +25,144 @@ static Anope::string UplinkSID; -class PlexusProto : public IRCDProto +plexus::Proto::Proto(Module *creator) : IRCDProto(creator, "hybrid-7.2.3+plexus-3.0.1") + , hybrid("hybrid") { - ServiceReference<IRCDProto> hybrid; // XXX use moddeps + inheritance here - - public: - PlexusProto(Module *creator) : IRCDProto(creator, "hybrid-7.2.3+plexus-3.0.1") - , hybrid("hybrid") - { - DefaultPseudoclientModes = "+oiU"; - CanSVSNick = true; - CanSVSJoin = true; - CanSetVHost = true; - CanSetVIdent = true; - CanSNLine = true; - CanSQLine = true; - CanSQLineChannel = true; - CanSVSHold = true; - CanCertFP = true; - RequiresID = true; - MaxModes = 4; - } + DefaultPseudoclientModes = "+oiU"; + CanSVSNick = true; + CanSVSJoin = true; + CanSetVHost = true; + CanSetVIdent = true; + CanSNLine = true; + CanSQLine = true; + CanSQLineChannel = true; + CanSVSHold = true; + CanCertFP = true; + RequiresID = true; + MaxModes = 4; +} - void SendSVSKill(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKill(source, targ, reason); } - void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override { hybrid->SendGlobalNotice(bi, dest, msg); } - void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override { hybrid->SendGlobalPrivmsg(bi, dest, msg); } - void SendSQLine(User *u, XLine *x) override { hybrid->SendSQLine(u, x); } - void SendSQLineDel(XLine *x) override { hybrid->SendSQLineDel(x); } - void SendSGLineDel(XLine *x) override { hybrid->SendSGLineDel(x); } - void SendSGLine(User *u, XLine *x) override { hybrid->SendSGLine(u, x); } - void SendAkillDel(XLine *x) override { hybrid->SendAkillDel(x); } - void SendAkill(User *u, XLine *x) override { hybrid->SendAkill(u, x); } - void SendServer(Server *server) override { hybrid->SendServer(server); } - void SendChannel(Channel *c) override { hybrid->SendChannel(c); } - void SendSVSHold(const Anope::string &nick, time_t t) override { hybrid->SendSVSHold(nick, t); } - void SendSVSHoldDel(const Anope::string &nick) override { hybrid->SendSVSHoldDel(nick); } - - void SendGlobops(const MessageSource &source, const Anope::string &buf) override - { - Uplink::Send(source, "OPERWALL", buf); - } +void plexus::Proto::SendGlobops(const MessageSource &source, const Anope::string &buf) +{ + Uplink::Send(source, "OPERWALL", buf); +} - void SendJoin(User *user, Channel *c, const ChannelStatus *status) override +void plexus::Proto::SendJoin(User *user, Channel *c, const ChannelStatus *status) +{ + Uplink::Send(Me, "SJOIN", c->creation_time, c->name, "+" + c->GetModes(true, true), user->GetUID()); + if (status) { - Uplink::Send(Me, "SJOIN", c->creation_time, c->name, "+" + c->GetModes(true, true), user->GetUID()); - if (status) - { - /* First save the channel status incase uc->Status == status */ - ChannelStatus cs = *status; - /* If the user is internally on the channel with flags, kill them so that - * the stacker will allow this. - */ - ChanUserContainer *uc = c->FindUser(user); - if (uc != NULL) - uc->status.Clear(); - - ServiceBot *setter = ServiceBot::Find(user->GetUID()); - for (size_t i = 0; i < cs.Modes().length(); ++i) - c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); - - if (uc != NULL) - uc->status = cs; - } - } + /* First save the channel status incase uc->Status == status */ + ChannelStatus cs = *status; + /* If the user is internally on the channel with flags, kill them so that + * the stacker will allow this. + */ + ChanUserContainer *uc = c->FindUser(user); + if (uc != NULL) + uc->status.Clear(); - void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override - { - Uplink::Send(Me, "ENCAP", u->server->GetName(), "SVSNICK", u->GetUID(), u->timestamp, newnick, when); - } + ServiceBot *setter = ServiceBot::Find(user->GetUID()); + for (size_t i = 0; i < cs.Modes().length(); ++i) + c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); - void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) override - { - if (!ident.empty()) - Uplink::Send(Me, "ENCAP", "*", "CHGIDENT", u->GetUID(), ident); - Uplink::Send(Me, "ENCAP", "*", "CHGHOST", u->GetUID(), host); - u->SetMode(Config->GetClient("HostServ"), "CLOAK"); + if (uc != NULL) + uc->status = cs; } +} - void SendVhostDel(User *u) override - { - u->RemoveMode(Config->GetClient("HostServ"), "CLOAK"); - } +void plexus::Proto::SendForceNickChange(User *u, const Anope::string &newnick, time_t when) +{ + Uplink::Send(Me, "ENCAP", u->server->GetName(), "SVSNICK", u->GetUID(), u->timestamp, newnick, when); +} - void SendConnect() override - { - Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS", 6, Me->GetSID()); - - /* CAPAB - * QS - Can handle quit storm removal - * EX - Can do channel +e exemptions - * CHW - Can do channel wall @# - * LL - Can do lazy links - * IE - Can do invite exceptions - * EOB - Can do EOB message - * KLN - Can do KLINE message - * GLN - Can do GLINE message - * HUB - This server is a HUB - * AOPS - Can do anon ops (+a) - * UID - Can do UIDs - * ZIP - Can do ZIPlinks - * ENC - Can do ENCrypted links - * KNOCK - Supports KNOCK - * TBURST - Supports TBURST - * PARA - Supports invite broadcasting for +p - * ENCAP - Supports encapsulization of protocol messages - * SVS - Supports services protocol extensions - */ - Uplink::Send("CAPAB", "QS EX CHW IE EOB KLN UNKLN GLN HUB KNOCK TBURST PARA ENCAP SVS"); - - /* Make myself known to myself in the serverlist */ - SendServer(Me); - - /* - * SVINFO - * parv[0] = sender prefix - * parv[1] = TS_CURRENT for the server - * parv[2] = TS_MIN for the server - * parv[3] = server is standalone or connected to non-TS only - * parv[4] = server's idea of UTC time - */ - Uplink::Send("SVINFO", 6, 6, 0, Anope::CurTime); - } +void plexus::Proto::SendVhost(User *u, const Anope::string &ident, const Anope::string &host) +{ + if (!ident.empty()) + Uplink::Send(Me, "ENCAP", "*", "CHGIDENT", u->GetUID(), ident); + Uplink::Send(Me, "ENCAP", "*", "CHGHOST", u->GetUID(), host); + u->SetMode(Config->GetClient("HostServ"), "CLOAK"); +} - void SendClientIntroduction(User *u) override - { - Anope::string modes = "+" + u->GetModes(); - Uplink::Send(Me, "UID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, "255.255.255.255", u->GetUID(), 0, u->host, u->realname); - } +void plexus::Proto::SendVhostDel(User *u) +{ + u->RemoveMode(Config->GetClient("HostServ"), "CLOAK"); +} - void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override - { - Uplink::Send(source, "ENCAP", "*", "SVSMODE", u->GetUID(), u->timestamp, buf); - } +void plexus::Proto::SendConnect() +{ + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS", 6, Me->GetSID()); + + /* CAPAB + * QS - Can handle quit storm removal + * EX - Can do channel +e exemptions + * CHW - Can do channel wall @# + * LL - Can do lazy links + * IE - Can do invite exceptions + * EOB - Can do EOB message + * KLN - Can do KLINE message + * GLN - Can do GLINE message + * HUB - This server is a HUB + * AOPS - Can do anon ops (+a) + * UID - Can do UIDs + * ZIP - Can do ZIPlinks + * ENC - Can do ENCrypted links + * KNOCK - Supports KNOCK + * TBURST - Supports TBURST + * PARA - Supports invite broadcasting for +p + * ENCAP - Supports encapsulization of protocol messages + * SVS - Supports services protocol extensions + */ + Uplink::Send("CAPAB", "QS EX CHW IE EOB KLN UNKLN GLN HUB KNOCK TBURST PARA ENCAP SVS"); - void SendLogin(User *u, NickServ::Nick *na) override - { - Uplink::Send(Me, "ENCAP", "*", "SU", u->GetUID(), na->GetAccount()->GetDisplay()); - } + /* Make myself known to myself in the serverlist */ + SendServer(Me); - void SendLogout(User *u) override - { - Uplink::Send(Me, "ENCAP", "*", "SU", u->GetUID(), ""); - } + /* + * SVINFO + * parv[0] = sender prefix + * parv[1] = TS_CURRENT for the server + * parv[2] = TS_MIN for the server + * parv[3] = server is standalone or connected to non-TS only + * parv[4] = server's idea of UTC time + */ + Uplink::Send("SVINFO", 6, 6, 0, Anope::CurTime); +} - void SendTopic(const MessageSource &source, Channel *c) override - { - Uplink::Send(source, "ENCAP", "*", "TOPIC", c->name, c->topic_setter, c->topic_ts, c->topic); - } +void plexus::Proto::SendClientIntroduction(User *u) +{ + Anope::string modes = "+" + u->GetModes(); + Uplink::Send(Me, "UID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, "255.255.255.255", u->GetUID(), 0, u->host, u->realname); +} - void SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) override - { - Uplink::Send(source, "ENCAP", user->server->GetName(), "SVSJOIN", user->GetUID(), chan); - } +void plexus::Proto::SendMode(const MessageSource &source, User *u, const Anope::string &buf) +{ + Uplink::Send(source, "ENCAP", "*", "SVSMODE", u->GetUID(), u->timestamp, buf); +} - void SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) override - { - Uplink::Send(source, "ENCAP", user->server->GetName(), "SVSPART", user->GetUID(), chan); - } -}; +void plexus::Proto::SendLogin(User *u, NickServ::Nick *na) +{ + Uplink::Send(Me, "ENCAP", "*", "SU", u->GetUID(), na->GetAccount()->GetDisplay()); +} + +void plexus::Proto::SendLogout(User *u) +{ + Uplink::Send(Me, "ENCAP", "*", "SU", u->GetUID(), ""); +} + +void plexus::Proto::SendTopic(const MessageSource &source, Channel *c) +{ + Uplink::Send(source, "ENCAP", "*", "TOPIC", c->name, c->topic_setter, c->topic_ts, c->topic); +} + +void plexus::Proto::SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) +{ + Uplink::Send(source, "ENCAP", user->server->GetName(), "SVSJOIN", user->GetUID(), chan); +} + +void plexus::Proto::SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) +{ + Uplink::Send(source, "ENCAP", user->server->GetName(), "SVSPART", user->GetUID(), chan); +} void plexus::Encap::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { @@ -291,7 +271,7 @@ class ProtoPlexus : public Module { Module *m_hybrid; - PlexusProto ircd_proto; + plexus::Proto ircd_proto; /* Core message handlers */ rfc1459::Away message_away; diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index 04f1314cc..592002578 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -25,146 +25,126 @@ static Anope::string UplinkSID; -class RatboxProto : public IRCDProto +ServiceBot *ratbox::Proto::FindIntroduced() { - ServiceReference<IRCDProto> hybrid; // XXX + ServiceBot *bi = Config->GetClient("OperServ"); + if (bi && bi->introduced) + return bi; - ServiceBot *FindIntroduced() + for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { - ServiceBot *bi = Config->GetClient("OperServ"); - if (bi && bi->introduced) - return bi; - - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + User *u = it->second; + if (u->type == UserType::BOT) { - User *u = it->second; - if (u->type == UserType::BOT) - { - bi = anope_dynamic_static_cast<ServiceBot *>(u); - if (bi->introduced) - return bi; - } + bi = anope_dynamic_static_cast<ServiceBot *>(u); + if (bi->introduced) + return bi; } - - return NULL; - } - - public: - RatboxProto(Module *creator) : IRCDProto(creator, "Ratbox 3.0+") - , hybrid("hybrid") - { - DefaultPseudoclientModes = "+oiS"; - CanSNLine = true; - CanSQLine = true; - CanSQLineChannel = true; - CanSZLine = true; - RequiresID = true; - MaxModes = 4; } - void SendSVSKill(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKill(source, targ, reason); } - void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override { hybrid->SendGlobalNotice(bi, dest, msg); } - void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override { hybrid->SendGlobalPrivmsg(bi, dest, msg); } - void SendSGLine(User *u, XLine *x) override { hybrid->SendSGLine(u, x); } - void SendSGLineDel(XLine *x) override { hybrid->SendSGLineDel(x); } - void SendAkill(User *u, XLine *x) override { hybrid->SendAkill(u, x); } - void SendAkillDel(XLine *x) override { hybrid->SendAkillDel(x); } - void SendJoin(User *user, Channel *c, const ChannelStatus *status) override { hybrid->SendJoin(user, c, status); } - void SendServer(Server *server) override { hybrid->SendServer(server); } - void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override { hybrid->SendMode(source, u, buf); } - void SendChannel(Channel *c) override { hybrid->SendChannel(c); } - bool IsIdentValid(const Anope::string &ident) override { return hybrid->IsIdentValid(ident); } - - void SendGlobops(const MessageSource &source, const Anope::string &buf) override - { - Uplink::Send(source, "OPERWALL", buf); - } + return NULL; +} - void SendConnect() override - { - Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS", 6, Me->GetSID()); - - /* - QS - Can handle quit storm removal - EX - Can do channel +e exemptions - CHW - Can do channel wall @# - IE - Can do invite exceptions - GLN - Can do GLINE message - KNOCK - supports KNOCK - TB - supports topic burst - ENCAP - supports ENCAP - */ - Uplink::Send("CAPAB", "QS EX CHW IE GLN TB ENCAP"); - - /* Make myself known to myself in the serverlist */ - SendServer(Me); - - /* - * SVINFO - * parv[0] = sender prefix - * parv[1] = TS_CURRENT for the server - * parv[2] = TS_MIN for the server - * parv[3] = server is standalone or connected to non-TS only - * parv[4] = server's idea of UTC time - */ - Uplink::Send("SVINFO", 6, 6, 0, Anope::CurTime); - } +ratbox::Proto::Proto(Module *creator) : IRCDProto(creator, "Ratbox 3.0+") + , hybrid("hybrid") +{ + DefaultPseudoclientModes = "+oiS"; + CanSNLine = true; + CanSQLine = true; + CanSQLineChannel = true; + CanSZLine = true; + RequiresID = true; + MaxModes = 4; +} - void SendClientIntroduction(User *u) override - { - Anope::string modes = "+" + u->GetModes(); - Uplink::Send(Me, "UID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, 0, u->GetUID(), u->realname); - } +void ratbox::Proto::SendGlobops(const MessageSource &source, const Anope::string &buf) +{ + Uplink::Send(source, "OPERWALL", buf); +} - void SendLogin(User *u, NickServ::Nick *na) override - { - if (na->GetAccount()->IsUnconfirmed()) - return; +void ratbox::Proto::SendConnect() +{ + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS", 6, Me->GetSID()); + + /* + QS - Can handle quit storm removal + EX - Can do channel +e exemptions + CHW - Can do channel wall @# + IE - Can do invite exceptions + GLN - Can do GLINE message + KNOCK - supports KNOCK + TB - supports topic burst + ENCAP - supports ENCAP + */ + Uplink::Send("CAPAB", "QS EX CHW IE GLN TB ENCAP"); + + /* Make myself known to myself in the serverlist */ + SendServer(Me); + + /* + * SVINFO + * parv[0] = sender prefix + * parv[1] = TS_CURRENT for the server + * parv[2] = TS_MIN for the server + * parv[3] = server is standalone or connected to non-TS only + * parv[4] = server's idea of UTC time + */ + Uplink::Send("SVINFO", 6, 6, 0, Anope::CurTime); +} - Uplink::Send(Me, "ENCAP", "*", "SU", u->GetUID(), na->GetAccount()->GetDisplay()); - } +void ratbox::Proto::SendClientIntroduction(User *u) +{ + Anope::string modes = "+" + u->GetModes(); + Uplink::Send(Me, "UID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, 0, u->GetUID(), u->realname); +} - void SendLogout(User *u) override - { - Uplink::Send(Me, "ENCAP", "*", "SU", u->GetUID()); - } +void ratbox::Proto::SendLogin(User *u, NickServ::Nick *na) +{ + if (na->GetAccount()->IsUnconfirmed()) + return; - void SendTopic(const MessageSource &source, Channel *c) override - { - ServiceBot *bi = source.GetBot(); - bool needjoin = c->FindUser(bi) == NULL; + Uplink::Send(Me, "ENCAP", "*", "SU", u->GetUID(), na->GetAccount()->GetDisplay()); +} - if (needjoin) - { - ChannelStatus status; +void ratbox::Proto::SendLogout(User *u) +{ + Uplink::Send(Me, "ENCAP", "*", "SU", u->GetUID()); +} - status.AddMode('o'); - bi->Join(c, &status); - } +void ratbox::Proto::SendTopic(const MessageSource &source, Channel *c) +{ + ServiceBot *bi = source.GetBot(); + bool needjoin = c->FindUser(bi) == NULL; - IRCDProto::SendTopic(source, c); + if (needjoin) + { + ChannelStatus status; - if (needjoin) - bi->Part(c); + status.AddMode('o'); + bi->Join(c, &status); } - void SendSQLine(User *, XLine *x) override - { - /* Calculate the time left before this would expire, capping it at 2 days */ - time_t timeleft = x->GetExpires() - Anope::CurTime; + IRCDProto::SendTopic(source, c); - if (timeleft > 172800 || !x->GetExpires()) - timeleft = 172800; + if (needjoin) + bi->Part(c); +} - Uplink::Send(FindIntroduced(), "ENCAP", "*", "RESV", timeleft, x->GetMask(), 0, x->GetReason()); - } +void ratbox::Proto::SendSQLine(User *, XLine *x) +{ + /* Calculate the time left before this would expire, capping it at 2 days */ + time_t timeleft = x->GetExpires() - Anope::CurTime; - void SendSQLineDel(XLine *x) override - { - Uplink::Send(Config->GetClient("OperServ"), "ENCAP", "*", "UNRESV", x->GetMask()); - } + if (timeleft > 172800 || !x->GetExpires()) + timeleft = 172800; -}; + Uplink::Send(FindIntroduced(), "ENCAP", "*", "RESV", timeleft, x->GetMask(), 0, x->GetReason()); +} + +void ratbox::Proto::SendSQLineDel(XLine *x) +{ + Uplink::Send(Config->GetClient("OperServ"), "ENCAP", "*", "UNRESV", x->GetMask()); +} // Debug: Received: :00BAAAAAB ENCAP * LOGIN Adam void ratbox::Encap::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) @@ -262,7 +242,7 @@ void ratbox::UID::Run(MessageSource &source, const std::vector<Anope::string> &p class ProtoRatbox : public Module { - RatboxProto ircd_proto; + ratbox::Proto ircd_proto; /* Core message handlers */ rfc1459::Away message_away; diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 259a64c9c..4a4a0c4d0 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -28,405 +28,397 @@ static Anope::string UplinkSID; -class UnrealIRCdProto : public IRCDProto +unreal::Proto::Proto(Module *creator) : IRCDProto(creator, "UnrealIRCd 4") { - public: - UnrealIRCdProto(Module *creator) : IRCDProto(creator, "UnrealIRCd 4") - { - DefaultPseudoclientModes = "+Soiq"; - CanSVSNick = true; - CanSVSJoin = true; - CanSetVHost = true; - CanSetVIdent = true; - CanSNLine = true; - CanSQLine = true; - CanSZLine = true; - CanSVSHold = true; - CanCertFP = true; - RequiresID = true; - MaxModes = 12; - } + DefaultPseudoclientModes = "+Soiq"; + CanSVSNick = true; + CanSVSJoin = true; + CanSetVHost = true; + CanSetVIdent = true; + CanSNLine = true; + CanSQLine = true; + CanSZLine = true; + CanSVSHold = true; + CanCertFP = true; + RequiresID = true; + MaxModes = 12; +} - private: - /* SVSNOOP */ - void SendSVSNOOP(Server *server, bool set) override - { - Uplink::Send("SVSNOOP", server->GetSID(), set ? "+" : "-"); - } +/* SVSNOOP */ +void unreal::Proto::SendSVSNOOP(Server *server, bool set) +{ + Uplink::Send("SVSNOOP", server->GetSID(), set ? "+" : "-"); +} - void SendAkillDel(XLine *x) override - { - if (x->IsRegex() || x->HasNickOrReal()) - return; +void unreal::Proto::SendAkillDel(XLine *x) +{ + if (x->IsRegex() || x->HasNickOrReal()) + return; - /* ZLine if we can instead */ - if (x->GetUser() == "*") + /* ZLine if we can instead */ + if (x->GetUser() == "*") + { + cidr a(x->GetHost()); + if (a.valid()) { - cidr a(x->GetHost()); - if (a.valid()) - { - IRCD->SendSZLineDel(x); - return; - } + IRCD->SendSZLineDel(x); + return; } - - Uplink::Send("TKL", "-", "G", x->GetUser(), x->GetHost(), x->GetBy()); } - void SendTopic(const MessageSource &source, Channel *c) override - { - Uplink::Send(source, "TOPIC", c->name, c->topic_setter, c->topic_ts, c->topic); - } + Uplink::Send("TKL", "-", "G", x->GetUser(), x->GetHost(), x->GetBy()); +} - void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); - } +void unreal::Proto::SendTopic(const MessageSource &source, Channel *c) +{ + Uplink::Send(source, "TOPIC", c->name, c->topic_setter, c->topic_ts, c->topic); +} - void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); - } +void unreal::Proto::SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); +} - void SendVhostDel(User *u) override - { - ServiceBot *HostServ = Config->GetClient("HostServ"); - u->RemoveMode(HostServ, "CLOAK"); - u->RemoveMode(HostServ, "VHOST"); - ModeManager::ProcessModes(); - u->SetMode(HostServ, "CLOAK"); - } +void unreal::Proto::SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); +} + +void unreal::Proto::SendVhostDel(User *u) +{ + ServiceBot *HostServ = Config->GetClient("HostServ"); + u->RemoveMode(HostServ, "CLOAK"); + u->RemoveMode(HostServ, "VHOST"); + ModeManager::ProcessModes(); + u->SetMode(HostServ, "CLOAK"); +} - void SendAkill(User *u, XLine *x) override +void unreal::Proto::SendAkill(User *u, XLine *x) +{ + if (x->IsRegex() || x->HasNickOrReal()) { - if (x->IsRegex() || x->HasNickOrReal()) + if (!u) { - if (!u) - { - /* 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); - return; - } - - XLine *old = x; - - if (old->GetManager()->HasEntry("*@" + u->host)) - return; + /* 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); + return; + } - /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ - XLine *xl = Serialize::New<XLine *>(); - xl->SetMask("*@" + u->host); - xl->SetBy(old->GetBy()); - xl->SetExpires(old->GetExpires()); - xl->SetReason(old->GetReason()); - xl->SetID(old->GetID()); + XLine *old = x; - old->GetManager()->AddXLine(xl); - x = xl; + if (old->GetManager()->HasEntry("*@" + u->host)) + return; - Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" << u->realname << " matches " << old->GetMask(); - } + /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ + XLine *xl = Serialize::New<XLine *>(); + xl->SetMask("*@" + u->host); + xl->SetBy(old->GetBy()); + xl->SetExpires(old->GetExpires()); + xl->SetReason(old->GetReason()); + xl->SetID(old->GetID()); - /* ZLine if we can instead */ - if (x->GetUser() == "*") - { - cidr a(x->GetHost()); - if (a.valid()) - { - IRCD->SendSZLine(u, x); - return; - } - } + old->GetManager()->AddXLine(xl); + x = xl; - // 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; - Uplink::Send("TKL", "+", "G", x->GetUser(), x->GetHost(), x->GetBy(), Anope::CurTime + timeleft, x->GetCreated(), x->GetReason()); + Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" << u->realname << " matches " << old->GetMask(); } - void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override + /* ZLine if we can instead */ + if (x->GetUser() == "*") { - Uplink::Send(source, "SVSKILL", user->GetUID(), buf); - user->KillInternal(source, buf); + cidr a(x->GetHost()); + if (a.valid()) + { + IRCD->SendSZLine(u, x); + return; + } } - void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override - { - IRCMessage message(source, "SVS2MODE", u->GetUID()); - message.TokenizeAndPush(buf); - Uplink::SendMessage(message); - } + // 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; + Uplink::Send("TKL", "+", "G", x->GetUser(), x->GetHost(), x->GetBy(), Anope::CurTime + timeleft, x->GetCreated(), x->GetReason()); +} - void SendClientIntroduction(User *u) override - { - Anope::string modes = "+" + u->GetModes(); - Uplink::Send("UID", u->nick, 1, u->timestamp, u->GetIdent(), u->host, u->GetUID(), "*", modes, !u->vhost.empty() ? u->vhost : "*", !u->chost.empty() ? u->chost : "*", "*", u->realname); - } +void unreal::Proto::SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) +{ + Uplink::Send(source, "SVSKILL", user->GetUID(), buf); + user->KillInternal(source, buf); +} - /* SERVER name hop descript */ - /* Unreal 3.2 actually sends some info about itself in the descript area */ - void SendServer(Server *server) override - { - if (!server->GetSID().empty() && server == Me) - Uplink::Send("SERVER", server->GetName(), server->GetHops() + 1, server->GetDescription()); - else - Uplink::Send("SID", server->GetName(), server->GetHops() + 1, server->GetSID(), server->GetDescription()); - } +void unreal::Proto::SendMode(const MessageSource &source, User *u, const Anope::string &buf) +{ + IRCMessage message(source, "SVS2MODE", u->GetUID()); + message.TokenizeAndPush(buf); + Uplink::SendMessage(message); +} - /* JOIN */ - void SendJoin(User *user, Channel *c, const ChannelStatus *status) override - { - Uplink::Send(Me, "SJOIN", c->creation_time, c->name, user->GetUID()); - if (status) - { - /* First save the channel status incase uc->Status == status */ - ChannelStatus cs = *status; - /* If the user is internally on the channel with flags, kill them so that - * the stacker will allow this. - */ - ChanUserContainer *uc = c->FindUser(user); - if (uc != NULL) - uc->status.Clear(); - - ServiceBot *setter = ServiceBot::Find(user->GetUID()); - for (size_t i = 0; i < cs.Modes().length(); ++i) - c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); - - if (uc != NULL) - uc->status = cs; - } - } +void unreal::Proto::SendClientIntroduction(User *u) +{ + Anope::string modes = "+" + u->GetModes(); + Uplink::Send("UID", u->nick, 1, u->timestamp, u->GetIdent(), u->host, u->GetUID(), "*", modes, !u->vhost.empty() ? u->vhost : "*", !u->chost.empty() ? u->chost : "*", "*", u->realname); +} - /* unsqline - */ - void SendSQLineDel(XLine *x) override - { - Uplink::Send("UNSQLINE", x->GetMask()); - } +/* SERVER name hop descript */ +/* Unreal 3.2 actually sends some info about itself in the descript area */ +void unreal::Proto::SendServer(Server *server) +{ + if (!server->GetSID().empty() && server == Me) + Uplink::Send("SERVER", server->GetName(), server->GetHops() + 1, server->GetDescription()); + else + Uplink::Send("SID", server->GetName(), server->GetHops() + 1, server->GetSID(), server->GetDescription()); +} - /* SQLINE */ - /* - ** - Unreal will translate this to TKL for us - ** - */ - void SendSQLine(User *, XLine *x) override +/* JOIN */ +void unreal::Proto::SendJoin(User *user, Channel *c, const ChannelStatus *status) +{ + Uplink::Send(Me, "SJOIN", c->creation_time, c->name, user->GetUID()); + if (status) { - Uplink::Send("SQLINE", x->GetMask(), x->GetReason()); - } + /* First save the channel status incase uc->Status == status */ + ChannelStatus cs = *status; + /* If the user is internally on the channel with flags, kill them so that + * the stacker will allow this. + */ + ChanUserContainer *uc = c->FindUser(user); + if (uc != NULL) + uc->status.Clear(); - /* Functions that use serval cmd functions */ + ServiceBot *setter = ServiceBot::Find(user->GetUID()); + for (size_t i = 0; i < cs.Modes().length(); ++i) + c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); - void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) override - { - if (!vIdent.empty()) - Uplink::Send(Me, "CHGIDENT", u->GetUID(), vIdent); - if (!vhost.empty()) - Uplink::Send(Me, "CHGHOST", u->GetUID(), vhost); + if (uc != NULL) + uc->status = cs; } +} - void SendConnect() override - { - /* - NICKv2 = Nick Version 2 - VHP = Sends hidden host - UMODE2 = sends UMODE2 on user modes - NICKIP = Sends IP on NICK - SJ3 = Supports SJOIN - NOQUIT = No Quit - TKLEXT = Extended TKL we don't use it but best to have it - MLOCK = Supports the MLOCK server command - VL = Version Info - SID = SID/UID mode - */ - Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password); - Uplink::Send("PROTOCTL", "NICKv2", "VHP", "UMODE2", "NICKIP", "SJOIN", "SJOIN2", "SJ3", "NOQUIT", "TKLEXT", "MLOCK", "SID"); - Uplink::Send("PROTOCTL", "EAUTH=" + Me->GetName() + ",,,Anope-" + Anope::VersionShort()); - Uplink::Send("PROTOCTL", "SID=" + Me->GetSID()); - SendServer(Me); - } +/* unsqline +*/ +void unreal::Proto::SendSQLineDel(XLine *x) +{ + Uplink::Send("UNSQLINE", x->GetMask()); +} - /* SVSHOLD - set */ - void SendSVSHold(const Anope::string &nick, time_t t) override - { - Uplink::Send("TKL", "+", "Q", "H", nick, Me->GetName(), Anope::CurTime + t, Anope::CurTime, "Being held for registered user"); - } +/* SQLINE */ +/* +** - Unreal will translate this to TKL for us +** +*/ +void unreal::Proto::SendSQLine(User *, XLine *x) +{ + Uplink::Send("SQLINE", x->GetMask(), x->GetReason()); +} - /* SVSHOLD - release */ - void SendSVSHoldDel(const Anope::string &nick) override - { - Uplink::Send("TKL", "-", "Q", "*", nick, Me->GetName()); - } +/* Functions that use serval cmd functions */ - /* UNSGLINE */ +void unreal::Proto::SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) +{ + if (!vIdent.empty()) + Uplink::Send(Me, "CHGIDENT", u->GetUID(), vIdent); + if (!vhost.empty()) + Uplink::Send(Me, "CHGHOST", u->GetUID(), vhost); +} + +void unreal::Proto::SendConnect() +{ /* - * SVSNLINE - :realname mask + NICKv2 = Nick Version 2 + VHP = Sends hidden host + UMODE2 = sends UMODE2 on user modes + NICKIP = Sends IP on NICK + SJ3 = Supports SJOIN + NOQUIT = No Quit + TKLEXT = Extended TKL we don't use it but best to have it + MLOCK = Supports the MLOCK server command + VL = Version Info + SID = SID/UID mode */ - void SendSGLineDel(XLine *x) override - { - Uplink::Send("SVSNLINE", "-", x->GetMask()); - } + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password); + Uplink::Send("PROTOCTL", "NICKv2", "VHP", "UMODE2", "NICKIP", "SJOIN", "SJOIN2", "SJ3", "NOQUIT", "TKLEXT", "MLOCK", "SID"); + Uplink::Send("PROTOCTL", "EAUTH=" + Me->GetName() + ",,,Anope-" + Anope::VersionShort()); + Uplink::Send("PROTOCTL", "SID=" + Me->GetSID()); + SendServer(Me); +} - /* UNSZLINE */ - void SendSZLineDel(XLine *x) override - { - Uplink::Send("TKL", "-", "Z", "*", x->GetHost(), x->GetBy()); - } +/* SVSHOLD - set */ +void unreal::Proto::SendSVSHold(const Anope::string &nick, time_t t) +{ + Uplink::Send("TKL", "+", "Q", "H", nick, Me->GetName(), Anope::CurTime + t, Anope::CurTime, "Being held for registered user"); +} - /* SZLINE */ - void SendSZLine(User *, XLine *x) override - { - // 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; - Uplink::Send("TKL", "+", "Z", "*", x->GetHost(), x->GetBy(), Anope::CurTime + timeleft, x->GetCreated(), x->GetReason()); - } +/* SVSHOLD - release */ +void unreal::Proto::SendSVSHoldDel(const Anope::string &nick) +{ + Uplink::Send("TKL", "-", "Q", "*", nick, Me->GetName()); +} - /* SGLINE */ - /* - * SVSNLINE + reason_where_is_space :realname mask with spaces - */ - void SendSGLine(User *, XLine *x) override - { - Anope::string edited_reason = x->GetReason(); - edited_reason = edited_reason.replace_all_cs(" ", "_"); - Uplink::Send("SVSNLINE", "+", edited_reason, x->GetMask()); - } +/* UNSGLINE */ +/* + * SVSNLINE - :realname mask +*/ +void unreal::Proto::SendSGLineDel(XLine *x) +{ + Uplink::Send("SVSNLINE", "-", x->GetMask()); +} - /* svsjoin - parv[0] - sender - parv[1] - nick to make join - parv[2] - channel to join - parv[3] - (optional) channel key(s) - */ - /* In older Unreal SVSJOIN and SVSNLINE tokens were mixed so SVSJOIN and SVSNLINE are broken - when coming from a none TOKEN'd server - */ - void SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) override - { - if (!param.empty()) - Uplink::Send(source, "SVSJOIN", user->GetUID(), chan, param); - else - Uplink::Send(source, "SVSJOIN", user->GetUID(), chan); - } +/* UNSZLINE */ +void unreal::Proto::SendSZLineDel(XLine *x) +{ + Uplink::Send("TKL", "-", "Z", "*", x->GetHost(), x->GetBy()); +} - void SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) override - { - if (!param.empty()) - Uplink::Send(source, "SVSPART", user->GetUID(), chan, param); - else - Uplink::Send(source, "SVSPART", user->GetUID(), chan); - } +/* SZLINE */ +void unreal::Proto::SendSZLine(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; + Uplink::Send("TKL", "+", "Z", "*", x->GetHost(), x->GetBy(), Anope::CurTime + timeleft, x->GetCreated(), x->GetReason()); +} - void SendSWhois(const MessageSource &source, const Anope::string &who, const Anope::string &mask) override - { - Uplink::Send(source, "SWHOIS", who, mask); - } +/* SGLINE */ +/* + * SVSNLINE + reason_where_is_space :realname mask with spaces +*/ +void unreal::Proto::SendSGLine(User *, XLine *x) +{ + Anope::string edited_reason = x->GetReason(); + edited_reason = edited_reason.replace_all_cs(" ", "_"); + Uplink::Send("SVSNLINE", "+", edited_reason, x->GetMask()); +} - void SendEOB() override - { - Uplink::Send(Me, "EOS"); - } +/* svsjoin + parv[0] - sender + parv[1] - nick to make join + parv[2] - channel to join + parv[3] - (optional) channel key(s) +*/ +void unreal::Proto::SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) +{ + if (!param.empty()) + Uplink::Send(source, "SVSJOIN", user->GetUID(), chan, param); + else + Uplink::Send(source, "SVSJOIN", user->GetUID(), chan); +} - bool IsNickValid(const Anope::string &nick) override - { - if (nick.equals_ci("ircd") || nick.equals_ci("irc")) - return false; +void unreal::Proto::SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) +{ + if (!param.empty()) + Uplink::Send(source, "SVSPART", user->GetUID(), chan, param); + else + Uplink::Send(source, "SVSPART", user->GetUID(), chan); +} - return IRCDProto::IsNickValid(nick); - } +void unreal::Proto::SendSWhois(const MessageSource &source, const Anope::string &who, const Anope::string &mask) +{ + Uplink::Send(source, "SWHOIS", who, mask); +} - bool IsChannelValid(const Anope::string &chan) override - { - if (chan.find(':') != Anope::string::npos) - return false; +void unreal::Proto::SendEOB() +{ + Uplink::Send(Me, "EOS"); +} - return IRCDProto::IsChannelValid(chan); - } +bool unreal::Proto::IsNickValid(const Anope::string &nick) +{ + if (nick.equals_ci("ircd") || nick.equals_ci("irc")) + return false; - bool IsExtbanValid(const Anope::string &mask) override - { - return mask.length() >= 4 && mask[0] == '~' && mask[2] == ':'; - } + return IRCDProto::IsNickValid(nick); +} - void SendLogin(User *u, NickServ::Nick *na) override - { - /* 3.2.10.4+ treats users logged in with accounts as fully registered, even if -r, so we can not set this here. Just use the timestamp. */ - if (Servers::Capab.count("ESVID") > 0 && !na->GetAccount()->IsUnconfirmed()) - IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", na->GetAccount()->GetDisplay()); - else - IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", u->signon); - } +bool unreal::Proto::IsChannelValid(const Anope::string &chan) +{ + if (chan.find(':') != Anope::string::npos) + return false; - void SendLogout(User *u) override - { - IRCD->SendMode(Config->GetClient("NickServ"), u, "+d 0"); - } + return IRCDProto::IsChannelValid(chan); +} - void SendChannel(Channel *c) override - { - /* Unreal does not support updating a channels TS without actually joining a user, - * so we will join and part us now - */ - ServiceBot *bi = c->ci->WhoSends(); - if (!bi) - ; - else if (c->FindUser(bi) == NULL) - { - bi->Join(c); - bi->Part(c); - } - else - { - bi->Part(c); - bi->Join(c); - } - } +bool unreal::Proto:: IsExtbanValid(const Anope::string &mask) +{ + return mask.length() >= 4 && mask[0] == '~' && mask[2] == ':'; +} - void SendSASLMessage(const SASL::Message &message) override - { - size_t p = message.target.find('!'); - if (p == Anope::string::npos) - return; +void unreal::Proto::SendLogin(User *u, NickServ::Nick *na) +{ + /* 3.2.10.4+ treats users logged in with accounts as fully registered, even if -r, so we can not set this here. Just use the timestamp. */ + if (Servers::Capab.count("ESVID") > 0 && !na->GetAccount()->IsUnconfirmed()) + IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", na->GetAccount()->GetDisplay()); + else + IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", u->signon); +} - if (!message.ext.empty()) - Uplink::Send(ServiceBot::Find(message.source), "SASL", message.target.substr(0, p), message.target, message.type, message.data, message.ext); - else - Uplink::Send(ServiceBot::Find(message.source), "SASL", message.target.substr(0, p), message.target, message.type, message.data); - } +void unreal::Proto::SendLogout(User *u) +{ + IRCD->SendMode(Config->GetClient("NickServ"), u, "+d 0"); +} - void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) override +void unreal::Proto::SendChannel(Channel *c) +{ + /* Unreal does not support updating a channels TS without actually joining a user, + * so we will join and part us now + */ + ServiceBot *bi = c->ci->WhoSends(); + if (!bi) + ; + else if (c->FindUser(bi) == NULL) { - size_t p = uid.find('!'); - if (p == Anope::string::npos) - return; - Uplink::Send(Me, "SVSLOGIN", uid.substr(0, p), uid, acc); + bi->Join(c); + bi->Part(c); } - - bool IsIdentValid(const Anope::string &ident) override + else { - if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) - return false; + bi->Part(c); + bi->Join(c); + } +} - for (unsigned i = 0; i < ident.length(); ++i) - { - const char &c = ident[i]; +void unreal::Proto::SendSASLMessage(const ::SASL::Message &message) +{ + size_t p = message.target.find('!'); + if (p == Anope::string::npos) + return; - if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-') - continue; + if (!message.ext.empty()) + Uplink::Send(ServiceBot::Find(message.source), "SASL", message.target.substr(0, p), message.target, message.type, message.data, message.ext); + else + Uplink::Send(ServiceBot::Find(message.source), "SASL", message.target.substr(0, p), message.target, message.type, message.data); +} - if (c == '-' || c == '.' || c == '_') - continue; +void unreal::Proto::SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) +{ + size_t p = uid.find('!'); + if (p == Anope::string::npos) + return; + Uplink::Send(Me, "SVSLOGIN", uid.substr(0, p), uid, acc); +} - return false; - } +bool unreal::Proto::IsIdentValid(const Anope::string &ident) +{ + if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) + return false; - return true; + for (unsigned i = 0; i < ident.length(); ++i) + { + const char &c = ident[i]; + + if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-') + continue; + + if (c == '-' || c == '.' || c == '_') + continue; + + return false; } -}; + + return true; +} class UnrealExtBan : public ChannelModeVirtual<ChannelModeList> { @@ -1120,7 +1112,7 @@ class ProtoUnreal : public Module , public EventHook<Event::DelChan> , public EventHook<Event::MLockEvents> { - UnrealIRCdProto ircd_proto; + unreal::Proto ircd_proto; ServiceReference<ModeLocks> mlocks; /* Core message handlers */ |