summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-02-21 21:27:20 +0000
committerSadie Powell <sadie@witchery.services>2024-02-22 00:14:08 +0000
commit82fa7e1467160332aa3692db5d3c58e54d50bbc7 (patch)
tree2ca35c1c626187c2dec4c8a92d0dcbad594ef4a1
parentaefbb4fbdab80a41c3f88566abcba4b92b2d36d5 (diff)
Convert protocol modules over to Uplink::Send.
-rw-r--r--modules/protocol/bahamut.cpp58
-rw-r--r--modules/protocol/hybrid.cpp76
-rw-r--r--modules/protocol/inspircd.cpp119
-rw-r--r--modules/protocol/ngircd.cpp33
-rw-r--r--modules/protocol/plexus.cpp43
-rw-r--r--modules/protocol/ratbox.cpp23
-rw-r--r--modules/protocol/solanum.cpp53
-rw-r--r--modules/protocol/unrealircd.cpp107
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 &param) 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 &param) 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::Message(Me) << "METADATA " << c->name << " " << c->creation_time << " topiclock :" << (mystate ? "1" : "");
+ Uplink::Send("METADATA", c->name, c->creation_time, "topiclock", !!mystate);
}
else if (params[2] == "maxlist")
{
@@ -1665,12 +1668,12 @@ struct IRCDMessageIdle final
{
BotInfo *bi = BotInfo::Find(params[0]);
if (bi)
- UplinkSocket::Message(bi) << "IDLE " << source.GetSource() << " " << Anope::StartTime << " " << (Anope::CurTime - bi->lastmsg);
+ Uplink::Send(bi, "IDLE", source.GetSource(), Anope::StartTime, Anope::CurTime - bi->lastmsg);
else
{
User *u = User::Find(params[0]);
if (u && u->server == Me)
- UplinkSocket::Message(u) << "IDLE " << source.GetSource() << " " << Anope::StartTime << " 0";
+ Uplink::Send(u, "IDLE", source.GetSource(), Anope::StartTime, 0);
}
}
};
@@ -1688,7 +1691,7 @@ struct IRCDMessageIJoin final
{
// When receiving an IJOIN, first check if the target channel exists. If it does not exist,
// ignore the join (that is, do not create the channel) and send a RESYNC back to the source.
- UplinkSocket::Message(Me) << "RESYNC :" << params[0];
+ Uplink::Send("RESYNC", params[0]);
return;
}
@@ -1793,7 +1796,7 @@ struct IRCDMessageRSQuit final
if (!s)
return;
- UplinkSocket::Message(Me) << "SQUIT " << s->GetSID() << " :" << reason;
+ Uplink::Send("SQUIT", s->GetSID(), reason);
s->Delete(s->GetName() + " " + s->GetUplink()->GetName());
}
};
@@ -1862,7 +1865,7 @@ struct IRCDMessageTime final
void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
- UplinkSocket::Message(Me) << "TIME " << source.GetSource() << " " << params[1] << " " << Anope::CurTime;
+ Uplink::Send("TIME", source.GetSource(), params[1], Anope::CurTime);
}
};
@@ -1961,7 +1964,7 @@ class ProtoInspIRCd final
void SendChannelMetadata(Channel *c, const Anope::string &metadataname, const Anope::string &value)
{
- UplinkSocket::Message(Me) << "METADATA " << c->name << " " << c->creation_time << " " << metadataname << " :" << value;
+ Uplink::Send("METADATA", c->name, c->creation_time, metadataname, value);
}
public:
diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp
index 1ea020290..6dfb91b6c 100644
--- a/modules/protocol/ngircd.cpp
+++ b/modules/protocol/ngircd.cpp
@@ -35,58 +35,59 @@ public:
{
// Calculate the time left before this would expire
time_t timeleft = x->expires ? x->expires - Anope::CurTime : x->expires;
- UplinkSocket::Message(Me) << "GLINE " << x->mask << " " << timeleft << " :" << x->GetReason() << " (" << x->by << ")";
+ Uplink::Send("GLINE", x->mask, timeleft, x->GetReason() + " (" + x->by + ")");
}
void SendAkillDel(const XLine *x) override
{
- UplinkSocket::Message(Me) << "GLINE " << x->mask;
+ Uplink::Send("GLINE", x->mask);
}
void SendChannel(Channel *c) override
{
- UplinkSocket::Message(Me) << "CHANINFO " << c->name << " +" << c->GetModes(true, true);
+ Uplink::Send("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();
- UplinkSocket::Message(Me) << "NICK " << u->nick << " 1 " << u->GetIdent() << " " << u->host << " 1 " << modes << " :" << u->realname;
+ Uplink::Send("NICK", u->nick, 1, u->GetIdent(), u->host, 1, "+" + u->GetModes(), u->realname);
}
void SendConnect() override
{
- UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password << " 0210-IRC+ Anope|" << Anope::VersionShort() << ":CLHMSo P";
+ 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 */
this->SendNumeric(376, "*", "End of MOTD command");
}
void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override
{
- UplinkSocket::Message(Me) << "SVSNICK " << u->nick << " " << newnick;
+ Uplink::Send("SVSNICK", u->nick, newnick);
}
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 SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override
{
- UplinkSocket::Message(source) << "WALLOPS :" << buf;
+ Uplink::Send(source, "WALLOPS", buf);
}
void SendJoin(User *user, Channel *c, const ChannelStatus *status) override
{
- UplinkSocket::Message(user) << "JOIN " << c->name;
+ Uplink::Send(user, "JOIN", c->name);
if (status)
{
/* First save the channel status incase uc->Status == status */
@@ -109,26 +110,26 @@ public:
void SendLogin(User *u, NickAlias *na) override
{
- UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :" << na->nc->display;
+ Uplink::Send("METADATA", u->GetUID(), "accountname", na->nc->display);
}
void SendLogout(User *u) override
{
- UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :";
+ Uplink::Send("METADATA", u->GetUID(), "accountname", "");
}
/* SERVER name hop descript */
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 SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) override
{
if (!vIdent.empty())
- UplinkSocket::Message(Me) << "METADATA " << u->nick << " user :" << vIdent;
+ Uplink::Send("METADATA", u->nick, "user", vIdent);
- UplinkSocket::Message(Me) << "METADATA " << u->nick << " cloakhost :" << vhost;
+ Uplink::Send("METADATA", u->nick, "cloakhost", vhost);
if (!u->HasMode("CLOAK"))
{
u->SetMode(Config->GetClient("HostServ"), "CLOAK");
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index bcf31155c..c7f5e559a 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -52,12 +52,12 @@ public:
void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override
{
- UplinkSocket::Message(source) << "OPERWALL :" << buf;
+ Uplink::Send(source, "OPERWALL", buf);
}
void SendJoin(User *user, Channel *c, const ChannelStatus *status) override
{
- UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " +" << c->GetModes(true, true) << " :" << user->GetUID();
+ Uplink::Send("SJOIN", c->creation_time, c->name, "+" + c->GetModes(true, true), user->GetUID());
if (status)
{
/* First save the channel status incase uc->Status == status */
@@ -80,14 +80,15 @@ public:
void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override
{
- UplinkSocket::Message(Me) << "ENCAP " << u->server->GetName() << " SVSNICK " << u->GetUID() << " " << u->timestamp << " " << newnick << " " << when;
+ Uplink::Send("ENCAP", u->server->GetName(), "SVSNICK", u->GetUID(), u->timestamp, newnick, when);
}
void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) override
{
if (!ident.empty())
- UplinkSocket::Message(Me) << "ENCAP * CHGIDENT " << u->GetUID() << " " << ident;
- UplinkSocket::Message(Me) << "ENCAP * CHGHOST " << u->GetUID() << " " << host;
+ Uplink::Send("ENCAP", '*', "CHGIDENT", u->GetUID(), ident);
+
+ Uplink::Send("ENCAP", '*', "CHGHOST", u->GetUID(), host);
u->SetMode(Config->GetClient("HostServ"), "CLOAK");
}
@@ -98,7 +99,8 @@ public:
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());
+
/* CAPAB
* QS - Can handle quit storm removal
* EX - Can do channel +e exemptions
@@ -119,7 +121,8 @@ public:
* ENCAP - Supports encapsulation of protocol messages
* SVS - Supports services protocol extensions
*/
- UplinkSocket::Message() << "CAPAB :QS EX CHW IE EOB KLN UNKLN GLN HUB KNOCK TBURST PARA ENCAP SVS";
+ 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);
/*
@@ -130,13 +133,12 @@ public:
* parv[3] = server is standalone or connected to non-TS only
* parv[4] = server's idea of UTC time
*/
- UplinkSocket::Message() << "SVINFO 6 5 0 :" << Anope::CurTime;
+ Uplink::Send("SVINFO", 6, 5, 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 << " 255.255.255.255 " << u->GetUID() << " 0 " << u->host << " :" << u->realname;
+ Uplink::Send("UID", u->nick, 1, u->timestamp, "+" + u->GetModes(), u->GetIdent(), u->host, "255.255.255.255", u->GetUID(), 0, u->host, u->realname);
}
void SendModeInternal(const MessageSource &source, User* u, const Anope::string &modes, const std::vector<Anope::string> &values) override
@@ -148,45 +150,48 @@ public:
void SendLogin(User *u, NickAlias *na) override
{
- UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID() << " " << na->nc->display;
+ Uplink::Send("ENCAP", '*', "SU", u->GetUID(), na->nc->display);
}
void SendLogout(User *u) override
{
- UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID();
+ Uplink::Send("ENCAP", '*', "SU", u->GetUID());
}
void SendTopic(const MessageSource &source, Channel *c) override
{
- UplinkSocket::Message(source) << "ENCAP * TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_ts << " :" << c->topic;
+ Uplink::Send(source, "ENCAP", '*', "TOPIC", c->name, c->topic_setter, c->topic_ts, c->topic);
}
void SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string &param) override
{
- UplinkSocket::Message(source) << "ENCAP " << user->server->GetName() << " SVSJOIN " << user->GetUID() << " " << chan;
+ Uplink::Send(source, "ENCAP", '*', "SVSJOIN", user->GetUID(), chan);
}
void SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string &param) override
{
- UplinkSocket::Message(source) << "ENCAP " << user->server->GetName() << " SVSPART " << user->GetUID() << " " << chan;
+ Uplink::Send(source, "ENCAP", '*', "SVSPART", user->GetUID(), chan);
}
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));
+ auto target = s ? s->GetName() : message.target.substr(0, 3);
+ if (message.ext.empty())
+ Uplink::Send("ENCAP", target, "SASL", message.source, message.target, message.type, message.data);
+ else
+ Uplink::Send("ENCAP", target, "SASL", message.source, message.target, message.type, message.data, message.ext);
}
void SendSVSLogin(const Anope::string &uid, NickAlias *na) override
{
Server *s = Server::Find(uid.substr(0, 3));
- UplinkSocket::Message(Me) << "ENCAP " << (s ? s->GetName() : uid.substr(0, 3)) << " SVSLOGIN " << uid << " * * "
- << (na->GetVhostHost().empty() ? "*" : na->GetVhostHost()) << " " << na->nc->display;
+ Uplink::Send("ENCAP", s ? s->GetName() : uid.substr(0, 3), "SVSLOGIN", uid, '*', '*', na->GetVhostHost().empty() ? "*" : na->GetVhostHost(), na->nc->display);
}
void SendSVSNOOP(const Server *server, bool set) override
{
- UplinkSocket::Message() << "ENCAP " << server->GetName() << " SVSNOOP " << (set ? "+" : "-");
+ Uplink::Send("ENCAP", '*', "SVSNOOP", set ? '+' : '-');
}
};
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index d76ad9c15..c3ac626ba 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -59,25 +59,25 @@ public:
void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override
{
- UplinkSocket::Message(source) << "OPERWALL :" << buf;
+ Uplink::Send(source, "OPERWALL", buf);
}
void SendSQLine(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(FindIntroduced()) << "ENCAP * RESV " << timeleft << " " << x->mask << " 0 :" << x->GetReason();
+ Uplink::Send("ENCAP", '*', "RESV", timeleft, x->mask, 0, x->GetReason());
}
void SendSQLineDel(const XLine *x) override
{
- UplinkSocket::Message(Config->GetClient("OperServ")) << "ENCAP * UNRESV " << x->mask;
+ Uplink::Send(Config->GetClient("OperServ"), "ENCAP", '*', "UNRESV", x->mask);
}
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());
+
/*
QS - Can handle quit storm removal
EX - Can do channel +e exemptions
@@ -88,9 +88,11 @@ public:
TB - supports topic burst
ENCAP - supports ENCAP
*/
- UplinkSocket::Message() << "CAPAB :QS EX CHW IE GLN TB 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
@@ -99,13 +101,12 @@ public:
* parv[3] = server is standalone or connected to non-TS only
* parv[4] = server's idea of UTC time
*/
- UplinkSocket::Message() << "SVINFO 6 3 0 :" << Anope::CurTime;
+ Uplink::Send("SVINFO", 6, 3, 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("UID", u->nick, 1, u->timestamp, "+" + u->GetModes(), u->GetIdent(), u->host, 0, u->GetUID(), u->realname);
}
void SendLogin(User *u, NickAlias *na) override
@@ -113,12 +114,12 @@ public:
if (na->nc->HasExt("UNCONFIRMED"))
return;
- UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID() << " " << na->nc->display;
+ Uplink::Send("ENCAP", '*', "SU", u->GetUID(), na->nc->display);
}
void SendLogout(User *u) override
{
- UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID();
+ Uplink::Send("ENCAP", '*', "SU", u->GetUID());
}
void SendTopic(const MessageSource &source, Channel *c) override
diff --git a/modules/protocol/solanum.cpp b/modules/protocol/solanum.cpp
index d0311fd15..ac0ebd8fa 100644
--- a/modules/protocol/solanum.cpp
+++ b/modules/protocol/solanum.cpp
@@ -75,12 +75,13 @@ public:
for (const auto &mechanism : mechanisms)
mechlist += "," + mechanism;
- UplinkSocket::Message(Me) << "ENCAP * MECHLIST :" << (mechanisms.empty() ? "" : mechlist.substr(1));
+ Uplink::Send("ENCAP", '*', "MECHLIST", mechanisms.empty() ? "" : mechlist.substr(1));
}
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
@@ -105,7 +106,7 @@ public:
* UNKLN - Can do UNKLINE (encap only)
* QS - Can handle quit storm removal
*/
- UplinkSocket::Message() << "CAPAB :BAN CHW CLUSTER ECHO ENCAP EOPMOD EUID EX IE KLN KNOCK MLOCK QS RSFNC SERVICES TB UNKLN";
+ Uplink::Send("CAPAB", "BAN CHW CLUSTER ECHO ENCAP EOPMOD EUID EX IE KLN KNOCK MLOCK QS RSFNC SERVICES TB UNKLN");
/* Make myself known to myself in the serverlist */
SendServer(Me);
@@ -117,34 +118,32 @@ public:
* arg[2] = '0'
* arg[3] = server's idea of UTC time
*/
- 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) << "EUID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " * * :" << u->realname;
+ Uplink::Send("EUID", u->nick, 1, u->timestamp, "+" + u->GetModes(), 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("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("ENCAP", '*', "NICKDELAY", delay, nick);
}
void SendSVSHoldDel(const Anope::string &nick) override
{
- UplinkSocket::Message(Me) << "ENCAP * NICKDELAY 0 " << nick;
+ Uplink::Send("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("ENCAP", '*', "CHGHOST", u->GetUID(), host);
}
void SendVhostDel(User *u) override
@@ -155,19 +154,21 @@ public:
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));
+ auto target = s ? s->GetName() : message.target.substr(0, 3);
+ if (message.ext.empty())
+ Uplink::Send("ENCAP", target, "SASL", message.source, message.target, message.type, message.data);
+ else
+ Uplink::Send("ENCAP", target, "SASL", message.source, message.target, message.type, message.data, message.ext);
}
void SendSVSLogin(const Anope::string &uid, NickAlias *na) override
{
Server *s = Server::Find(uid.substr(0, 3));
- UplinkSocket::Message(Me) << "ENCAP " << (s ? s->GetName() : uid.substr(0, 3)) << " SVSLOGIN " << uid << " * "
- << (na && !na->GetVhostIdent().empty() ? na->GetVhostIdent() : '*')
- << " "
- << (na && !na->GetVhostHost().empty() ? na->GetVhostHost() : '*')
- << " "
- << (na ? na->nc->display : "0");
+ Uplink::Send("ENCAP", s ? s->GetName() : uid.substr(0, 3), "SVSLOGIN", uid, '*',
+ na && !na->GetVhostIdent().empty() ? na->GetVhostIdent() : '*',
+ na && !na->GetVhostHost().empty() ? na->GetVhostHost() : '*',
+ na ? na->nc->display : "0");
}
};
@@ -295,7 +296,7 @@ struct IRCDMessageNotice final
void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (Servers::Capab.count("ECHO"))
- UplinkSocket::Message(Me) << "ECHO N " << source.GetSource() << " :" << params[1];
+ Uplink::Send("ECHO", 'N', source.GetSource(), params[1]);
Message::Notice::Run(source, params, tags);
}
@@ -309,7 +310,7 @@ struct IRCDMessagePrivmsg final
void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
if (Servers::Capab.count("ECHO"))
- UplinkSocket::Message(Me) << "ECHO P " << source.GetSource() << " :" << params[1];
+ Uplink::Send("ECHO", 'P', source.GetSource(), params[1]);
Message::Privmsg::Run(source, params, tags);
}
@@ -424,15 +425,15 @@ public:
// If the user has logged into their current nickname then mark them as such.
NickAlias *na = NickAlias::Find(u->nick);
if (na && na->nc == u->Account())
- UplinkSocket::Message(Me) << "ENCAP * IDENTIFIED " << u->GetUID() << " " << u->nick;
+ Uplink::Send("ENCAP", '*', "IDENTIFIED", u->GetUID(), u->nick);
else
- UplinkSocket::Message(Me) << "ENCAP * IDENTIFIED " << u->GetUID() << " " << u->nick << " OFF";
+ Uplink::Send("ENCAP", '*', "IDENTIFIED", u->GetUID(), u->nick, "OFF");
}
void OnNickLogout(User *u) override
{
// We don't know what account the user was logged into so send in all cases.
- UplinkSocket::Message(Me) << "ENCAP * IDENTIFIED " << u->GetUID() << " " << u->nick << " OFF";
+ Uplink::Send("ENCAP", '*', "IDENTIFIED", u->GetUID(), u->nick, "OFF");
}
void OnUserNickChange(User *u, const Anope::string &) override
@@ -457,7 +458,7 @@ public:
if (use_server_side_mlock && modelocks && Servers::Capab.count("MLOCK") > 0)
{
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
- UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(c->creation_time) << " " << c->ci->name << " " << modes;
+ Uplink::Send("MLOCK", c->creation_time, c->ci->name, modes);
}
}
@@ -468,7 +469,7 @@ public:
if (use_server_side_mlock && cm && ci->c && modelocks && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
{
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->mchar;
- UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
+ Uplink::Send("MLOCK", ci->c->creation_time, ci->name, modes);
}
return EVENT_CONTINUE;
@@ -481,7 +482,7 @@ public:
if (use_server_side_mlock && cm && modelocks && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
{
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->mchar, "");
- UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
+ Uplink::Send("MLOCK", ci->c->creation_time, ci->name, modes);
}
return EVENT_CONTINUE;
diff --git a/modules/protocol/unrealircd.cpp b/modules/protocol/unrealircd.cpp
index 0a3d2d094..b85ce8aff 100644
--- a/modules/protocol/unrealircd.cpp
+++ b/modules/protocol/unrealircd.cpp
@@ -45,7 +45,7 @@ private:
/* SVSNOOP */
void SendSVSNOOP(const Server *server, bool set) override
{
- UplinkSocket::Message() << "SVSNOOP " << server->GetSID() << " " << (set ? "+" : "-");
+ Uplink::Send("SVSNOOP", server->GetSID(), set ? '+' : '-');
}
void SendAkillDel(const XLine *x) override
@@ -64,22 +64,22 @@ private:
}
}
- UplinkSocket::Message() << "TKL - G " << x->GetUser() << " " << x->GetHost() << " " << x->by;
+ Uplink::Send("TKL", '-', 'G', x->GetUser(), x->GetHost(), x->by);
}
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);
}
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 SendVhostDel(User *u) override
@@ -125,12 +125,12 @@ private:
}
}
- UplinkSocket::Message() << "TKL + G " << x->GetUser() << " " << x->GetHost() << " " << x->by << " " << x->expires << " " << x->created << " :" << x->GetReason();
+ Uplink::Send("TKL", '+', 'G', x->GetUser(), x->GetHost(), x->by, x->expires, x->created, x->GetReason());
}
void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override
{
- UplinkSocket::Message(source) << "SVSKILL " << user->GetUID() << " :" << buf;
+ Uplink::Send(source, "SVSKILL", user->GetUID(), buf);
user->KillInternal(source, buf);
}
@@ -143,25 +143,22 @@ private:
void SendClientIntroduction(User *u) override
{
- Anope::string modes = "+" + u->GetModes();
- UplinkSocket::Message(u->server) << "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;
+ Uplink::Send(u->server, "UID", u->nick, 1, u->timestamp, u->GetIdent(), u->host, u->GetUID(), '*', "+" + u->GetModes(),
+ u->vhost.empty() ? "*" : u->vhost, u->chost.empty() ? "*" : u->chost, "*", u->realname);
}
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("SID", server->GetName(), server->GetHops() + 1, server->GetSID(), server->GetDescription());
}
/* JOIN */
void SendJoin(User *user, Channel *c, const ChannelStatus *status) override
{
- UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name
- << " +" << c->GetModes(true, true) << " :" << user->GetUID();
+ Uplink::Send("SJOIN", c->creation_time, c->name, "+" + c->GetModes(true, true), user->GetUID());
if (status)
{
/* First save the channel status incase uc->Status == status */
@@ -186,7 +183,7 @@ private:
*/
void SendSQLineDel(const XLine *x) override
{
- UplinkSocket::Message() << "UNSQLINE " << x->mask;
+ Uplink::Send("UNSQLINE", x->mask);
}
/* SQLINE */
@@ -196,7 +193,7 @@ private:
*/
void SendSQLine(User *, const XLine *x) override
{
- UplinkSocket::Message() << "SQLINE " << x->mask << " :" << x->GetReason();
+ Uplink::Send("SQLINE", x->mask, x->GetReason());
}
/* Functions that use serval cmd functions */
@@ -204,9 +201,11 @@ private:
void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) override
{
if (!vIdent.empty())
- UplinkSocket::Message(Me) << "CHGIDENT " << u->GetUID() << " " << vIdent;
+ Uplink::Send("CHGIDENT", u->GetUID(), vIdent);
+
if (!vhost.empty())
- UplinkSocket::Message(Me) << "CHGHOST " << u->GetUID() << " " << vhost;
+ Uplink::Send("CHGHOST", u->GetUID(), vhost);
+
// Internally unreal sets +xt on chghost
BotInfo *bi = Config->GetClient("HostServ");
u->SetMode(bi, "CLOAK");
@@ -227,10 +226,12 @@ private:
VL = Version Info
SID = SID/UID mode
*/
- UplinkSocket::Message() << "PASS :" << Config->Uplinks[Anope::CurrentUplink].password;
- UplinkSocket::Message() << "PROTOCTL " << "NICKv2 VHP UMODE2 NICKIP SJOIN SJOIN2 SJ3 NOQUIT TKLEXT MLOCK SID MTAGS";
- UplinkSocket::Message() << "PROTOCTL " << "EAUTH=" << Me->GetName() << ",,,Anope-" << Anope::VersionShort();
- UplinkSocket::Message() << "PROTOCTL " << "SID=" << Me->GetSID();
+ Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password);
+
+ Uplink::Send("PROTOCTL", "NICKv2", "VHP", "UMODE2", "NICKIP", "SJOIN", "SJOIN2", "SJ3", "NOQUIT", "TKLEXT", "MLOCK", "SID", "MTAGS");
+ Uplink::Send("PROTOCTL" "EAUTH=" + Me->GetName() + ",,,Anope-" + Anope::VersionShort());
+ Uplink::Send("PROTOCTL", "SID=" + Me->GetSID());
+
SendServer(Me);
}
@@ -240,19 +241,19 @@ private:
for (const auto &mechanism : mechanisms)
mechlist += "," + mechanism;
- UplinkSocket::Message() << "MD client " << Me->GetName() << " saslmechlist :" << (mechanisms.empty() ? "" : mechlist.substr(1));
+ Uplink::Send("MD", "client", Me->GetName(), "saslmechlist", mechanisms.empty() ? "" : mechlist.substr(1));
}
/* SVSHOLD - set */
void SendSVSHold(const Anope::string &nick, time_t t) override
{
- UplinkSocket::Message() << "TKL + Q H " << nick << " " << Me->GetName() << " " << Anope::CurTime + t << " " << Anope::CurTime << " :Being held for registered user";
+ Uplink::Send("TKL", '+', 'Q', 'H', nick, Me->GetName(), Anope::CurTime + t, Anope::CurTime, "Being held for a registered user");
}
/* SVSHOLD - release */
void SendSVSHoldDel(const Anope::string &nick) override
{
- UplinkSocket::Message() << "TKL - Q * " << nick << " " << Me->GetName();
+ Uplink::Send("TKL", '-', 'Q', '*', nick, Me->GetName());
}
/* UNSGLINE */
@@ -261,19 +262,19 @@ private:
*/
void SendSGLineDel(const XLine *x) override
{
- UplinkSocket::Message() << "SVSNLINE - :" << x->mask;
+ Uplink::Send("SVSNLINE", '-', x->mask);
}
/* UNSZLINE */
void SendSZLineDel(const XLine *x) override
{
- UplinkSocket::Message() << "TKL - Z * " << x->GetHost() << " " << x->by;
+ Uplink::Send("TKL", '-', 'Z', '*', x->GetHost(), x->by);
}
/* SZLINE */
void SendSZLine(User *, const XLine *x) override
{
- UplinkSocket::Message() << "TKL + Z * " << x->GetHost() << " " << x->by << " " << x->expires << " " << x->created << " :" << x->GetReason();
+ Uplink::Send("TKL", '+', 'Z', '*', x->GetHost(), x->by, x->expires, x->created, x->GetReason());
}
/* SGLINE */
@@ -284,7 +285,7 @@ private:
{
Anope::string edited_reason = x->GetReason();
edited_reason = edited_reason.replace_all_cs(" ", "_");
- UplinkSocket::Message() << "SVSNLINE + " << edited_reason << " :" << x->mask;
+ Uplink::Send("SVSNLINE", '+', edited_reason, x->mask);
}
/* svsjoin
@@ -299,32 +300,32 @@ private:
void SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string &param) override
{
if (!param.empty())
- UplinkSocket::Message() << "SVSJOIN " << user->GetUID() << " " << chan << " :" << param;
+ Uplink::Send("SVSJOIN", user->GetUID(), chan, param);
else
- UplinkSocket::Message() << "SVSJOIN " << user->GetUID() << " " << chan;
+ Uplink::Send("SVSJOIN", user->GetUID(), chan);
}
void SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string &param) override
{
if (!param.empty())
- UplinkSocket::Message() << "SVSPART " << user->GetUID() << " " << chan << " :" << param;
+ Uplink::Send("SVSPART", user->GetUID(), chan, param);
else
- UplinkSocket::Message() << "SVSPART " << user->GetUID() << " " << chan;
+ Uplink::Send("SVSPART", user->GetUID(), chan);
}
void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override
{
- UplinkSocket::Message(Me) << "SENDUMODE o :from " << source.GetName() << ": " << buf;
+ Uplink::Send("SENDUMODE", 'o', "From " + source.GetName() + ": " < buf);
}
void SendSWhois(const MessageSource &source, const Anope::string &who, const Anope::string &mask) override
{
- UplinkSocket::Message() << "SWHOIS " << who << " :" << mask;
+ Uplink::Send("SWHOIS", who, mask);
}
void SendEOB() override
{
- UplinkSocket::Message(Me) << "EOS";
+ Uplink::Send("EOS");
}
bool IsNickValid(const Anope::string &nick) override
@@ -364,8 +365,7 @@ private:
void SendChannel(Channel *c) override
{
- UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name
- << " +" << c->GetModes(true, true) << " :";
+ Uplink::Send("SJOIN", c->creation_time, c->name, "+" + c->GetModes(true, true), "");
}
void SendSASLMessage(const SASL::Message &message) override
@@ -385,7 +385,10 @@ private:
distmask = message.target.substr(0, p);
}
- UplinkSocket::Message(BotInfo::Find(message.source)) << "SASL " << distmask << " " << message.target << " " << message.type << " " << message.data << (message.ext.empty() ? "" : " " + message.ext);
+ if (message.ext.empty())
+ Uplink::Send(BotInfo::Find(message.source), "SASL", distmask, message.target, message.type, message.data);
+ else
+ Uplink::Send(BotInfo::Find(message.source), "SASL", distmask, message.target, message.type, message.data, message.ext);
}
void SendSVSLogin(const Anope::string &uid, NickAlias *na) override
@@ -408,11 +411,13 @@ private:
if (na)
{
if (!na->GetVhostIdent().empty())
- UplinkSocket::Message(Me) << "CHGIDENT " << uid << " " << na->GetVhostIdent();
+ Uplink::Send("CHGIDENT", uid, na->GetVhostIdent());
+
if (!na->GetVhostHost().empty())
- UplinkSocket::Message(Me) << "CHGHOST " << uid << " " << na->GetVhostHost();
+ Uplink::Send("CHGHOST", uid, na->GetVhostHost());
}
- UplinkSocket::Message(Me) << "SVSLOGIN " << distmask << " " << uid << " " << (na ? na->nc->display : "0");
+
+ Uplink::Send("SVSLOGIN", distmask, uid, na ? na->nc->display : "0");
}
bool IsIdentValid(const Anope::string &ident) override
@@ -1197,7 +1202,7 @@ struct IRCDMessageNetInfo final
void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) override
{
- UplinkSocket::Message() << "NETINFO " << MaxUserCount << " " << Anope::CurTime << " " << convertTo<int>(params[2]) << " " << params[3] << " 0 0 0 :" << params[7];
+ Uplink::Send("NETINFO", MaxUserCount, Anope::CurTime, convertTo<int>(params[2]), params[3], 0, 0, 0, params[7]);
}
};
@@ -1755,7 +1760,7 @@ public:
if (use_server_side_mlock && Servers::Capab.count("MLOCK") > 0 && modelocks)
{
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
- UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(c->creation_time) << " " << c->ci->name << " " << modes;
+ Uplink::Send("MLOCK", c->creation_time, c->ci->name, modes);
}
}
@@ -1765,14 +1770,14 @@ public:
if (!ci->c || !use_server_side_mlock || !modelocks || !Servers::Capab.count("MLOCK"))
return;
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
- UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
+ Uplink::Send("MLOCK", ci->c->creation_time, ci->name, modes);
}
void OnDelChan(ChannelInfo *ci) override
{
if (!ci->c || !use_server_side_mlock || !Servers::Capab.count("MLOCK"))
return;
- UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " :";
+ Uplink::Send("MLOCK", ci->c->creation_time, ci->name, "");
}
EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) override
@@ -1782,7 +1787,7 @@ public:
if (use_server_side_mlock && cm && modelocks && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
{
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->mchar;
- UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
+ Uplink::Send("MLOCK", ci->c->creation_time, ci->name, modes);
}
return EVENT_CONTINUE;
@@ -1795,7 +1800,7 @@ public:
if (use_server_side_mlock && cm && modelocks && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
{
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->mchar, "");
- UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
+ Uplink::Send("MLOCK", ci->c->creation_time, ci->name, modes);
}
return EVENT_CONTINUE;
@@ -1803,9 +1808,7 @@ public:
void OnChannelUnban(User *u, ChannelInfo *ci) override
{
- UplinkSocket::Message(ci->WhoSends()) << "SVS2MODE " << ci->c->name << " -b " << u->GetUID();
- /* Unreal will remove all matching bans for us regardless of our internal matching.
- Don't use Message(Me) here as certain Unreal versions will always respond with TS-less MODE message. */
+ Uplink::Send(ci->WhoSends(), "SVS2MODE", ci->c->name, "-b", u->GetUID());
}
};