diff options
Diffstat (limited to 'modules/protocol')
| -rw-r--r-- | modules/protocol/bahamut.cpp | 64 | ||||
| -rw-r--r-- | modules/protocol/charybdis.cpp | 77 | ||||
| -rw-r--r-- | modules/protocol/hybrid.cpp | 59 | ||||
| -rw-r--r-- | modules/protocol/inspircd20.cpp | 111 | ||||
| -rw-r--r-- | modules/protocol/ngircd.cpp | 50 | ||||
| -rw-r--r-- | modules/protocol/plexus.cpp | 34 | ||||
| -rw-r--r-- | modules/protocol/ratbox.cpp | 18 | ||||
| -rw-r--r-- | modules/protocol/unreal.cpp | 88 |
8 files changed, 258 insertions, 243 deletions
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 8c44c1d9d..a32a7606d 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -57,58 +57,64 @@ class BahamutIRCdProto : public IRCDProto { if (Servers::Capab.count("TSMODE") > 0) { - UplinkSocket::Message(source) << "MODE " << dest->name << " " << dest->creation_time << " " << buf; + IRCMessage message(source, "MODE", dest->name, dest->creation_time); + message.TokenizeAndPush(buf); + Uplink::SendMessage(message); } else + { IRCDProto::SendModeInternal(source, dest, buf); + } } void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) override { - UplinkSocket::Message(source) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf; + IRCMessage message(source, "SVSMODE", u->nick, u->timestamp); + message.TokenizeAndPush(buf); + Uplink::SendMessage(message); } void SendGlobalNotice(ServiceBot *bi, const Server *dest, const Anope::string &msg) override { - UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg; + Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); } void SendGlobalPrivmsg(ServiceBot *bi, const Server *dest, const Anope::string &msg) override { - UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg; + Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); } /* SVSHOLD - set */ void SendSVSHold(const Anope::string &nick, time_t time) override { - UplinkSocket::Message(Me) << "SVSHOLD " << nick << " " << time << " :Being held for registered user"; + Uplink::Send(Me, "SVSHOLD", nick, time, "Being held for registered user"); } /* SVSHOLD - release */ void SendSVSHoldDel(const Anope::string &nick) override { - UplinkSocket::Message(Me) << "SVSHOLD " << nick << " 0"; + Uplink::Send(Me, "SVSHOLD", nick, 0); } /* SQLINE */ void SendSQLine(User *, XLine *x) override { - UplinkSocket::Message() << "SQLINE " << x->GetMask() << " :" << x->GetReason(); + Uplink::Send(Me, "SQLINE", x->GetMask(), x->GetReason()); } /* UNSLINE */ void SendSGLineDel(XLine *x) override { - UplinkSocket::Message() << "UNSGLINE 0 :" << x->GetMask(); + Uplink::Send("UNSGLINE", 0, x->GetMask()); } /* UNSZLINE */ void SendSZLineDel(XLine *x) override { /* this will likely fail so its only here for legacy */ - UplinkSocket::Message() << "UNSZLINE 0 " << x->GetHost(); + Uplink::Send("UNSZLINE", 0, x->GetHost()); /* this is how we are supposed to deal with it */ - UplinkSocket::Message() << "RAKILL " << x->GetHost() << " *"; + Uplink::Send("RAKILL", x->GetHost(), "*"); } /* SZLINE */ @@ -119,21 +125,21 @@ class BahamutIRCdProto : public IRCDProto if (timeleft > 172800 || !x->GetExpires()) timeleft = 172800; /* this will likely fail so its only here for legacy */ - UplinkSocket::Message() << "SZLINE " << x->GetHost() << " :" << x->GetReason(); + Uplink::Send("SZLINE", x->GetHost(), x->GetReason()); /* this is how we are supposed to deal with it */ - UplinkSocket::Message() << "AKILL " << x->GetHost() << " * " << timeleft << " " << x->GetBy() << " " << Anope::CurTime << " :" << x->GetReason(); + Uplink::Send("AKILL", x->GetHost(), "*", timeleft, x->GetBy(), Anope::CurTime, x->GetReason()); } /* SVSNOOP */ void SendSVSNOOP(const Server *server, bool set) override { - UplinkSocket::Message() << "SVSNOOP " << server->GetName() << " " << (set ? "+" : "-"); + Uplink::Send("SVSNOOP", server->GetName(), set ? "+" : "-"); } /* SGLINE */ void SendSGLine(User *, XLine *x) override { - UplinkSocket::Message() << "SGLINE " << x->GetMask().length() << " :" << x->GetMask() << ":" << x->GetReason(); + Uplink::Send("SGLINE", x->GetMask().length(), x->GetMask() + ":" + x->GetReason()); } /* RAKILL */ @@ -153,25 +159,26 @@ class BahamutIRCdProto : public IRCDProto } } - UplinkSocket::Message() << "RAKILL " << x->GetHost() << " " << x->GetUser(); + Uplink::Send("RAKKILL", x->GetHost(), x->GetUser()); } /* TOPIC */ void SendTopic(const MessageSource &source, Channel *c) override { - UplinkSocket::Message(source) << "TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_ts << " :" << c->topic; + Uplink::Send(source, "TOPIC", c->name, c->topic_setter, c->topic_ts, c->topic); } /* UNSQLINE */ void SendSQLineDel(XLine *x) override { - UplinkSocket::Message() << "UNSQLINE " << x->GetMask(); + Uplink::Send("UNSQLINE", x->GetMask()); } /* JOIN - SJOIN */ void SendJoin(User *user, Channel *c, const ChannelStatus *status) override { - UplinkSocket::Message(user) << "SJOIN " << c->creation_time << " " << c->name; + Uplink::Send(user, "SJOIN", c->creation_time, c->name); + if (status) { /* First save the channel status incase uc->Status == status */ @@ -237,7 +244,8 @@ class BahamutIRCdProto : public IRCDProto time_t timeleft = x->GetExpires() - Anope::CurTime; if (timeleft > 172800) timeleft = 172800; - UplinkSocket::Message() << "AKILL " << x->GetHost() << " " << x->GetUser() << " " << timeleft << " " << x->GetBy() << " " << Anope::CurTime << " :" << x->GetReason(); + + Uplink::Send("AKILL", x->GetHost(), x->GetUser(), timeleft, x->GetBy(), Anope::CurTime, x->GetReason()); } /* @@ -245,35 +253,35 @@ class BahamutIRCdProto : public IRCDProto */ void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override { - UplinkSocket::Message(source) << "SVSKILL " << user->nick << " :" << buf; + Uplink::Send(source, "SVSKILL", user->nick, buf); } void SendBOB() override { - UplinkSocket::Message() << "BURST"; + Uplink::Send("BURST"); } void SendEOB() override { - UplinkSocket::Message() << "BURST 0"; + Uplink::Send("BURST", 0); } void SendClientIntroduction(User *u) override { Anope::string modes = "+" + u->GetModes(); - UplinkSocket::Message() << "NICK " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " " << u->server->GetName() << " 0 0 :" << u->realname; + Uplink::Send("NICK", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, u->server->GetName(), 0, 0, u->realname); } /* SERVER */ void SendServer(const Server *server) override { - UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription(); + Uplink::Send("SERVER", server->GetName(), server->GetHops(), server->GetDescription()); } void SendConnect() override { - UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password << " :TS"; - UplinkSocket::Message() << "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3"; + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS"); + Uplink::Send("CAPAB", "SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3"); SendServer(Me); /* * SVINFO @@ -283,7 +291,7 @@ class BahamutIRCdProto : public IRCDProto * parv[3] = server is standalone or connected to non-TS only * parv[4] = server's idea of UTC time */ - UplinkSocket::Message() << "SVINFO 3 1 0 :" << Anope::CurTime; + Uplink::Send("SVINFO", 3, 1, 0, Anope::CurTime); this->SendBOB(); } @@ -292,7 +300,7 @@ class BahamutIRCdProto : public IRCDProto Anope::string modes = c->GetModes(true, true); if (modes.empty()) modes = "+"; - UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :"; + Uplink::Send("SJOIN", c->creation_time, c->name, modes, ""); } void SendLogin(User *u, NickServ::Nick *) override diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp index 77dc52847..121915924 100644 --- a/modules/protocol/charybdis.cpp +++ b/modules/protocol/charybdis.cpp @@ -17,15 +17,12 @@ * along with this program; if not, see see <http://www.gnu.org/licenses/>. */ -#if 0 #include "module.h" #include "modules/chanserv/mode.h" #include "modules/sasl.h" static Anope::string UplinkSID; -static ServiceReference<IRCDProto> ratbox("IRCDProto", "ratbox"); - class ChannelModeLargeBan : public ChannelMode { public: @@ -40,8 +37,10 @@ class ChannelModeLargeBan : public ChannelMode class CharybdisProto : public IRCDProto { + ServiceReference<IRCDProto> ratbox; // XXX public: CharybdisProto(Module *creator) : IRCDProto(creator, "Charybdis 3.4+") + , ratbox("ratbox") { DefaultPseudoclientModes = "+oiS"; CanCertFP = true; @@ -74,12 +73,13 @@ class CharybdisProto : public IRCDProto void SendSQLine(User *, XLine *x) override { - UplinkSocket::Message(Me) << "RESV * " << x->GetMask() << " :" << x->GetReason(); + Uplink::Send(Me, "RESV", "*", x->GetMask(), x->GetReason()); } void SendConnect() override { - UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password << " TS 6 :" << Me->GetSID(); + 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 @@ -103,7 +103,7 @@ class CharybdisProto : public IRCDProto * UNKLN - Can do UNKLINE (encap only) * QS - Can handle quit storm removal */ - UplinkSocket::Message() << "CAPAB :BAN CHW CLUSTER ENCAP EOPMOD EUID EX IE KLN KNOCK MLOCK QS RSFNC SERVICES TB UNKLN"; + 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); @@ -115,34 +115,34 @@ class CharybdisProto : public IRCDProto * arg[2] = '0' * arg[3] = server's idea of UTC time */ - UplinkSocket::Message() << "SVINFO 6 6 0 :" << Anope::CurTime; + Uplink::Send("SVINFO", 6, 6, Anope::CurTime); } void SendClientIntroduction(User *u) override { Anope::string modes = "+" + u->GetModes(); - UplinkSocket::Message(Me) << "EUID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " * * :" << u->realname; + Uplink::Send(Me, "EUID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, 0, u->GetUID(), "*", "*", u->realname); } void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override { - UplinkSocket::Message(Me) << "ENCAP " << u->server->GetName() << " RSFNC " << u->GetUID() - << " " << newnick << " " << when << " " << u->timestamp; + Uplink::Send(Me, "ENCAP", u->server->GetName(), "RSFNC", u->GetUID(), + newnick, when, u->timestamp); } void SendSVSHold(const Anope::string &nick, time_t delay) override { - UplinkSocket::Message(Me) << "ENCAP * NICKDELAY " << delay << " " << nick; + Uplink::Send(Me, "ENCAP", "*", "NICKDELAY", delay, nick); } void SendSVSHoldDel(const Anope::string &nick) override { - UplinkSocket::Message(Me) << "ENCAP * NICKDELAY 0 " << nick; + Uplink::Send(Me, "ENCAP", "*", "NICKDELAY", 0, nick); } void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) override { - UplinkSocket::Message(Me) << "ENCAP * CHGHOST " << u->GetUID() << " :" << host; + Uplink::Send(Me, "ENCAP", "*", "CHGHOST", u->GetUID(), host); } void SendVhostDel(User *u) override @@ -153,19 +153,21 @@ class CharybdisProto : public IRCDProto void SendSASLMessage(const SASL::Message &message) override { Server *s = Server::Find(message.target.substr(0, 3)); - UplinkSocket::Message(Me) << "ENCAP " << (s ? s->GetName() : message.target.substr(0, 3)) << " SASL " << message.source << " " << message.target << " " << message.type << " " << message.data << (message.ext.empty() ? "" : (" " + message.ext)); + 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 SendSVSLogin(const Anope::string &uid, const Anope::string &acc) override { Server *s = Server::Find(uid.substr(0, 3)); - UplinkSocket::Message(Me) << "ENCAP " << (s ? s->GetName() : uid.substr(0, 3)) << " SVSLOGIN " << uid << " * * * " << acc; + Uplink::Send(Me, "ENCAP", s ? s->GetName() : uid.substr(0, 3), "SVSLOGIN", uid, "*", "*", "*", acc); } }; struct IRCDMessageEncap : IRCDMessage { + ServiceReference<SASL::Service> sasl; + IRCDMessageEncap(Module *creator) : IRCDMessage(creator, "ENCAP", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT);} void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override @@ -197,7 +199,7 @@ struct IRCDMessageEncap : IRCDMessage * * Charybdis only accepts messages from SASL agents; these must have umode +S */ - if (params[1] == "SASL" && SASL::sasl && params.size() >= 6) + if (params[1] == "SASL" && sasl && params.size() >= 6) { SASL::Message m; m.source = params[2]; @@ -206,7 +208,7 @@ struct IRCDMessageEncap : IRCDMessage m.data = params[5]; m.ext = params.size() > 6 ? params[6] : ""; - SASL::sasl->ProcessMessage(m); + sasl->ProcessMessage(m); } } }; @@ -271,6 +273,7 @@ class ProtoCharybdis : public Module , public EventHook<Event::MLockEvents> { Module *m_ratbox; + ServiceReference<ModeLocks> mlocks; CharybdisProto ircd_proto; @@ -307,32 +310,10 @@ class ProtoCharybdis : public Module bool use_server_side_mlock; - void AddModes() - { - /* Add user modes */ - ModeManager::AddUserMode(new UserMode("NOFORWARD", 'Q')); - ModeManager::AddUserMode(new UserMode("REGPRIV", 'R')); - ModeManager::AddUserMode(new UserModeOperOnly("OPERWALLS", 'z')); - ModeManager::AddUserMode(new UserModeNoone("SSL", 'Z')); - - /* b/e/I */ - ModeManager::AddChannelMode(new ChannelModeList("QUIET", 'q')); - - /* Add channel modes */ - ModeManager::AddChannelMode(new ChannelMode("BLOCKCOLOR", 'c')); - ModeManager::AddChannelMode(new ChannelMode("NOCTCP", 'C')); - ModeManager::AddChannelMode(new ChannelModeParam("REDIRECT", 'f')); - ModeManager::AddChannelMode(new ChannelMode("ALLOWFORWARD", 'F')); - ModeManager::AddChannelMode(new ChannelMode("ALLINVITE", 'g')); - ModeManager::AddChannelMode(new ChannelModeParam("JOINFLOOD", 'j')); - ModeManager::AddChannelMode(new ChannelModeLargeBan("LBAN", 'L')); - ModeManager::AddChannelMode(new ChannelMode("PERM", 'P')); - ModeManager::AddChannelMode(new ChannelMode("NOFORWARD", 'Q')); - ModeManager::AddChannelMode(new ChannelMode("OPMODERATED", 'z')); - } - public: ProtoCharybdis(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR) + , EventHook<Event::ChannelSync>(this) + , EventHook<Event::MLockEvents>(this) , ircd_proto(this) , message_away(this) , message_capab(this) @@ -377,10 +358,9 @@ class ProtoCharybdis : public Module m_ratbox = ModuleManager::FindModule("ratbox"); if (!m_ratbox) throw ModuleException("Unable to find ratbox"); - if (!ratbox) - throw ModuleException("No protocol interface for ratbox"); - - this->AddModes(); +#warning "" +// if (!ratbox) +// throw ModuleException("No protocol interface for ratbox"); } ~ProtoCharybdis() @@ -402,7 +382,7 @@ class ProtoCharybdis : public Module if (use_server_side_mlock && Servers::Capab.count("MLOCK") > 0) { Anope::string modes = mlocks->GetMLockAsString(c->ci, false).replace_all_cs("+", "").replace_all_cs("-", ""); - UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(c->creation_time) << " " << c->ci->GetName() << " " << modes; + Uplink::Send(Me, "MLOCK", c->creation_time, c->ci->GetName(), modes); } } @@ -415,7 +395,7 @@ class ProtoCharybdis : public Module if (use_server_side_mlock && cm && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0) { Anope::string modes = mlocks->GetMLockAsString(ci, false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->mchar; - UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->GetName() << " " << modes; + Uplink::Send(Me, "MLOCK", ci->c->creation_time, ci->GetName(), modes); } return EVENT_CONTINUE; @@ -430,7 +410,7 @@ class ProtoCharybdis : public Module if (use_server_side_mlock && cm && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0) { Anope::string modes = mlocks->GetMLockAsString(ci, false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->mchar, ""); - UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->GetName() << " " << modes; + Uplink::Send(Me, "MLOCK", ci->c->creation_time, ci->GetName(), modes); } return EVENT_CONTINUE; @@ -438,4 +418,3 @@ class ProtoCharybdis : public Module }; MODULE_INIT(ProtoCharybdis) -#endif diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index 90b3581b2..d733dadee 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -68,37 +68,37 @@ class HybridProto : public IRCDProto void SendInvite(const MessageSource &source, const Channel *c, User *u) override { - UplinkSocket::Message(source) << "INVITE " << u->GetUID() << " " << c->name << " " << c->creation_time; + Uplink::Send(source, "INVITE", u->GetUID(), c->name, c->creation_time); } void SendGlobalNotice(ServiceBot *bi, const Server *dest, const Anope::string &msg) override { - UplinkSocket::Message(bi) << "NOTICE $$" << dest->GetName() << " :" << msg; + Uplink::Send(bi, "NOTICE", "$$" + dest->GetName(), msg); } void SendGlobalPrivmsg(ServiceBot *bi, const Server *dest, const Anope::string &msg) override { - UplinkSocket::Message(bi) << "PRIVMSG $$" << dest->GetName() << " :" << msg; + Uplink::Send(bi, "PRIVMSG", "$$" + dest->GetName(), msg); } void SendSQLine(User *, XLine *x) override { - UplinkSocket::Message(FindIntroduced()) << "ENCAP * RESV " << (x->GetExpires() ? x->GetExpires() - Anope::CurTime : 0) << " " << x->GetMask() << " 0 :" << x->GetReason(); + Uplink::Send(FindIntroduced(), "ENCAP", "*", "RESV", x->GetExpires() ? x->GetExpires() - Anope::CurTime : 0, x->GetMask(), "0", x->GetReason()); } void SendSGLineDel(XLine *x) override { - UplinkSocket::Message(Config->GetClient("OperServ")) << "UNXLINE * " << x->GetMask(); + Uplink::Send(Config->GetClient("OperServ"), "UNXLINE", "*", x->GetMask()); } void SendSGLine(User *, XLine *x) override { - UplinkSocket::Message(Config->GetClient("OperServ")) << "XLINE * " << x->GetMask() << " 0 :" << x->GetReason(); + Uplink::Send(Config->GetClient("OperServ"), "XLINE", "*", x->GetMask(), "0", x->GetReason()); } void SendSZLineDel(XLine *x) override { - UplinkSocket::Message(Config->GetClient("OperServ")) << "UNDLINE * " << x->GetHost(); + Uplink::Send(Config->GetClient("OperServ"), "UNDLINE", "*", x->GetHost()); } void SendSZLine(User *, XLine *x) override @@ -109,7 +109,7 @@ class HybridProto : public IRCDProto if (timeleft > 172800 || !x->GetExpires()) timeleft = 172800; - UplinkSocket::Message(Config->GetClient("OperServ")) << "DLINE * " << timeleft << " " << x->GetHost() << " :" << x->GetReason(); + Uplink::Send(Config->GetClient("OperServ"), "DLINE", "*", timeleft, x->GetHost(), x->GetReason()); } void SendAkillDel(XLine *x) override @@ -117,12 +117,12 @@ class HybridProto : public IRCDProto if (x->IsRegex() || x->HasNickOrReal()) return; - UplinkSocket::Message(Config->GetClient("OperServ")) << "UNKLINE * " << x->GetUser() << " " << x->GetHost(); + Uplink::Send(Config->GetClient("OperServ"), "UNKLINE", "*", x->GetUser(), x->GetHost()); } void SendSQLineDel(XLine *x) override { - UplinkSocket::Message(Config->GetClient("OperServ")) << "UNRESV * " << x->GetMask(); + Uplink::Send(Config->GetClient("OperServ"), "UNRESV", "*", x->GetMask()); } void SendJoin(User *user, Channel *c, const ChannelStatus *status) override @@ -132,9 +132,7 @@ class HybridProto : public IRCDProto * can not add them to the mode stacker because ircd-hybrid * does not allow *any* client to op itself */ - UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " +" - << c->GetModes(true, true) << " :" - << (status != NULL ? status->BuildModePrefixList() : "") << user->GetUID(); + Uplink::Send("SJOIN", c->creation_time, c->name, "+" + c->GetModes(true, true), (status != NULL ? status->BuildModePrefixList() : "") + user->GetUID()); /* And update our internal status for this user since this is not going through our mode handling system */ if (status != NULL) @@ -189,23 +187,23 @@ class HybridProto : public IRCDProto if (timeleft > 172800 || !x->GetExpires()) timeleft = 172800; - UplinkSocket::Message(Config->GetClient("OperServ")) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->GetReason(); + Uplink::Send(Config->GetClient("OperServ"), "KLINE", timeleft, x->GetUser(), x->GetHost(), x->GetReason()); } void SendServer(const Server *server) override { if (server == Me) - UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() + 1 << " :" << server->GetDescription(); + Uplink::Send("SERVER", server->GetName(), server->GetHops() + 1, server->GetDescription()); else - UplinkSocket::Message(Me) << "SID " << server->GetName() << " " << server->GetHops() + 1 << " " << server->GetSID() << " :" << server->GetDescription(); + Uplink::Send(Me, "SID", server->GetName(), server->GetHops() + 1, server->GetSID(), server->GetDescription()); } void SendConnect() override { - UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password << " TS 6 :" << Me->GetSID(); + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS", 6, Me->GetSID()); /* - * As of October 13, 2012, ircd-hybrid-8 does support the following capabilities + * As of October 13, 2012, ircd-hybrid-8 supports the following capabilities * which are required to work with IRC-services: * * QS - Can handle quit storm removal @@ -220,29 +218,30 @@ class HybridProto : public IRCDProto * EOB - Supports End Of Burst message * TS6 - Capable of TS6 support */ - UplinkSocket::Message() << "CAPAB :QS EX CHW IE ENCAP TBURST SVS HOPS EOB TS6"; + Uplink::Send("CAPAB", "QS EX CHW IE ENCAP TBURST SVS HOPS EOB TS6"); SendServer(Me); - UplinkSocket::Message() << "SVINFO 6 6 0 :" << Anope::CurTime; + Uplink::Send("SVINFO", 6, 6, 0, Anope::CurTime); } void SendClientIntroduction(User *u) override { Anope::string modes = "+" + u->GetModes(); - UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " - << u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " * :" << u->realname; + Uplink::Send(Me, "UID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, 0, u->GetUID(), "*", u->realname); } void SendEOB() override { - UplinkSocket::Message(Me) << "EOB"; + Uplink::Send(Me, "EOB"); } void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) override { - UplinkSocket::Message(source) << "SVSMODE " << u->GetUID() << " " << u->timestamp << " " << buf; + IRCMessage message(source, "SVSMODE", u->GetUID(), u->timestamp); + message.TokenizeAndPush(buf); + Uplink::SendMessage(message); } void SendLogin(User *u, NickServ::Nick *na) override @@ -262,30 +261,30 @@ class HybridProto : public IRCDProto if (modes.empty()) modes = "+"; - UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :"; + Uplink::Send("SJOIN", c->creation_time, c->name, modes, ""); } void SendTopic(const MessageSource &source, Channel *c) override { - UplinkSocket::Message(source) << "TBURST " << c->creation_time << " " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic; + Uplink::Send(source, "TBURST", c->creation_time, c->name, c->topic_ts, c->topic_setter, c->topic); } void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override { - UplinkSocket::Message(Me) << "SVSNICK " << u->GetUID() << " " << newnick << " " << when; + Uplink::Send(Me, "SVSNICK", u->GetUID(), newnick, when); } void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) override { - UplinkSocket::Message(source) << "SVSJOIN " << u->GetUID() << " " << chan; + Uplink::Send(source, "SVSJOIN", u->GetUID(), chan); } void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) override { if (!param.empty()) - UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan << " :" << param; + Uplink::Send(source, "SVSPART", u->GetUID(), chan, param); else - UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan; + Uplink::Send(source, "SVSPART", u->GetUID(), chan); } void SendSVSHold(const Anope::string &nick, time_t t) override diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index b9406f55a..1d457df58 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -47,7 +47,7 @@ class InspIRCd20Proto : public IRCDProto if (!Servers::Capab.count("CHGIDENT")) Log() << "CHGIDENT not loaded!"; else - UplinkSocket::Message(Me) << "CHGIDENT " << nick << " " << vIdent; + Uplink::Send(Me, "CHGIDENT", nick, vIdent); } void SendChgHostInternal(const Anope::string &nick, const Anope::string &vhost) @@ -55,17 +55,17 @@ class InspIRCd20Proto : public IRCDProto if (!Servers::Capab.count("CHGHOST")) Log() << "CHGHOST not loaded!"; else - UplinkSocket::Message(Me) << "CHGHOST " << nick << " " << vhost; + 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) { - UplinkSocket::Message(Me) << "ADDLINE " << xtype << " " << mask << " " << addedby << " " << Anope::CurTime << " " << duration << " :" << reason; + Uplink::Send(Me, "ADDLINE", xtype, mask, addedby, Anope::CurTime, duration, reason); } void SendDelLine(const Anope::string &xtype, const Anope::string &mask) { - UplinkSocket::Message(Me) << "DELLINE " << xtype << " " << mask; + Uplink::Send(Me, "DELLINE", xtype, mask); } public: @@ -86,20 +86,20 @@ class InspIRCd20Proto : public IRCDProto void SendConnect() override { - UplinkSocket::Message() << "CAPAB START 1202"; - UplinkSocket::Message() << "CAPAB CAPABILITIES :PROTOCOL=1202"; - UplinkSocket::Message() << "CAPAB END"; + Uplink::Send("CAPAB START 1202"); + Uplink::Send("CAPAB CAPABILITIES :PROTOCOL=1202"); + Uplink::Send("CAPAB END"); SendServer(Me); } void SendGlobalNotice(ServiceBot *bi, const Server *dest, const Anope::string &msg) override { - UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg; + Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); } void SendGlobalPrivmsg(ServiceBot *bi, const Server *dest, const Anope::string &msg) override { - UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg; + Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); } void SendAkillDel(XLine *x) override @@ -135,7 +135,7 @@ class InspIRCd20Proto : public IRCDProto { if (Servers::Capab.count("SVSTOPIC")) { - UplinkSocket::Message(c->ci->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic; + Uplink::Send(c->ci->WhoSends(), "SVSTOPIC", c->name, c->topic_ts, c->topic_setter, c->topic); } else { @@ -144,7 +144,7 @@ class InspIRCd20Proto : public IRCDProto 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 */ - UplinkSocket::Message(source) << "FTOPIC " << c->name << " " << ts << " " << c->topic_setter << " :" << c->topic; + Uplink::Send(source, "FTOPIC", c->name, ts, c->topic_setter, c->topic); } } @@ -219,20 +219,22 @@ class InspIRCd20Proto : public IRCDProto void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) override { - UplinkSocket::Message() << "PUSH " << dest << " ::" << Me->GetName() << " " << numeric << " " << dest << " " << buf; + Uplink::Send("PUSH", dest, ":" + Me->GetName() + " " + numeric + " " + dest + " " + buf); } void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) override { - UplinkSocket::Message(source) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf; + IRCMessage message(source, "FMODE", dest->name, dest->creation_time); + message.TokenizeAndPush(buf); + Uplink::SendMessage(message); } void SendClientIntroduction(User *u) override { Anope::string modes = "+" + u->GetModes(); - UplinkSocket::Message(Me) << "UID " << u->GetUID() << " " << u->timestamp << " " << u->nick << " " << u->host << " " << u->host << " " << u->GetIdent() << " 0.0.0.0 " << u->timestamp << " " << modes << " :" << u->realname; + 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) - UplinkSocket::Message(u) << "OPERTYPE :services"; + Uplink::Send(u, "OPERTYPE", "services"); } /* SERVER services-dev.chatspike.net password 0 :Description here */ @@ -240,7 +242,7 @@ class InspIRCd20Proto : public IRCDProto { /* if rsquit is set then we are waiting on a squit */ if (rsquit_id.empty() && rsquit_server.empty()) - UplinkSocket::Message() << "SERVER " << server->GetName() << " " << Config->Uplinks[Anope::CurrentUplink].password << " " << server->GetHops() << " " << server->GetSID() << " :" << server->GetDescription(); + Uplink::Send("SERVER", server->GetName(), Config->Uplinks[Anope::CurrentUplink].password, server->GetHops(), server->GetSID(), server->GetDescription()); } void SendSquit(Server *s, const Anope::string &message) override @@ -249,16 +251,20 @@ class InspIRCd20Proto : public IRCDProto { rsquit_id = s->GetSID(); rsquit_server = s->GetName(); - UplinkSocket::Message() << "RSQUIT " << s->GetName() << " :" << message; + + Uplink::Send("RSQUIT", s->GetName(), message); } else - UplinkSocket::Message() << "SQUIT " << s->GetName() << " :" << message; + { + Uplink::Send("SQUIT", s->GetName(), message); + } } /* JOIN */ void SendJoin(User *user, Channel *c, const ChannelStatus *status) override { - UplinkSocket::Message(Me) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :," << user->GetUID(); + 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 @@ -310,13 +316,13 @@ class InspIRCd20Proto : public IRCDProto /* SVSHOLD - set */ void SendSVSHold(const Anope::string &nick, time_t t) override { - UplinkSocket::Message(Config->GetClient("NickServ")) << "SVSHOLD " << nick << " " << t << " :Being held for registered user"; + Uplink::Send(Config->GetClient("NickServ"), "SVSHOLD", nick, t, "Being held for registered user"); } /* SVSHOLD - release */ void SendSVSHoldDel(const Anope::string &nick) override { - UplinkSocket::Message(Config->GetClient("NickServ")) << "SVSHOLD " << nick; + Uplink::Send(Config->GetClient("NickServ"), "SVSHOLD", nick); } /* UNSZLINE */ @@ -337,42 +343,42 @@ class InspIRCd20Proto : public IRCDProto void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) override { - UplinkSocket::Message(source) << "SVSJOIN " << u->GetUID() << " " << chan; + Uplink::Send(source, "SVSJOIN", u->GetUID(), chan); } void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) override { if (!param.empty()) - UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan << " :" << param; + Uplink::Send(source, "SVSPART", u->GetUID(), chan, param); else - UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan; + Uplink::Send(source, "SVSPART", u->GetUID(), chan); } void SendSWhois(const MessageSource &, const Anope::string &who, const Anope::string &mask) override { User *u = User::Find(who); - UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " swhois :" << mask; + Uplink::Send(Me, "METADATA", u->GetUID(), "swhois", mask); } void SendBOB() override { - UplinkSocket::Message(Me) << "BURST " << Anope::CurTime; + Uplink::Send(Me, "BURST", Anope::CurTime); Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); - UplinkSocket::Message(Me) << "VERSION :Anope-" << Anope::Version() << " " << Me->GetName() << " :" << IRCD->GetProtocolName() << " - (" << (enc ? enc->name : "none") << ") -- " << Anope::VersionBuildString(); + Uplink::Send(Me, "VERSION", "Anope-" + Anope::Version() + " " + Me->GetName() + " :" + IRCD->GetProtocolName() + " - (" + (enc ? enc->name : "none") + ") -- " + Anope::VersionBuildString()); } void SendEOB() override { - UplinkSocket::Message(Me) << "ENDBURST"; + Uplink::Send(Me, "ENDBURST"); } void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override { if |
