diff options
| author | Sadie Powell <sadie@witchery.services> | 2024-02-21 21:27:20 +0000 |
|---|---|---|
| committer | Sadie Powell <sadie@witchery.services> | 2024-02-22 00:14:08 +0000 |
| commit | 82fa7e1467160332aa3692db5d3c58e54d50bbc7 (patch) | |
| tree | 2ca35c1c626187c2dec4c8a92d0dcbad594ef4a1 /modules/protocol | |
| parent | aefbb4fbdab80a41c3f88566abcba4b92b2d36d5 (diff) | |
Convert protocol modules over to Uplink::Send.
Diffstat (limited to 'modules/protocol')
| -rw-r--r-- | modules/protocol/bahamut.cpp | 58 | ||||
| -rw-r--r-- | modules/protocol/hybrid.cpp | 76 | ||||
| -rw-r--r-- | modules/protocol/inspircd.cpp | 119 | ||||
| -rw-r--r-- | modules/protocol/ngircd.cpp | 33 | ||||
| -rw-r--r-- | modules/protocol/plexus.cpp | 43 | ||||
| -rw-r--r-- | modules/protocol/ratbox.cpp | 23 | ||||
| -rw-r--r-- | modules/protocol/solanum.cpp | 53 | ||||
| -rw-r--r-- | modules/protocol/unrealircd.cpp | 107 |
8 files changed, 259 insertions, 253 deletions
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index a82f63bd8..7a0c357ca 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -68,45 +68,46 @@ public: void SendGlobalNotice(BotInfo *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(BotInfo *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("SVSHOLD", nick, time, "Being held for a registered user"); } /* SVSHOLD - release */ void SendSVSHoldDel(const Anope::string &nick) override { - UplinkSocket::Message(Me) << "SVSHOLD " << nick << " 0"; + Uplink::Send("SVSHOLD", nick, 0); } /* SQLINE */ void SendSQLine(User *, const XLine *x) override { - UplinkSocket::Message() << "SQLINE " << x->mask << " :" << x->GetReason(); + Uplink::Send("SQLINE", x->mask, x->reason); } /* UNSLINE */ void SendSGLineDel(const XLine *x) override { - UplinkSocket::Message() << "UNSGLINE 0 :" << x->mask; + Uplink::Send("UNSGLINE", 0, x->mask); } /* UNSZLINE */ void SendSZLineDel(const 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 */ @@ -116,21 +117,22 @@ public: time_t timeleft = x->expires ? x->expires - Anope::CurTime : x->expires; /* 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->by << " " << Anope::CurTime << " :" << x->GetReason(); + Uplink::Send("AKILL", x->GetHost(), '*', timeleft, x->by, 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 *, const XLine *x) override { - UplinkSocket::Message() << "SGLINE " << x->mask.length() << " :" << x->mask << ":" << x->GetReason(); + Uplink::Send("SGLINE", x->mask.length(), x->mask, x->GetReason()); } /* RAKILL */ @@ -150,25 +152,25 @@ public: } } - UplinkSocket::Message() << "RAKILL " << x->GetHost() << " " << x->GetUser(); + Uplink::Send("RAKILL", 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(const XLine *x) override { - UplinkSocket::Message() << "UNSQLINE " << x->mask; + Uplink::Send("UNSQLINE", x->mask); } /* 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 */ @@ -227,7 +229,7 @@ public: // Calculate the time left before this would expire time_t timeleft = x->expires ? x->expires - Anope::CurTime : x->expires; - UplinkSocket::Message() << "AKILL " << x->GetHost() << " " << x->GetUser() << " " << timeleft << " " << x->by << " " << Anope::CurTime << " :" << x->GetReason(); + Uplink::Send("AKILL", x->GetHost(), x->GetUser(), timeleft, x->by, Anope::CurTime, x->reason); } /* @@ -235,35 +237,34 @@ public: */ void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override { - UplinkSocket::Message(source) << "SVSKILL " << user->nick << " :" << buf; + Uplink::Send("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, "+" + u->GetModes(), 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 @@ -273,16 +274,13 @@ public: * 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(); } void SendChannel(Channel *c) override { - 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, "+" + c->GetModes(true, true), ""); } void SendLogin(User *u, NickAlias *) override diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index cbb4270b4..b5ccbe1b3 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -43,45 +43,44 @@ public: 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(BotInfo *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(BotInfo *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 *, const XLine *x) override { - UplinkSocket::Message(Me) << "RESV * " << (x->expires ? x->expires - Anope::CurTime : 0) << " " << x->mask << " :" << x->reason; + Uplink::Send("RESV", '*', x->expires ? x->expires - Anope::CurTime : 0, x->mask, x->reason); } void SendSGLineDel(const XLine *x) override { - UplinkSocket::Message(Me) << "UNXLINE * " << x->mask; + Uplink::Send("UNXLINE", '*', x->mask); } void SendSGLine(User *, const XLine *x) override { - UplinkSocket::Message(Me) << "XLINE * " << x->mask << " " << (x->expires ? x->expires - Anope::CurTime : 0) << " :" << x->GetReason(); + Uplink::Send("XLINE", '*', x->mask, x->expires ? x->expires - Anope::CurTime : 0, x->GetReason()); } void SendSZLineDel(const XLine *x) override { - UplinkSocket::Message(Me) << "UNDLINE * " << x->GetHost(); + Uplink::Send("UNDLINE", '*', x->GetHost()); } void SendSZLine(User *, const XLine *x) override { /* Calculate the time left before this would expire */ time_t timeleft = x->expires ? x->expires - Anope::CurTime : x->expires; - - UplinkSocket::Message(Me) << "DLINE * " << timeleft << " " << x->GetHost() << " :" << x->GetReason(); + Uplink::Send("DLINE", '*', timeleft, x->GetHost(), x->GetReason()); } void SendAkillDel(const XLine *x) override @@ -89,17 +88,17 @@ public: if (x->IsRegex() || x->HasNickOrReal()) return; - UplinkSocket::Message(Me) << "UNKLINE * " << x->GetUser() << " " << x->GetHost(); + Uplink::Send("UNKLINE", '*', x->GetUser(), x->GetHost()); } void SendSQLineDel(const XLine *x) override { - UplinkSocket::Message(Me) << "UNRESV * " << x->mask; + Uplink::Send("UNRESV", '*', x->mask); } void SendJoin(User *u, Channel *c, const ChannelStatus *status) override { - UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " +" << c->GetModes(true, true) << " :" << u->GetUID(); + Uplink::Send("SJOIN", c->creation_time, c->name, "+" + c->GetModes(true, true), u->GetUID()); /* * Note that we can send this with the SJOIN but choose not to @@ -162,21 +161,20 @@ public: /* Calculate the time left before this would expire */ time_t timeleft = x->expires ? x->expires - Anope::CurTime : x->expires; - - UplinkSocket::Message(Me) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->GetReason(); + Uplink::Send("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->GetSID() << " +" << " :" << server->GetDescription(); + Uplink::Send("SERVER", server->GetName(), server->GetHops() + 1, server->GetSID(), '+', server->GetDescription()); else - UplinkSocket::Message(Me) << "SID " << server->GetName() << " " << server->GetHops() + 1 << " " << server->GetSID() << " +" << " :" << server->GetDescription(); + Uplink::Send("SID", server->GetName(), server->GetHops() + 1, server->GetSID(), '+', server->GetDescription()); } void SendConnect() override { - UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password; + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password); /* * TBURST - Supports topic burst @@ -185,24 +183,21 @@ public: * RHOST - Supports UID message with realhost information * MLOCK - Supports MLOCK */ - UplinkSocket::Message() << "CAPAB :ENCAP TBURST EOB RHOST MLOCK"; + Uplink::Send("CAPAB", "ENCAP", "TBURST", "EOB", "RHOST", "MLOCK"); SendServer(Me); - UplinkSocket::Message(Me) << "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 << " " << u->host << " 0.0.0.0 " << u->GetUID() << " * :" << u->realname; + Uplink::Send("UID", u->nick, 1, u->timestamp, "+" + u->GetModes(), u->GetIdent(), u->host, u->host, "0.0.0.0", u->GetUID(), '*', u->realname); } void SendEOB() override { - UplinkSocket::Message(Me) << "EOB"; + Uplink::Send("EOB"); } void SendModeInternal(const MessageSource &source, User* u, const Anope::string &modes, const std::vector<Anope::string> &values) override @@ -217,7 +212,7 @@ public: if (UseSVSAccount == false) IRCD->SendMode(Config->GetClient("NickServ"), u, "+d", na->nc->display); else - UplinkSocket::Message(Me) << "SVSACCOUNT " << u->GetUID() << " " << u->timestamp << " " << na->nc->display; + Uplink::Send("SVSACCOUNT", u->GetUID(), u->timestamp, na->nc->display); } void SendLogout(User *u) override @@ -225,41 +220,40 @@ public: if (UseSVSAccount == false) IRCD->SendMode(Config->GetClient("NickServ"), u, "+d", '*'); else - UplinkSocket::Message(Me) << "SVSACCOUNT " << u->GetUID() << " " << u->timestamp << " *"; + Uplink::Send("SVSACCOUNT", u->GetUID(), u->timestamp, '*'); } void SendChannel(Channel *c) override { - Anope::string modes = "+" + c->GetModes(true, true); - UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :"; + Uplink::Send("SJOIN", c->creation_time, c->name, "+" + c->GetModes(true, true), ""); } 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() << " " << u->timestamp << " " << newnick << " " << when; + Uplink::Send("SVSNICK", u->GetUID(), u->timestamp, 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("SVSPART", u->GetUID(), chan, param); else - UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan; + Uplink::Send("SVSPART", u->GetUID(), chan); } void SendSVSHold(const Anope::string &nick, time_t t) override { - XLine x(nick, Me->GetName(), Anope::CurTime + t, "Being held for registered user"); + XLine x(nick, Me->GetName(), Anope::CurTime + t, "Being held for a registered user"); this->SendSQLine(NULL, &x); } @@ -271,12 +265,12 @@ public: void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) override { - UplinkSocket::Message(Me) << "SVSHOST " << u->GetUID() << " " << u->timestamp << " " << host; + Uplink::Send("SVSHOST", u->GetUID(), u->timestamp, host); } void SendVhostDel(User *u) override { - UplinkSocket::Message(Me) << "SVSHOST " << u->GetUID() << " " << u->timestamp << " " << u->host; + Uplink::Send("SVSHOST", u->GetUID(), u->timestamp, u->host); } bool IsExtbanValid(const Anope::string &mask) override @@ -460,7 +454,7 @@ struct IRCDMessageMLock final // Mode lock string is not what we say it is? if (modes != params[3]) - UplinkSocket::Message(Me) << "MLOCK " << c->creation_time << " " << c->name << " " << Anope::CurTime << " :" << modes; + Uplink::Send("MLOCK", c->creation_time, c->name, Anope::CurTime, modes); } } }; @@ -847,14 +841,14 @@ public: if (use_server_side_mlock && modelocks && Servers::Capab.count("MLOCK")) { Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", ""); - UplinkSocket::Message(Me) << "MLOCK " << c->creation_time << " " << c->ci->name << " " << Anope::CurTime << " :" << modes; + Uplink::Send("MLOCK", c->creation_time, c->ci->name, Anope::CurTime, modes); } } void OnDelChan(ChannelInfo *ci) override { if (use_server_side_mlock && ci->c && Servers::Capab.count("MLOCK")) - UplinkSocket::Message(Me) << "MLOCK " << ci->c->creation_time << " " << ci->name << " " << Anope::CurTime << " :"; + Uplink::Send("MLOCK", ci->c->creation_time, ci->name, Anope::CurTime, ""); } EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) override @@ -864,7 +858,7 @@ public: if (use_server_side_mlock && cm && ci->c && modelocks && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK")) { Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->mchar; - UplinkSocket::Message(Me) << "MLOCK " << ci->c->creation_time << " " << ci->name << " " << Anope::CurTime << " :" << modes; + Uplink::Send("MLOCK", ci->c->creation_time, ci->name, Anope::CurTime, modes); } return EVENT_CONTINUE; @@ -877,7 +871,7 @@ public: if (use_server_side_mlock && cm && modelocks && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK")) { Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->mchar, ""); - UplinkSocket::Message(Me) << "MLOCK " << ci->c->creation_time << " " << ci->name << " " << Anope::CurTime << " :" << modes; + Uplink::Send("MLOCK", ci->c->creation_time, ci->name, Anope::CurTime, modes); } return EVENT_CONTINUE; diff --git a/modules/protocol/inspircd.cpp b/modules/protocol/inspircd.cpp index fd4771a7d..b72f06f49 100644 --- a/modules/protocol/inspircd.cpp +++ b/modules/protocol/inspircd.cpp @@ -53,7 +53,7 @@ private: if (!Servers::Capab.count("CHGIDENT")) Log() << "CHGIDENT not loaded!"; else - UplinkSocket::Message(Me) << "CHGIDENT " << nick << " " << vIdent; + Uplink::Send("CHGIDENT", nick, vIdent); } void SendChgHostInternal(const Anope::string &nick, const Anope::string &vhost) @@ -61,23 +61,23 @@ private: if (!Servers::Capab.count("CHGHOST")) Log() << "CHGHOST not loaded!"; else - UplinkSocket::Message(Me) << "CHGHOST " << nick << " " << vhost; + Uplink::Send("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("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("DELLINE", xtype, mask); } void SendAccount(const Anope::string &uid, NickAlias *na) { - UplinkSocket::Message(Me) << "METADATA " << uid << " accountid :" << (na ? na->nc->GetId() : Anope::string()); - UplinkSocket::Message(Me) << "METADATA " << uid << " accountname :" << (na ? na->nc->display : Anope::string()); + Uplink::Send("METADATA", uid, "accountid", na ? na->nc->GetId() : Anope::string()); + Uplink::Send("METADATA", uid, "accountname", na ? na->nc->display : Anope::string()); } public: @@ -118,10 +118,10 @@ public: void SendConnect() override { - UplinkSocket::Message() << "CAPAB START 1205"; - UplinkSocket::Message() << "CAPAB CAPABILITIES :CASEMAPPING=" << Config->GetBlock("options")->Get<const Anope::string>("casemap", "ascii"); - UplinkSocket::Message() << "CAPAB END"; - UplinkSocket::Message() << "SERVER " << Me->GetName() << " " << Config->Uplinks[Anope::CurrentUplink].password << " 0 " << Me->GetSID() << " :" << Me->GetDescription(); + Uplink::Send("CAPAB", "START", 1205); + Uplink::Send("CAPAB", "CAPABILITIES", "CASEMAPPING=" + Config->GetBlock("options")->Get<const Anope::string>("casemap", "ascii")); + Uplink::Send("CAPAB", "END"); + Uplink::Send("SERVER", Me->GetName(), Config->Uplinks[Anope::CurrentUplink].password, 0, Me->GetSID(), Me->GetDescription()); } void SendSASLMechanisms(std::vector<Anope::string> &mechanisms) override @@ -130,7 +130,7 @@ public: for (const auto &mechanism : mechanisms) mechlist += "," + mechanism; - UplinkSocket::Message(Me) << "METADATA * saslmechlist :" << (mechanisms.empty() ? "" : mechlist.substr(1)); + Uplink::Send("METADATA", "*", "saslmechlist", mechanisms.empty() ? "" : mechlist.substr(1)); } void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override @@ -141,17 +141,17 @@ public: void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override { - UplinkSocket::Message() << "SVSNICK " << u->GetUID() << " " << newnick << " " << when << " " << u->timestamp; + Uplink::Send("SVSNICK", u->GetUID(), newnick, when, u->timestamp); } void SendGlobalNotice(BotInfo *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(BotInfo *bi, const Server *dest, const Anope::string &msg) override { - UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg; + Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); } void SendPong(const Anope::string &servname, const Anope::string &who) override @@ -160,7 +160,7 @@ public: if (!serv) serv = Me; - UplinkSocket::Message(serv) << "PONG " << who; + Uplink::Send(serv, "PONG", who); } void SendAkillDel(const XLine *x) override @@ -204,14 +204,14 @@ public: 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 SendTopic(const MessageSource &source, Channel *c) override { if (Servers::Capab.count("SVSTOPIC")) { - UplinkSocket::Message(c->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic; + Uplink::Send(c->WhoSends(), "SVSTOPIC", c->name, c->topic_ts, c->topic_setter, c->topic); } else { @@ -220,7 +220,7 @@ public: 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 << " " << c->creation_time << " " << ts << " " << c->topic_setter << " :" << c->topic; + Uplink::Send(source, "FTOPIC", c->name, c->creation_time, ts, c->topic_setter, c->topic); } } @@ -312,17 +312,16 @@ public: 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("UID", u->GetUID(), u->timestamp, u->nick, u->host, u->host, u->GetIdent(), "0.0.0.0", u->timestamp, "+" + u->GetModes(), u->realname); - if (modes.find('o') != Anope::string::npos) + if (u->GetModes().find('o') != Anope::string::npos) { // Mark as introduced so we can send an oper type. BotInfo *bi = BotInfo::Find(u->nick, true); if (bi) bi->introduced = true; - UplinkSocket::Message(u) << "OPERTYPE :service"; + Uplink::Send(u, "OPERTYPE", "service"); } } @@ -330,7 +329,7 @@ public: { /* if rsquit is set then we are waiting on a squit */ if (rsquit_id.empty() && rsquit_server.empty()) - UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetSID() << " :" << server->GetDescription(); + Uplink::Send("SERVER", server->GetName(), server->GetSID(), server->GetDescription()); } void SendSquit(Server *s, const Anope::string &message) override @@ -339,15 +338,15 @@ public: { 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); } 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("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 @@ -401,12 +400,12 @@ public: 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 a registered user"); } void SendSVSHoldDel(const Anope::string &nick) override { - UplinkSocket::Message(Config->GetClient("NickServ")) << "SVSHOLD " << nick; + Uplink::Send(Config->GetClient("NickServ"), "SVSHOLD", nick); } void SendSZLineDel(const XLine *x) override @@ -424,44 +423,44 @@ public: void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &other) 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 &bi, const Anope::string &who, const Anope::string &mask) override { User *u = User::Find(who); - - UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " swhois :" << mask; + Uplink::Send("METADATA", u->GetUID(), "swhois", mask); } void SendBOB() override { - UplinkSocket::Message(Me) << "BURST " << Anope::CurTime; + Uplink::Send("BURST", Anope::CurTime); Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); - UplinkSocket::Message(Me) << "SINFO version :Anope-" << Anope::Version() << " " << Me->GetName() << " :" << IRCD->GetProtocolName() << " - (" << (enc ? enc->name : "none") << ") -- " << Anope::VersionBuildString(); - UplinkSocket::Message(Me) << "SINFO fullversion :Anope-" << Anope::Version() << " " << Me->GetName() << " :[" << Me->GetSID() << "] " << IRCD->GetProtocolName() << " - (" << (enc ? enc->name : "none") << ") -- " << Anope::VersionBuildString(); - UplinkSocket::Message(Me) << "SINFO rawversion :Anope-" << Anope::VersionShort(); + + Uplink::Send("SINFO", "version", Anope::printf("Anope-%s %s :%s -- (%s) -- %s", Anope::Version().c_str(), Me->GetName().c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "none", Anope::VersionBuildString().c_str())); + Uplink::Send("SINFO", "fullversion", Anope::printf("Anope-%s %s :[%s] %s -- (%s) -- %s", Anope::Version().c_str(), Me->GetName().c_str(), Me->GetSID().c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "none", Anope::VersionBuildString().c_str())); + Uplink::Send("SINFO", "rawversion", "Anope-" + Anope::VersionShort()); } void SendEOB() override { - UplinkSocket::Message(Me) << "ENDBURST"; + Uplink::Send("ENDBURST"); } void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override { if (Servers::Capab.count("GLOBOPS")) - UplinkSocket::Message(source) << "SNONOTICE g :" << buf; + Uplink::Send(source, "SNONOTICE", 'g', buf); else - UplinkSocket::Message(source) << "SNONOTICE A :" << buf; + Uplink::Send(source, "SNONOTICE", "A", buf); } void SendLogin(User *u, NickAlias *na) override @@ -478,12 +477,15 @@ public: void SendChannel(Channel *c) override { - UplinkSocket::Message(Me) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :"; + Uplink::Send("FJOIN", c->name, c->creation_time, "+" + c->GetModes(true, true), ""); } void SendSASLMessage(const SASL::Message &message) override { - UplinkSocket::Message(Me) << "ENCAP " << message.target.substr(0, 3) << " SASL " << message.source << " " << message.target << " " << message.type << " " << message.data << (message.ext.empty() ? "" : (" " + message.ext)); + if (message.ext.empty()) + Uplink::Send("ENCAP", message.target.substr(0, 3), "SASL", message.source, message.target, message.type, message.data); + else + Uplink::Send("ENCAP", message.target.substr(0, 3), "SASL", message.source, message.target, message.type, message.data, message.ext); } void SendSVSLogin(const Anope::string &uid, NickAlias *na) override @@ -503,9 +505,10 @@ public: if (na) { if (!na->GetVhostIdent().empty()) - UplinkSocket::Message(Me) << "ENCAP " << uid.substr(0, 3) << " CHGIDENT " << uid << " " << na->GetVhostIdent(); + Uplink::Send("ENCAP", uid.substr(0, 3), "CHGIDENT", uid, na->GetVhostIdent()); + if (!na->GetVhostHost().empty()) - UplinkSocket::Message(Me) << "ENCAP " << uid.substr(0, 3) << " CHGHOST " << uid << " " << na->GetVhostHost(); + Uplink::Send("ENCAP", uid.substr(0, 3), "CHGHOST", uid, na->GetVhostHost()); // Mark this SASL session as pending user introduction. SASLUser su; @@ -930,7 +933,7 @@ struct IRCDMessageCapab final if (spanningtree_proto_ver < 1205) { - UplinkSocket::Message() << "ERROR :Protocol mismatch, no or invalid protocol version given in CAPAB START"; + Uplink::Send("ERROR", "Protocol mismatch, no or invalid protocol version given in CAPAB START."); Anope::QuitReason = "Protocol mismatch, no or invalid protocol version given in CAPAB START"; Anope::Quitting = true; return; @@ -1222,14 +1225,14 @@ struct IRCDMessageCapab final { if (!Servers::Capab.count("SERVICES")) { - UplinkSocket::Message() << "ERROR :The services_account module is not loaded. This is required by Anope"; + Uplink::Send("ERROR", "The services_account module is not loaded. This is required by Anope."); Anope::QuitReason = "ERROR: Remote server does not have the services_account module loaded, and this is required."; Anope::Quitting = true; return; } if (!ModeManager::FindUserModeByName("PRIV")) { - UplinkSocket::Message() << "ERROR :The hidechans module is not loaded. This is required by Anope"; + Uplink::Send("ERROR", "The hidechans module is not loaded. This is required by Anope."); Anope::QuitReason = "ERROR: Remote server does not have the hidechans module loaded, and this is required."; Anope::Quitting = true; return; @@ -1263,7 +1266,7 @@ struct IRCDMessageEncap final return; u->SetIdent(params[3]); - UplinkSocket::Message(u) << "FIDENT :" << params[3]; + Uplink::Send(u, "FIDENT", params[3]); } else if (params[1] == "CHGHOST") { @@ -1272,7 +1275,7 @@ struct IRCDMessageEncap final return; u->SetDisplayedHost(params[3]); - UplinkSocket::Message(u) << "FHOST :" << params[3]; + Uplink::Send(u, "FHOST", params[3]); } else if (params[1] == "CHGNAME") { @@ -1281,7 +1284,7 @@ struct IRCDMessageEncap final return; u->SetRealname(params[3]); - UplinkSocket::Message(u) << "FNAME :" << params[3]; + Uplink::Send(u, "FNAME", params[3]); } else if (SASL::sasl && params[1] == "SASL" && params.size() >= 6) { @@ -1412,14 +1415,14 @@ public: // Mode lock string is not what we say it is? if (modes != params[3]) - UplinkSocket::Message(Me) << "METADATA " << c->name << " " << c->creation_time << " mlock :" << modes; + Uplink::Send("METADATA", c->name, c->creation_time, "mlock", modes); } else if ((c->ci) && (do_topiclock) && (params[2] == "topiclock")) { bool mystate = c->ci->HasExt("TOPICLOCK"); bool serverstate = (params[3] == "1"); if (mystate != serverstate) - UplinkSocket::Messa |
