summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-11-25 00:44:31 -0500
committerAdam <Adam@anope.org>2011-11-25 00:44:31 -0500
commitcef3eb78dfd2ea20e0a482d040cc99902fdb4b2a (patch)
treed9e964ac19137e87a6fb97d25dda9be6487c2aa9
parent12d0a7302f76fe21c54ffcead286fc31e870b817 (diff)
Remove send_cmd and replace it with a stringstream
-rw-r--r--include/extern.h21
-rw-r--r--include/servers.h6
-rw-r--r--include/services.h2
-rw-r--r--modules/commands/os_jupe.cpp2
-rw-r--r--modules/protocol/bahamut.cpp101
-rw-r--r--modules/protocol/inspircd-ts6.h101
-rw-r--r--modules/protocol/inspircd11.cpp66
-rw-r--r--modules/protocol/inspircd12.cpp49
-rw-r--r--modules/protocol/inspircd20.cpp58
-rw-r--r--modules/protocol/plexus.cpp130
-rw-r--r--modules/protocol/ratbox.cpp123
-rw-r--r--modules/protocol/unreal.cpp125
-rw-r--r--modules/pseudoclients/global.cpp4
-rw-r--r--src/main.cpp54
-rw-r--r--src/protocol.cpp50
-rw-r--r--src/send.cpp93
-rw-r--r--src/servers.cpp13
17 files changed, 417 insertions, 581 deletions
diff --git a/include/extern.h b/include/extern.h
index 9a1583ec6..17802d91a 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -117,6 +117,21 @@ class UplinkSocket : public ConnectionSocket, public BufferedSocket
bool Read(const Anope::string &);
void OnConnect();
void OnError(const Anope::string &);
+
+ class CoreExport Message
+ {
+ Anope::string source;
+ std::stringstream buffer;
+ public:
+ Message();
+ Message(const Anope::string &);
+ ~Message();
+ template<typename T> Message &operator<<(const T &val)
+ {
+ this->buffer << val;
+ return *this;
+ }
+ };
};
E UplinkSocket *UplinkSock;
E int CurrentUplink;
@@ -200,12 +215,6 @@ E bool is_on_access(const User *u, const NickCore *nc);
E void process(const Anope::string &buf);
-/**** send.c ****/
-
-E void send_cmd(const Anope::string &source, const char *fmt, ...) FORMAT(printf, 2, 3);
-
-E void notice_server(const Anope::string &source, const Server *s, const char *fmt, ...) FORMAT(printf, 3, 4);
-
/**** sockets.cpp ****/
E int32_t TotalRead;
diff --git a/include/servers.h b/include/servers.h
index f23f20fc5..f63c747e3 100644
--- a/include/servers.h
+++ b/include/servers.h
@@ -152,6 +152,12 @@ class CoreExport Server : public Flags<ServerFlag>
*/
bool IsULined() const;
+ /** Send a message to alll users on this server
+ * @param source The source of the message
+ * @param message The message
+ */
+ void Notice(BotInfo *source, const Anope::string &message);
+
/** Find a server
* @param name The name or SID/numeric
* @param s The server list to search for this server on, defaults to our Uplink
diff --git a/include/services.h b/include/services.h
index 06596db5d..1da51e296 100644
--- a/include/services.h
+++ b/include/services.h
@@ -792,7 +792,7 @@ class CoreExport IRCDProto
virtual void SendPart(const BotInfo *bi, const Channel *chan, const char *fmt, ...);
virtual void SendGlobops(const BotInfo *source, const char *fmt, ...);
virtual void SendSQLine(User *, const XLine *x) { }
- virtual void SendSquit(const Anope::string &servname, const Anope::string &message);
+ virtual void SendSquit(Server *, const Anope::string &message);
virtual void SendSVSO(const Anope::string &, const Anope::string &, const Anope::string &) { }
virtual void SendChangeBotNick(const BotInfo *bi, const Anope::string &newnick);
virtual void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when);
diff --git a/modules/commands/os_jupe.cpp b/modules/commands/os_jupe.cpp
index 54834a0a6..57ea5be76 100644
--- a/modules/commands/os_jupe.cpp
+++ b/modules/commands/os_jupe.cpp
@@ -37,7 +37,7 @@ class CommandOSJupe : public Command
{
Anope::string rbuf = "Juped by " + u->nick + (!reason.empty() ? ": " + reason : "");
if (server)
- ircdproto->SendSquit(jserver, rbuf);
+ ircdproto->SendSquit(server, rbuf);
Server *juped_server = new Server(Me, jserver, 1, rbuf, ircd->ts6 ? ts6_sid_retrieve() : "", SERVER_JUPED);
ircdproto->SendServer(juped_server);
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index 10c9a6454..c4b7b1bf0 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -44,127 +44,102 @@ IRCDVar myIrcd[] = {
{NULL}
};
-void bahamut_cmd_burst()
-{
- send_cmd("", "BURST");
-}
-
-/*
- * SVINFO
- * parv[0] = sender prefix
- * parv[1] = TS_CURRENT for the server
- * parv[2] = TS_MIN for the server
- * parv[3] = server is standalone or connected to non-TS only
- * parv[4] = server's idea of UTC time
- */
-void bahamut_cmd_svinfo()
-{
- send_cmd("", "SVINFO 3 1 0 :%ld", static_cast<long>(Anope::CurTime));
-}
-
-/* PASS */
-void bahamut_cmd_pass(const Anope::string &pass)
-{
- send_cmd("", "PASS %s :TS", pass.c_str());
-}
-
-/* CAPAB */
-void bahamut_cmd_capab()
-{
- send_cmd("", "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3");
-}
class BahamutIRCdProto : public IRCDProto
{
void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf)
{
if (Capab.HasFlag(CAPAB_TSMODE))
- send_cmd(source ? source->nick : Config->ServerName, "MODE %s %ld %s", dest->name.c_str(), static_cast<long>(dest->creation_time), buf.c_str());
+ UplinkSocket::Message(source ? source->nick : Config->ServerName) << "MODE " << dest->name << " " << dest->creation_time << " " << buf;
else
- send_cmd(source ? source->nick : Config->ServerName, "MODE %s %s", dest->name.c_str(), buf.c_str());
+ UplinkSocket::Message(source ? source->nick : Config->ServerName) << "MODE " << dest->name << " " << buf;
}
void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf)
{
- send_cmd(bi ? bi->nick : Config->ServerName, "SVSMODE %s %ld %s", u->nick.c_str(), static_cast<long>(u->timestamp), buf.c_str());
+ UplinkSocket::Message(bi ? bi->nick : Config->ServerName) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf;
}
/* SVSHOLD - set */
void SendSVSHold(const Anope::string &nick)
{
- send_cmd(Config->ServerName, "SVSHOLD %s %u :Being held for registered user", nick.c_str(), static_cast<unsigned>(Config->NSReleaseTimeout));
+ UplinkSocket::Message(Config->ServerName) << "SVSHOLD " << nick << " " << Config->NSReleaseTimeout << " :Being held for registered user";
}
/* SVSHOLD - release */
void SendSVSHoldDel(const Anope::string &nick)
{
- send_cmd(Config->ServerName, "SVSHOLD %s 0", nick.c_str());
+ UplinkSocket::Message(Config->ServerName) << "SVSHOLD " << nick << " 0";
}
/* SQLINE */
void SendSQLine(User *, const XLine *x)
{
- send_cmd("", "SQLINE %s :%s", x->Mask.c_str(), x->Reason.c_str());
+ UplinkSocket::Message() << "SQLINE " << x->Mask << " :" << x->Reason;
}
/* UNSLINE */
void SendSGLineDel(const XLine *x)
{
- send_cmd("", "UNSGLINE 0 :%s", x->Mask.c_str());
+ UplinkSocket::Message() << "UNSGLINE 0 :" << x->Mask;
}
/* UNSZLINE */
void SendSZLineDel(const XLine *x)
{
/* this will likely fail so its only here for legacy */
- send_cmd("", "UNSZLINE 0 %s", x->GetHost().c_str());
+ UplinkSocket::Message() << "UNSZLINE 0 " << x->GetHost();
/* this is how we are supposed to deal with it */
- send_cmd("", "RAKILL %s *", x->GetHost().c_str());
+ UplinkSocket::Message() << "RAKILL " << x->GetHost() << " *";
}
/* SZLINE */
void SendSZLine(User *, const XLine *x)
{
+ // Calculate the time left before this would expire, capping it at 2 days
+ time_t timeleft = x->Expires - Anope::CurTime;
+ if (timeleft > 172800 || !x->Expires)
+ timeleft = 172800;
/* this will likely fail so its only here for legacy */
- send_cmd("", "SZLINE %s :%s", x->GetHost().c_str(), x->Reason.c_str());
+ UplinkSocket::Message() << "SZLINE " << x->GetHost() << " :" << x->Reason;
/* this is how we are supposed to deal with it */
- send_cmd("", "AKILL %s * %d %s %ld :%s", x->GetHost().c_str(), 172800, x->By.c_str(), static_cast<long>(Anope::CurTime), x->Reason.c_str());
+ UplinkSocket::Message() << "AKILL " << x->GetHost() << " * " << timeleft << " " << x->By << " " << Anope::CurTime << " :" << x->Reason;
}
/* SVSNOOP */
void SendSVSNOOP(const Server *server, bool set)
{
- send_cmd("", "SVSNOOP %s %s", server->GetName().c_str(), set ? "+" : "-");
+ UplinkSocket::Message() << "SVSNOOP " << server->GetName() << " " << (set ? "+" : "-");
}
/* SGLINE */
void SendSGLine(User *, const XLine *x)
{
- send_cmd("", "SGLINE %d :%s:%s", static_cast<int>(x->Mask.length()), x->Mask.c_str(), x->Reason.c_str());
+ UplinkSocket::Message() << "SGLINE " << x->Mask.length() << " :" << x->Mask << ":" << x->Reason;
}
/* RAKILL */
void SendAkillDel(const XLine *x)
{
- send_cmd("", "RAKILL %s %s", x->GetHost().c_str(), x->GetUser().c_str());
+ UplinkSocket::Message() << "RAKILL " << x->GetHost() << " " << x->GetUser();
}
/* TOPIC */
void SendTopic(BotInfo *whosets, Channel *c)
{
- send_cmd(whosets->nick, "TOPIC %s %s %lu :%s", c->name.c_str(), c->topic_setter.c_str(), static_cast<unsigned long>(c->topic_time), c->topic.c_str());
+ UplinkSocket::Message(whosets->nick) << "TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_time << " :" << c->topic;
}
/* UNSQLINE */
void SendSQLineDel(const XLine *x)
{
- send_cmd("", "UNSQLINE %s", x->Mask.c_str());
+ UplinkSocket::Message() << "UNSQLINE " << x->Mask;
}
/* JOIN - SJOIN */
void SendJoin(User *user, Channel *c, const ChannelStatus *status)
{
- send_cmd(user->nick, "SJOIN %ld %s", static_cast<long>(c->creation_time), c->name.c_str());
+ UplinkSocket::Message(user->nick) << "SJOIN " << c->creation_time << " " << c->name;
if (status)
{
/* First save the channel status incase uc->Status == status */
@@ -189,7 +164,7 @@ class BahamutIRCdProto : public IRCDProto
time_t timeleft = x->Expires - Anope::CurTime;
if (timeleft > 172800)
timeleft = 172800;
- send_cmd("", "AKILL %s %s %d %s %ld :%s", x->GetHost().c_str(), x->GetUser().c_str(), static_cast<int>(timeleft), x->By.c_str(), static_cast<long>(Anope::CurTime), x->Reason.c_str());
+ UplinkSocket::Message() << "AKILL " << x->GetHost() << " " << x->GetUser() << " " << timeleft << " " << x->By << " " << Anope::CurTime << " :" << x->Reason;
}
/*
@@ -197,46 +172,54 @@ class BahamutIRCdProto : public IRCDProto
*/
void SendSVSKillInternal(const BotInfo *source, const User *user, const Anope::string &buf)
{
- send_cmd(source ? source->nick : "", "SVSKILL %s :%s", user->nick.c_str(), buf.c_str());
+ UplinkSocket::Message(source ? source->nick : "") << "SVSKILL " << user->nick << " :" << buf;
}
void SendBOB()
{
- send_cmd("", "BURST");
+ UplinkSocket::Message() << "BURST";
}
void SendEOB()
{
- send_cmd("", "BURST 0");
+ UplinkSocket::Message() << "BURST 0";
}
void SendKickInternal(const BotInfo *source, const Channel *chan, const User *user, const Anope::string &buf)
{
if (!buf.empty())
- send_cmd(source->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf.c_str());
+ UplinkSocket::Message(source->nick) << "KICK " << chan->name << " " << user->nick << " :" << buf;
else
- send_cmd(source->nick, "KICK %s %s", chan->name.c_str(), user->nick.c_str());
+ UplinkSocket::Message(source->nick) << "KICK " << chan->name << " " << user->nick;
}
void SendClientIntroduction(const User *u)
{
Anope::string modes = "+" + u->GetModes();
- send_cmd("", "NICK %s 1 %ld %s %s %s %s 0 0 :%s", u->nick.c_str(), static_cast<long>(u->timestamp), modes.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->server->GetName().c_str(), u->realname.c_str());
+ UplinkSocket::Message() << "NICK " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " " << u->server->GetName() << " 0 0 :" << u->realname;
}
/* SERVER */
void SendServer(const Server *server)
{
- send_cmd("", "SERVER %s %d :%s", server->GetName().c_str(), server->GetHops(), server->GetDescription().c_str());
+ UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription();
}
void SendConnect()
{
- bahamut_cmd_pass(Config->Uplinks[CurrentUplink]->password);
- bahamut_cmd_capab();
+ UplinkSocket::Message() << "PASS " << Config->Uplinks[CurrentUplink]->password << " :TS";
+ UplinkSocket::Message() << "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3";
SendServer(Me);
- bahamut_cmd_svinfo();
- bahamut_cmd_burst();
+ /*
+ * SVINFO
+ * parv[0] = sender prefix
+ * parv[1] = TS_CURRENT for the server
+ * parv[2] = TS_MIN for the server
+ * parv[3] = server is standalone or connected to non-TS only
+ * parv[4] = server's idea of UTC time
+ */
+ UplinkSocket::Message() << "SVINFO 3 1 0 :" << Anope::CurTime;
+ this->SendBOB();
}
void SendChannel(Channel *c)
@@ -244,7 +227,7 @@ class BahamutIRCdProto : public IRCDProto
Anope::string modes = c->GetModes(true, true);
if (modes.empty())
modes = "+";
- send_cmd("", "SJOIN %ld %s %s :", static_cast<long>(c->creation_time), c->name.c_str(), modes.c_str());
+ UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :";
}
void SendLogin(User *u)
diff --git a/modules/protocol/inspircd-ts6.h b/modules/protocol/inspircd-ts6.h
index a540f30b3..8b1905c2c 100644
--- a/modules/protocol/inspircd-ts6.h
+++ b/modules/protocol/inspircd-ts6.h
@@ -33,33 +33,31 @@ class InspIRCdTS6Proto : public IRCDProto
private:
void SendChgIdentInternal(const Anope::string &nick, const Anope::string &vIdent)
{
- User *u = finduser(Config->HostServ);
if (!has_chgidentmod)
Log() << "CHGIDENT not loaded!";
else
- send_cmd(u ? u->GetUID() : Config->Numeric, "CHGIDENT %s %s", nick.c_str(), vIdent.c_str());
+ UplinkSocket::Message(Config->HostServ) << "CHGIDENT " << nick << " " << vIdent;
}
void SendChgHostInternal(const Anope::string &nick, const Anope::string &vhost)
{
- User *u = finduser(Config->HostServ);
if (!has_chghostmod)
Log() << "CHGHOST not loaded!";
else
- send_cmd(u ? u->GetUID() : Config->Numeric, "CHGHOST %s %s", nick.c_str(), vhost.c_str());
+ UplinkSocket::Message(Config->Numeric) << "CHGHOST " << nick << " " << vhost;
}
public:
void SendAkillDel(const XLine *x)
{
- User *u = finduser(Config->OperServ);
- send_cmd(u ? u->GetUID() : Config->Numeric, "GLINE %s", x->Mask.c_str());
+ BotInfo *bi = findbot(Config->OperServ);
+ UplinkSocket::Message(bi ? bi->GetUID() : Config->Numeric) << "GLINE " << x->Mask;
}
void SendTopic(BotInfo *whosets, Channel *c)
{
- send_cmd(whosets->GetUID(), "FTOPIC %s %lu %s :%s", c->name.c_str(), static_cast<unsigned long>(c->topic_time + 1), c->topic_setter.c_str(), c->topic.c_str());
+ UplinkSocket::Message(whosets->GetUID()) << "FTOPIC " << c->name << " " << c->topic_time + 1 << " " << c->topic_setter << " :" << c->topic;
}
void SendVhostDel(User *u)
@@ -80,53 +78,53 @@ class InspIRCdTS6Proto : public IRCDProto
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
User *u = finduser(Config->OperServ);
- send_cmd(u ? u->GetUID() : Config->Numeric, "ADDLINE G %s@%s %s %ld %ld :%s", x->GetUser().c_str(), x->GetHost().c_str(), x->By.c_str(), static_cast<long>(Anope::CurTime), static_cast<long>(timeleft), x->Reason.c_str());
+ UplinkSocket::Message(u ? u->GetUID() : Config->Numeric) << "ADDLINE G " << x->GetUser() << "@" << x->GetHost() << " " << x->By << " " << Anope::CurTime << " " << timeleft << " :" << x->Reason;
}
void SendSVSKillInternal(const BotInfo *source, const User *user, const Anope::string &buf)
{
- send_cmd(source ? source->GetUID() : Config->Numeric, "KILL %s :%s", user->GetUID().c_str(), buf.c_str());
+ UplinkSocket::Message(source ? source->GetUID() : Config->Numeric) << "KILL " << user->GetUID() << " :" << buf;
}
void SendNumericInternal(const Anope::string &source, int numeric, const Anope::string &dest, const Anope::string &buf)
{
- send_cmd(Config->Numeric, "PUSH %s ::%s %03d %s %s", dest.c_str(), source.c_str(), numeric, dest.c_str(), buf.c_str());
+ UplinkSocket::Message(Config->Numeric) << "PUSH " << dest << " ::" << source << " " << numeric << " " << dest << " " << buf;
}
void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf)
{
- send_cmd(source ? source->GetUID() : Config->Numeric, "FMODE %s %u %s", dest->name.c_str(), static_cast<unsigned>(dest->creation_time), buf.c_str());
+ UplinkSocket::Message(source ? source->GetUID() : Config->Numeric) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf;
}
void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf)
{
- send_cmd(bi ? bi->GetUID() : Config->Numeric, "MODE %s %s", u->GetUID().c_str(), buf.c_str());
+ UplinkSocket::Message(bi ? bi->GetUID() : Config->Numeric) << "MODE " << u->GetUID() << " " << buf;
}
void SendClientIntroduction(const User *u)
{
Anope::string modes = "+" + u->GetModes();
- send_cmd(Config->Numeric, "UID %s %ld %s %s %s %s 0.0.0.0 %ld %s :%s", u->GetUID().c_str(), static_cast<long>(u->timestamp), u->nick.c_str(), u->host.c_str(), u->host.c_str(), u->GetIdent().c_str(), static_cast<long>(u->my_signon), modes.c_str(), u->realname.c_str());
+ UplinkSocket::Message(Config->Numeric) << "UID " << u->GetUID() << " " << u->timestamp << " " << u->nick << " " << u->host << " " << u->host << " " << u->GetIdent() << " 0.0.0.0 " << u->my_signon << " " << modes << " :" << u->realname;
}
void SendKickInternal(const BotInfo *source, const Channel *chan, const User *user, const Anope::string &buf)
{
if (!buf.empty())
- send_cmd(source->GetUID(), "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), buf.c_str());
+ UplinkSocket::Message(source->GetUID()) << "KICK " << chan->name << " " << user->GetUID() << " :" << buf;
else
- send_cmd(source->GetUID(), "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), user->nick.c_str());
+ UplinkSocket::Message(source->GetUID()) << "KICK " << chan->name << " " << user->GetUID() << " :" << user->nick;
}
/* SERVER services-dev.chatspike.net password 0 :Description here */
void SendServer(const Server *server)
{
- send_cmd("", "SERVER %s %s %d %s :%s", server->GetName().c_str(), Config->Uplinks[CurrentUplink]->password.c_str(), server->GetHops(), server->GetSID().c_str(), server->GetDescription().c_str());
+ UplinkSocket::Message("") << "SERVER " << server->GetName() << " " << Config->Uplinks[CurrentUplink]->password << " " << server->GetHops() << " " << server->GetSID() << " :" << server->GetDescription();
}
/* JOIN */
void SendJoin(User *user, Channel *c, const ChannelStatus *status)
{
- send_cmd(Config->Numeric, "FJOIN %s %ld +%s :,%s", c->name.c_str(), static_cast<long>(c->creation_time), c->GetModes(true, true).c_str(), user->GetUID().c_str());
+ UplinkSocket::Message(Config->Numeric) << "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
@@ -152,7 +150,7 @@ class InspIRCdTS6Proto : public IRCDProto
/* UNSQLINE */
void SendSQLineDel(const XLine *x)
{
- send_cmd(Config->Numeric, "DELLINE Q %s", x->Mask.c_str());
+ UplinkSocket::Message(Config->Numeric) << "DELLINE Q " << x->Mask;
}
/* SQLINE */
@@ -162,13 +160,7 @@ class InspIRCdTS6Proto : public IRCDProto
time_t timeleft = x->Expires - Anope::CurTime;
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
- send_cmd(Config->Numeric, "ADDLINE Q %s %s %ld %ld :%s", x->Mask.c_str(), Config->OperServ.c_str(), static_cast<long>(Anope::CurTime), static_cast<long>(timeleft), x->Reason.c_str());
- }
-
- /* SQUIT */
- void SendSquit(const Anope::string &servname, const Anope::string &message)
- {
- send_cmd(Config->Numeric, "SQUIT %s :%s", servname.c_str(), message.c_str());
+ UplinkSocket::Message(Config->Numeric) << "ADDLINE Q " << x->Mask << " " << Config->OperServ << " " << Anope::CurTime << " " << timeleft << " :" << x->Reason;
}
/* Functions that use serval cmd functions */
@@ -184,9 +176,9 @@ class InspIRCdTS6Proto : public IRCDProto
void SendConnect()
{
SendServer(Me);
- send_cmd(Config->Numeric, "BURST");
+ UplinkSocket::Message(Config->Numeric) << "BURST";
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
- send_cmd(Config->Numeric, "VERSION :Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, enc ? enc->name.c_str() : "unknown", Anope::VersionBuildString().c_str());
+ UplinkSocket::Message(Config->Numeric) << "VERSION :Anope-" << Anope::Version() << " " << Config->ServerName << " :" << ircd->name << " - (" << (enc ? enc->name : "unknown") << ") -- " << Anope::VersionBuildString();
}
/* SVSHOLD - set */
@@ -194,7 +186,7 @@ class InspIRCdTS6Proto : public IRCDProto
{
BotInfo *bi = findbot(Config->NickServ);
if (bi)
- send_cmd(bi->GetUID(), "SVSHOLD %s %u :Being held for registered user", nick.c_str(), static_cast<unsigned>(Config->NSReleaseTimeout));
+ UplinkSocket::Message(bi->GetUID()) << "SVSHOLD " << nick << " " << Config->NSReleaseTimeout << " :Being held for registered user";
}
/* SVSHOLD - release */
@@ -202,13 +194,13 @@ class InspIRCdTS6Proto : public IRCDProto
{
BotInfo *bi = findbot(Config->NickServ);
if (bi)
- send_cmd(bi->GetUID(), "SVSHOLD %s", nick.c_str());
+ UplinkSocket::Message(bi->GetUID()) << "SVSHOLD " << nick;
}
/* UNSZLINE */
void SendSZLineDel(const XLine *x)
{
- send_cmd(Config->Numeric, "DELLINE Z %s", x->GetHost().c_str());
+ UplinkSocket::Message(Config->Numeric) << "DELLINE Z " << x->GetHost();
}
/* SZLINE */
@@ -218,39 +210,39 @@ class InspIRCdTS6Proto : public IRCDProto
time_t timeleft = x->Expires - Anope::CurTime;
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
- send_cmd(Config->Numeric, "ADDLINE Z %s %s %ld %ld :%s", x->GetHost().c_str(), x->By.c_str(), static_cast<long>(Anope::CurTime), static_cast<long>(timeleft), x->Reason.c_str());
+ UplinkSocket::Message(Config->Numeric) << "ADDLINE Z " << x->GetHost() << " " << x->By << " " << Anope::CurTime << " " << timeleft <<" :" << x->Reason;
}
void SendSVSJoin(const Anope::string &source, const Anope::string &nick, const Anope::string &chan, const Anope::string &)
{
User *u = finduser(nick);
BotInfo *bi = findbot(source);
- send_cmd(bi->GetUID(), "SVSJOIN %s %s", u->GetUID().c_str(), chan.c_str());
+ UplinkSocket::Message(bi->GetUID()) << "SVSJOIN " << u->GetUID() << " " << chan;
}
void SendSWhois(const Anope::string &, const Anope::string &who, const Anope::string &mask)
{
User *u = finduser(who);
- send_cmd(Config->Numeric, "METADATA %s swhois :%s", u->GetUID().c_str(), mask.c_str());
+ UplinkSocket::Message(Config->Numeric) << "METADATA " << u->GetUID() << " swhois :" << mask;
}
void SendBOB()
{
- send_cmd(Config->Numeric, "BURST %ld", static_cast<long>(Anope::CurTime));
+ UplinkSocket::Message(Config->Numeric) << "BURST " << Anope::CurTime;
}
void SendEOB()
{
- send_cmd(Config->Numeric, "ENDBURST");
+ UplinkSocket::Message(Config->Numeric) << "ENDBURST";
}
void SendGlobopsInternal(BotInfo *source, const Anope::string &buf)
{
if (has_globopsmod)
- send_cmd(source ? source->GetUID() : Config->Numeric, "SNONOTICE g :%s", buf.c_str());
+ UplinkSocket::Message(source ? source->GetUID() : Config->Numeric) << "SNONOTICE g :" << buf;
else
- send_cmd(source ? source->GetUID() : Config->Numeric, "SNONOTICE A :%s", buf.c_str());
+ UplinkSocket::Message(source ? source->GetUID() : Config->Numeric) << "SNONOTICE A :" << buf;
}
void SendLogin(User *u)
@@ -258,17 +250,17 @@ class InspIRCdTS6Proto : public IRCDProto
if (!u->Account() || u->Account()->HasFlag(NI_UNCONFIRMED))
return;
- send_cmd(Config->Numeric, "METADATA %s accountname :%s", u->GetUID().c_str(), u->Account()->display.c_str());
+ UplinkSocket::Message(Config->Numeric) << "METADATA " << u->GetUID() << " accountname :" << u->Account()->display;
}
void SendLogout(User *u)
{
- send_cmd(Config->Numeric, "METADATA %s accountname :", u->GetUID().c_str());
+ UplinkSocket::Message(Config->Numeric) << "METADATA " << u->GetUID() << " accountname :";
}
void SendChannel(Channel *c)
{
- send_cmd(Config->Numeric, "FJOIN %s %ld +%s :", c->name.c_str(), static_cast<long>(c->creation_time), c->GetModes(true, true).c_str());
+ UplinkSocket::Message(Config->Numeric) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :";
}
bool IsNickValid(const Anope::string &nick)
@@ -460,3 +452,32 @@ class InspircdIRCdMessage : public IRCdMessage
}
};
+bool event_idle(const Anope::string &source, const std::vector<Anope::string> &params)
+{
+ BotInfo *bi = findbot(params[0]);
+ UplinkSocket::Message(bi ? bi->GetUID() : params[0]) << "IDLE " << source << " " << start_time << (bi ? Anope::CurTime - bi->lastmsg : 0);
+ return true;
+}
+
+bool event_time(const Anope::string &source, const std::vector<Anope::string> &params)
+{
+ if (params.size() < 2)
+ return true;
+
+ UplinkSocket::Message(Config->Numeric) << "TIME " << source << " " << params[1] << " " << Anope::CurTime;
+ return true;
+}
+
+bool event_rsquit(const Anope::string &source, const std::vector<Anope::string> &params)
+{
+ /* On InspIRCd we must send a SQUIT when we recieve RSQUIT for a server we have juped */
+ Server *s = Server::Find(params[0]);
+ if (s && s->HasFlag(SERVER_JUPED))
+ UplinkSocket::Message(Config->Numeric) << "SQUIT " << s->GetSID() << " :" << (params.size() > 1 ? params[1].c_str() : "");
+
+ ircdmessage->OnSQuit(source, params);
+
+ return true;
+}
+
+
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index 262892c42..adb6ee1fa 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -58,7 +58,7 @@ void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost)
{
if (nick.empty() || vhost.empty())
return;
- send_cmd(Config->OperServ, "CHGHOST %s %s", nick.c_str(), vhost.c_str());
+ UplinkSocket::Message(Config->OperServ) << "CHGHOST " << nick << " " << vhost;
}
else
{
@@ -71,7 +71,7 @@ void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost)
bool event_idle(const Anope::string &source, const std::vector<Anope::string> &params)
{
if (!params.empty())
- send_cmd(params[0], "IDLE %s %ld 0", source.c_str(), static_cast<long>(Anope::CurTime));
+ UplinkSocket::Message(params[0]) << "IDLE " << source << " " << Anope::CurTime << " 0";
return true;
}
@@ -87,12 +87,12 @@ class InspIRCdProto : public IRCDProto
{
void SendAkillDel(const XLine *x)
{
- send_cmd(Config->OperServ, "GLINE %s", x->Mask.c_str());
+ UplinkSocket::Message(Config->OperServ) << "GLINE " << x->Mask;
}
void SendTopic(BotInfo *whosets, Channel *c)
{
- send_cmd(whosets->nick, "FTOPIC %s %lu %s :%s", c->name.c_str(), static_cast<unsigned long>(c->topic_time + 1), c->topic_setter.c_str(), c->topic.c_str());
+ UplinkSocket::Message(whosets->nick) << "FTOPIC " << c->name << " " << c->topic_time << " " << c->topic_setter <<" :" << c->topic;
}
void SendVhostDel(User *u)
@@ -112,54 +112,54 @@ class InspIRCdProto : public IRCDProto
time_t timeleft = x->Expires - Anope::CurTime;
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
- send_cmd(Config->ServerName, "ADDLINE G %s %s %ld %ld :%s", x->Mask.c_str(), x->By.c_str(), static_cast<long>(Anope::CurTime), static_cast<long>(timeleft), x->Reason.c_str());
+ UplinkSocket::Message(Config->ServerName) << "ADDLINE G " << x->Mask << " " << x->By << " " << Anope::CurTime << " " << timeleft << " :" << x->Reason;
}
void SendSVSKillInternal(const BotInfo *source, const User *user, const Anope::string &buf)
{
- send_cmd(source ? source->nick : Config->ServerName, "KILL %s :%s", user->nick.c_str(), buf.c_str());
+ UplinkSocket::Message(source ? source->nick : Config->ServerName) << "KILL " << user->nick << " :" << buf;
}
void SendNumericInternal(const Anope::string &source, int numeric, const Anope::string &dest, const Anope::string &buf)
{
- send_cmd(source, "PUSH %s ::%s %03d %s %s", dest.c_str(), source.c_str(), numeric, dest.c_str(), buf.c_str());
+ UplinkSocket::Message(source) << "PUSH " << dest << " ::" << source << " " << numeric << " " << dest << " " << buf;
}
void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf)
{
- send_cmd(source ? source->nick : Config->ServerName, "FMODE %s %u %s", dest->name.c_str(), static_cast<unsigned>(dest->creation_time), buf.c_str());
+ UplinkSocket::Message(source ? source->nick : Config->ServerName) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf;
}
void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf)
{
- send_cmd(bi ? bi->nick : Config->ServerName, "MODE %s %s", u->nick.c_str(), buf.c_str());
+ UplinkSocket::Message(bi ? bi->nick : Config->ServerName) << "MODE " << u->nick << " " << buf;
}
void SendClientIntroduction(const User *u)
{
Anope::string modes = "+" + u->GetModes();
- send_cmd(Config->ServerName, "NICK %ld %s %s %s %s %s 0.0.0.0 :%s", static_cast<long>(u->timestamp), u->nick.c_str(), u->host.c_str(), u->host.c_str(), u->GetIdent().c_str(), modes.c_str(), u->realname.c_str());
- send_cmd(u->nick, "OPERTYPE Service");
+ UplinkSocket::Message(Config->ServerName) << "NICK " << u->timestamp << " " << u->nick << " " << u->host << " " << u->host << " " << u->GetIdent() << " " << modes << " 0.0.0.0 :" << u->realname;
+ UplinkSocket::Message(u->nick) << "OPERTYPE Service";
}
void SendKickInternal(const BotInfo *source, const Channel *chan, const User *user, const Anope::string &buf)
{
if (!buf.empty())
- send_cmd(source->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf.c_str());
+ UplinkSocket::Message(source->nick) << "KICK " << chan->name << " " << user->nick << " :" << buf;
else
- send_cmd(source->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), user->nick.c_str());
+ UplinkSocket::Message(source->nick) << "KICK " << chan->name << " " << user->nick << " :" << user->nick;
}
/* SERVER services-dev.chatspike.net password 0 :Description here */
void SendServer(const Server *server)
{
- send_cmd(Config->ServerName, "SERVER %s %s %d :%s", server->GetName().c_str(), currentpass.c_str(), server->GetHops(), server->GetDescription().c_str());
+ UplinkSocket::Message(Config->ServerName) << "SERVER " << server->GetName() << " " << currentpass << " " << server->GetHops() << " :" << server->GetDescription();
}
/* JOIN */
void SendJoin(User *user, Channel *c, const ChannelStatus *status)
{
- send_cmd(user->nick, "JOIN %s %ld", c->name.c_str(), static_cast<long>(c->creation_time));
+ UplinkSocket::Message(user->nick) << "JOIN " << c->name << " " << c->creation_time;
if (status)
{
/* First save the channel status incase uc->Status == status */
@@ -181,7 +181,7 @@ class InspIRCdProto : public IRCDProto
/* UNSQLINE */
void SendSQLineDel(const XLine *x)
{
- send_cmd(Config->OperServ, "QLINE %s", x->Mask.c_str());
+ UplinkSocket::Message(Config->OperServ) << "QLINE " << x->Mask;
}
/* SQLINE */
@@ -191,13 +191,7 @@ class InspIRCdProto : public IRCDProto
time_t timeleft = x->Expires - Anope::CurTime;
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
- send_cmd(Config->ServerName, "ADDLINE Q %s %s %ld %ld :%s", x->Mask.c_str(), Config->OperServ.c_str(), static_cast<long>(Anope::CurTime), static_cast<long>(timeleft), x->Reason.c_str());
- }
-
- /* SQUIT */
- void SendSquit(const A