diff options
Diffstat (limited to 'modules/protocol')
-rw-r--r-- | modules/protocol/bahamut.cpp | 101 | ||||
-rw-r--r-- | modules/protocol/inspircd-ts6.h | 101 | ||||
-rw-r--r-- | modules/protocol/inspircd11.cpp | 66 | ||||
-rw-r--r-- | modules/protocol/inspircd12.cpp | 49 | ||||
-rw-r--r-- | modules/protocol/inspircd20.cpp | 58 | ||||
-rw-r--r-- | modules/protocol/plexus.cpp | 130 | ||||
-rw-r--r-- | modules/protocol/ratbox.cpp | 123 | ||||
-rw-r--r-- | modules/protocol/unreal.cpp | 125 |
8 files changed, 300 insertions, 453 deletions
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> ¶ms) +{ + 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> ¶ms) +{ + 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> ¶ms) +{ + /* 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> ¶ms) { 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 Anope::string &servname, const Anope::string &message) - { - send_cmd(Config->ServerName, "SQUIT %s :%s", servname.c_str(), message.c_str()); + UplinkSocket::Message(Config->ServerName) << "ADDLINE Q " << x->Mask << " " << x->By << " " << Anope::CurTime << " " << timeleft << " :" << x->Reason; } /* Functions that use serval cmd functions */ @@ -214,9 +208,9 @@ class InspIRCdProto : public IRCDProto { inspircd_cmd_pass(Config->Uplinks[CurrentUplink]->password); SendServer(Me); - send_cmd("", "BURST"); + UplinkSocket::Message() << "BURST"; Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); - send_cmd(Config->ServerName, "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->ServerName) << "VERSION :Anope-" << Anope::Version() << " " << Me->GetName() << " :" << ircd->name << " - (" << (enc ? enc->name : "unknown") << ") -- " << Anope::VersionBuildString(); } /* CHGIDENT */ @@ -226,7 +220,7 @@ class InspIRCdProto : public IRCDProto { if (nick.empty() || vIdent.empty()) return; - send_cmd(Config->OperServ, "CHGIDENT %s %s", nick.c_str(), vIdent.c_str()); + UplinkSocket::Message(Config->OperServ) << "CHGIDENT " << nick << " " << vIdent; } else Log() << "CHGIDENT not loaded!"; @@ -235,19 +229,19 @@ class InspIRCdProto : public IRCDProto /* SVSHOLD - set */ void SendSVSHold(const Anope::string &nick) { - send_cmd(Config->OperServ, "SVSHOLD %s %ds :Being held for registered user", nick.c_str(), static_cast<int>(Config->NSReleaseTimeout)); + UplinkSocket::Message(Config->OperServ) << "SVSHOLD " << nick << " " << Config->NSReleaseTimeout << "s :Being held for registered user"; } /* SVSHOLD - release */ void SendSVSHoldDel(const Anope::string &nick) { - send_cmd(Config->OperServ, "SVSHOLD %s", nick.c_str()); + UplinkSocket::Message(Config->OperServ) << "SVSHOLD " << nick; } /* UNSZLINE */ void SendSZLineDel(const XLine *x) { - send_cmd(Config->OperServ, "ZLINE %s", x->GetHost().c_str()); + UplinkSocket::Message(Config->OperServ) << "ZLINE " << x->GetHost(); } /* SZLINE */ @@ -257,22 +251,22 @@ class InspIRCdProto : public IRCDProto time_t timeleft = x->Expires - Anope::CurTime; if (timeleft > 172800 || !x->Expires) timeleft = 172800; - send_cmd(Config->ServerName, "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->ServerName) << "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 &) { - send_cmd(source, "SVSJOIN %s %s", nick.c_str(), chan.c_str()); + UplinkSocket::Message(source) << "SVSJOIN " << nick << " " << chan; } void SendBOB() { - send_cmd("", "BURST %ld", static_cast<long>(Anope::CurTime)); + UplinkSocket::Message() << "BURST " << Anope::CurTime; } void SendEOB() { - send_cmd("", "ENDBURST"); + UplinkSocket::Message() << "ENDBURST"; } void SendLogin(User *u) @@ -574,21 +568,21 @@ class InspircdIRCdMessage : public IRCdMessage { if (!has_globopsmod) { - send_cmd("", "ERROR :m_globops is not loaded. This is required by Anope"); + UplinkSocket::Message() << "ERROR :m_globops is not loaded. This is required by Anope"; quitmsg = "ERROR: Remote server does not have the m_globops module loaded, and this is required."; quitting = true; return false; } if (!has_servicesmod) { - send_cmd("", "ERROR :m_services is not loaded. This is required by Anope"); + UplinkSocket::Message() << "ERROR :m_services is not loaded. This is required by Anope"; quitmsg = "ERROR: Remote server does not have the m_services module loaded, and this is required."; quitting = true; return false; } if (!has_hidechansmod) { - send_cmd("", "ERROR :m_hidechans.so is not loaded. This is required by Anope"); + UplinkSocket::Message() << "ERROR :m_hidechans.so is not loaded. This is required by Anope"; quitmsg = "ERROR: Remote server deos not have the m_hidechans module loaded, and this is required."; quitting = true; return false; diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 88d45bd79..1af63c37b 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -54,28 +54,6 @@ static bool has_servicesmod = false; static bool has_svsholdmod = false; static bool has_hidechansmod = false; -/* CHGHOST */ -void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost) -{ - if (!has_chghostmod) - { - Log() << "CHGHOST not loaded!"; - return; - } - - User *u = finduser(nick); - send_cmd(u ? u->GetUID() : Config->Numeric, "CHGHOST %s %s", nick.c_str(), vhost.c_str()); -} - -bool event_idle(const Anope::string &source, const std::vector<Anope::string> ¶ms) -{ - BotInfo *bi = findbot(params[0]); - - send_cmd(bi ? bi->GetUID() : params[0], "IDLE %s %ld %ld", source.c_str(), static_cast<long>(start_time), bi ? (static_cast<long>(Anope::CurTime - bi->lastmsg)) : 0); - return true; -} - - bool event_ftopic(const Anope::string &source, const std::vector<Anope::string> ¶ms) { /* :source FTOPIC channel ts setby :topic */ @@ -144,27 +122,6 @@ bool event_fmode(const Anope::string &source, const std::vector<Anope::string> & return ircdmessage->OnMode(source, newparams); } -bool event_time(const Anope::string &source, const std::vector<Anope::string> ¶ms) -{ - if (params.size() < 2) - return true; - - send_cmd(Config->Numeric, "TIME %s %s %ld", source.c_str(), params[1].c_str(), static_cast<long>(Anope::CurTime)); - return true; -} - -bool event_rsquit(const Anope::string &source, const std::vector<Anope::string> ¶ms) -{ - /* 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)) - send_cmd(Config->Numeric, "SQUIT %s :%s", s->GetSID().c_str(), params.size() > 1 ? params[1].c_str() : ""); - - ircdmessage->OnSQuit(source, params); - - return true; -} - bool event_setname(const Anope::string &source, const std::vector<Anope::string> ¶ms) { User *u = finduser(source); @@ -693,21 +650,21 @@ class Inspircd12IRCdMessage : public InspircdIRCdMessage { if (!has_globopsmod) { - send_cmd("", "ERROR :m_globops is not loaded. This is required by Anope"); + UplinkSocket::Message() << "ERROR :m_globops is not loaded. This is required by Anope"; quitmsg = "Remote server does not have the m_globops module loaded, and this is required."; quitting = true; return false; } if (!has_servicesmod) { - send_cmd("", "ERROR :m_services_account.so is not loaded. This is required by Anope"); + UplinkSocket::Message() << "ERROR :m_services_account.so is not loaded. This is required by Anope"; quitmsg = "ERROR: Remote server does not have the m_services_account module loaded, and this is required."; quitting = true; return false; } if (!has_hidechansmod) { - send_cmd("", "ERROR :m_hidechans.so is not loaded. This is required by Anope"); + UplinkSocket::Message() << "ERROR :m_hidechans.so is not loaded. This is required by Anope"; quitmsg = "ERROR: Remote server does not have the m_hidechans module loaded, and this is required."; quitting = true; return false; diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 23924a2cc..1e1eff8fd 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -53,38 +53,17 @@ IRCDVar myIrcd[] = { static bool has_servicesmod = false; static bool has_svsholdmod = false; -/* CHGHOST */ -void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost) -{ - if (!has_chghostmod) - { - Log() << "CHGHOST not loaded!"; - return; - } - - User *u = finduser(nick); - send_cmd(u ? u->GetUID() : Config->Numeric, "CHGHOST %s %s", nick.c_str(), vhost.c_str()); -} - -bool event_idle(const Anope::string &source, const std::vector<Anope::string> ¶ms) -{ - BotInfo *bi = findbot(params[0]); - - send_cmd(bi ? bi->GetUID() : params[0], "IDLE %s %ld %ld", source.c_str(), static_cast<long>(start_time), bi ? (static_cast<long>(Anope::CurTime - bi->lastmsg)) : 0); - return true; -} - class InspIRCdProto : public InspIRCdTS6Proto { void SendConnect() { - send_cmd("", "CAPAB START 1202"); - send_cmd("", "CAPAB CAPABILITIES :PROTOCOL=1202"); - send_cmd("", "CAPAB END"); + UplinkSocket::Message() << "CAPAB START 1202"; + UplinkSocket::Message() << "CAPAB CAPABILITIES :PROTOCOL=1202"; + UplinkSocket::Message() << "CAPAB END"; 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() << " " << Me->GetName() << " :" << ircd->name <<" - (" << (enc ? enc->name : "unknown") << ") -- " << Anope::VersionBuildString(); } }; @@ -155,27 +134,6 @@ bool event_fmode(const Anope::string &source, const std::vector<Anope::string> & return ircdmessage->OnMode(source, newparams); } -bool event_time(const Anope::string &source, const std::vector<Anope::string> ¶ms) -{ - if (params.size() < 2) - return true; - - send_cmd(Config->Numeric, "TIME %s %s %ld", source.c_str(), params[1].c_str(), static_cast<long>(Anope::CurTime)); - return true; -} - -bool event_rsquit(const Anope::string &source, const std::vector<Anope::string> ¶ms) -{ - /* 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)) - send_cmd(Config->Numeric, "SQUIT %s :%s", s->GetSID().c_str(), params.size() > 1 ? params[1].c_str() : ""); - - ircdmessage->OnSQuit(source, params); - - return true; -} - bool event_setname(const Anope::string &source, const std::vector<Anope::string> ¶ms) { User *u = finduser(source); @@ -429,7 +387,7 @@ class Inspircd20IRCdMessage : public InspircdIRCdMessage { if (params.size() < 2 || (Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0) < 1202) { - send_cmd("", "ERROR :Protocol mismatch, no or invalid protocol version given in CAPAB START"); + UplinkSocket::Message() << "ERROR :Protocol mismatch, no or invalid protocol version given in CAPAB START"; quitmsg = "Protocol mismatch, no or invalid protocol version given in CAPAB START"; quitting = true; return false; @@ -713,14 +671,14 @@ class Inspircd20IRCdMessage : public InspircdIRCdMessage { if (!has_servicesmod) { - send_cmd("", "ERROR :m_services_account.so is not loaded. This is required by Anope"); + UplinkSocket::Message() << "ERROR :m_services_account.so is not loaded. This is required by Anope"; quitmsg = "ERROR: Remote server does not have the m_services_account module loaded, and this is required."; quitting = true; return false; } if (!ModeManager::FindUserModeByName(UMODE_PRIV)) { - send_cmd("", "ERROR :m_hidechans.so is not loaded. This is required by Anope"); + UplinkSocket::Message() << "ERROR :m_hidechans.so is not loaded. This is required by Anope"; quitmsg = "ERROR: Remote server does not have the m_hidechans module loaded, and this is required."; quitting = true; return false; diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index 92b55ac46..ebed5e16c 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -44,88 +44,44 @@ IRCDVar myIrcd[] = { {NULL} }; -/* - * 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 - */ -static inline void plexus_cmd_svinfo() -{ - send_cmd("", "SVINFO 6 5 0 :%ld", static_cast<long>(Anope::CurTime)); -} - -/* CAPAB - * QS - Can handle quit storm removal - * EX - Can do channel +e exemptions - * CHW - Can do channel wall @# - * LL - Can do lazy links - * IE - Can do invite exceptions - * EOB - Can do EOB message - * KLN - Can do KLINE message - * GLN - Can do GLINE message - * HUB - This server is a HUB - * AOPS - Can do anon ops (+a) - * UID - Can do UIDs - * ZIP - Can do ZIPlinks - * ENC - Can do ENCrypted links - * KNOCK - Supports KNOCK - * TBURST - Supports TBURST - * PARA - Supports invite broadcasting for +p - * ENCAP - Supports encapsulization of protocol messages - * SVS - Supports services protocol extensions - */ -static inline void plexus_cmd_capab() -{ - send_cmd("", "CAPAB :QS EX CHW IE EOB KLN UNKLN GLN HUB KNOCK TBURST PARA ENCAP SVS"); -} - -/* PASS */ -void plexus_cmd_pass(const Anope::string &pass) -{ - send_cmd("", "PASS %s TS 6 :%s", pass.c_str(), Config->Numeric.c_str()); -} - class PlexusProto : public IRCDProto { void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) { - send_cmd(source ? source->GetUID() : Config->Numeric, "OPERWALL :%s", buf.c_str()); + UplinkSocket::Message(source ? source->GetUID() : Me->GetSID()) << "OPERWALL :" << buf; } void SendSQLine(User *, const XLine *x) { - send_cmd(Config->Numeric, "RESV * %s :%s", x->Mask.c_str(), x->Reason.c_str()); + UplinkSocket::Message(Me->GetSID()) << "RESV * " << x->Mask << " :" << x->Reason; } void SendSGLineDel(const XLine *x) { BotInfo *bi = findbot(Config->OperServ); - send_cmd(bi ? bi->GetUID() : Config->OperServ, "UNXLINE * %s", x->Mask.c_str()); + UplinkSocket::Message(bi ? bi->GetUID() : Config->OperServ) << "UNXLINE * " << x->Mask; } void SendSGLine(User *, const XLine *x) { BotInfo *bi = findbot(Config->OperServ); - send_cmd(bi ? bi->GetUID() : Config->OperServ, "XLINE * %s 0 :%s", x->Mask.c_str(), x->Reason.c_str()); + UplinkSocket::Message(bi ? bi->GetUID() : Config->OperServ) << "XLINE * " << x->Mask << " 0 :" << x->Reason; } void SendAkillDel(const XLine *x) { BotInfo *bi = findbot(Config->OperServ); - send_cmd(bi ? bi->GetUID() : Config->OperServ, "UNKLINE * %s %s", x->GetUser().c_str(), x->GetHost().c_str()); + UplinkSocket::Message(bi ? bi->GetUID() : Config->OperServ) << "UNKLINE * " << x->GetUser() << " " << x->GetHost(); } void SendSQLineDel(const XLine *x) { - send_cmd(Config->Numeric, "UNRESV * %s", x->Mask.c_str()); + UplinkSocket::Message(Me->GetSID()) << "UNRESV * " << x->Mask; } void SendJoin(User *user, Channel *c, const ChannelStatus *status) { - send_cmd(Config->Numeric, "SJOIN %ld %s +%s :%s", static_cast<long>(c->creation_time), c->name.c_str(), c->GetModes(true, true).c_str(), user->GetUID().c_str()); + UplinkSocket::Message(Me->GetSID()) << "SJOIN " << c->creation_time << " " << c->name << " +" << c->GetModes(true, true) << " :" << user->GetUID(); if (status) { /* First save the channel status incase uc->Status == status */ @@ -151,25 +107,25 @@ class PlexusProto : public IRCDProto if (timeleft > 172800 || !x->Expires) timeleft = 172800; BotInfo *bi = findbot(Config->OperServ); - send_cmd(bi ? bi->GetUID() : Config->OperServ, "KLINE * %ld %s %s :%s", static_cast<long>(timeleft), x->GetUser().c_str(), x->GetHost().c_str(), x->Reason.c_str()); + UplinkSocket::Message(bi ? bi->GetUID() : Config->OperServ) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << 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() : Me->GetSID()) << "KILL " << user->GetUID() << " :" << buf; } void SendServer(const Server *server) { if (server == Me) - 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(); else - send_cmd(Config->Numeric, "SID %s %d %s :%s", server->GetName().c_str(), 2, server->GetSID().c_str(), server->GetDescription().c_str()); + UplinkSocket::Message(Me->GetSID()) << "SID " << server->GetName() << " " << server->GetHops() << " " << server->GetSID() << " :" << server->GetDescription(); } void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when) { - send_cmd(Config->Numeric, "ENCAP %s SVSNICK %s %ld %s %ld", u->server->GetName().c_str(), u->GetUID().c_str(), static_cast<long>(u->timestamp), newnick.c_str(), static_cast<long>(when)); + UplinkSocket::Message(Me->GetSID()) << "ENCAP " << u->server->GetName() << " SVSNICK " << u->GetUID() << " " << u->timestamp << " " << newnick << " " << when; } void SendVhostDel(User *u) @@ -184,56 +140,84 @@ class PlexusProto : public IRCDProto void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) { if (!ident.empty()) - send_cmd(Config->Numeric, "ENCAP * CHGIDENT %s %s", u->nick.c_str(), ident.c_str()); - send_cmd(Config->Numeric, "ENCAP * CHGHOST %s %s", u->nick.c_str(), host.c_str()); + UplinkSocket::Message(Me->GetSID()) << "ENCAP * CHGIDENT " << u->GetUID() << " " << ident; + UplinkSocket::Message(Me->GetSID()) << "ENCAP * CHGHOST " << u->GetUID() << " " << host; } void SendConnect() { - plexus_cmd_pass(Config->Uplinks[CurrentUplink]->password); - plexus_cmd_capab(); + UplinkSocket::Message() << "PASS " << Config->Uplinks[CurrentUplink]->password << " TS 6 :" << Me->GetSID(); + /* CAPAB + * QS - Can handle quit storm removal + * EX - Can do channel +e exemptions + * CHW - Can do channel wall @# + * LL - Can do lazy links + * IE - Can do invite exceptions + * EOB - Can do EOB message + * KLN - Can do KLINE message + * GLN - Can do GLINE message + * HUB - This server is a HUB + * AOPS - Can do anon ops (+a) + * UID - Can do UIDs + * ZIP - Can do ZIPlinks + * ENC - Can do ENCrypted links + * KNOCK - Supports KNOCK + * TBURST - Supports TBURST + * PARA - Supports invite broadcasting for +p + * ENCAP - Supports encapsulization of protocol messages + * SVS - Supports services protocol extensions + */ + UplinkSocket::Message() << "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); - plexus_cmd_svinfo(); + /* + * 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 6 5 0 :" << Anope::CurTime; } void SendClientIntroduction(const User *u) { Anope::string modes = "+" + u->GetModes(); - send_cmd(Config->Numeric, "UID %s 1 %ld %s %s %s 255.255.255.255 %s 0 %s :%s", u->nick.c_str(), static_cast<long>(u->timestamp), modes.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->GetUID().c_str(), u->host.c_str(), u->realname.c_str()); + UplinkSocket::Message(Me->GetSID()) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 255.255.255.255 " << u->GetUID() << " 0 " << u->host << " :" << u->realname; } void SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf) { if (!buf.empty()) - send_cmd(bi->GetUID(), "PART %s :%s", chan->name.c_str(), buf.c_str()); + UplinkSocket::Message(bi->GetUID()) << "PART " << chan->name << " :" << buf; else - send_cmd(bi->GetUID(), "PART %s", chan->name.c_str()); + UplinkSocket::Message(bi->GetUID()) << "PART " << chan->name; } void SendModeInternal(const BotInfo *bi, const Channel *dest, const Anope::string &buf) { - send_cmd(bi ? bi->GetUID() : Config->Numeric, "MODE %s %s", dest->name.c_str(), buf.c_str()); + UplinkSocket::Message(bi ? bi->GetUID() : Me->GetSID()) << "MODE " << dest->name << " " << buf; } void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) { - send_cmd(bi ? bi->GetUID() : Config->Numeric, "ENCAP * SVSMODE %s %ld %s", u->GetUID().c_str(), static_cast<long>(u->timestamp), buf.c_str()); + UplinkSocket::Message(bi ? bi->GetUID() : Me->GetSID()) << "ENCAP * SVSMODE " << u->GetUID() << " " << u->timestamp << " " << buf; } void SendKickInternal(const BotInfo *bi, const Channel *chan, const User *user, const Anope::string &buf) { if (!buf.empty()) - send_cmd(bi->GetUID(), "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), buf.c_str()); + UplinkSocket::Message(bi->GetUID()) << "KICK " << chan->name << " " << user->GetUID() << " :" << buf; else - send_cmd(bi->GetUID(), "KICK %s %s", chan->name.c_str(), user->GetUID().c_str()); + UplinkSocket::Message(bi->GetUID()) << "KICK " << chan->name << " " << user->GetUID(); } /* INVITE */ void SendInvite(BotInfo *source, const Anope::string &chan, const Anope::string &nick) { User *u = finduser(nick); - send_cmd(source->GetUID(), "INVITE %s %s", u ? u->GetUID().c_str() : nick.c_str(), chan.c_str()); + UplinkSocket::Message(source->GetUID()) << "INVITE " << (u ? u->GetUID() : nick) << " " << chan; } void SendLogin(User *u) @@ -241,17 +225,17 @@ class PlexusProto : public IRCDProto if (!u->Account()) return; - send_cmd(Config->Numeric, "ENCAP * SU %s %s", u->GetUID().c_str(), u->Account()->display.c_str()); + UplinkSocket::Message(Me->GetSID()) << "ENCAP * SU " << u->GetUID() << " " << u->Account()->display; } void SendLogout(User *u) { - send_cmd(Config->Numeric, "ENCAP * SU %s", u->GetUID().c_str()); + UplinkSocket::Message(Me->GetSID()) << "ENCAP * SU " << u->GetUID(); } void SendTopic(BotInfo *bi, Channel *c) { - send_cmd(bi->GetUID(), "ENCAP * TOPIC %s %s %lu :%s", c->name.c_str(), c->topic_setter.c_str(), static_cast<unsigned long>(c->topic_time + 1), c->topic.c_str()); + UplinkSocket::Message(bi->GetUID()) << "ENCAP * TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_time + 1 << " :" << c->topic; } void SendChannel(Channel *c) @@ -259,7 +243,7 @@ class PlexusProto : public IRCDProto Anope::string modes = c->GetModes(true, true); if (modes.empty()) modes = "+"; - send_cmd(Config->Numeric, "SJOIN %ld %s %s :", static_cast<long>(c->creation_time), c->name.c_str(), modes.c_str()); + UplinkSocket::Message(Me->GetSID()) << "SJOIN " << c->creation_time << " " << c->name << " " << modes << "%s :"; } }; diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index 6cb58968f..f82f2c322 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -44,86 +44,39 @@ IRCDVar myIrcd[] = { {NULL} }; -/* - * 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 ratbox_cmd_svinfo() -{ - send_cmd("", "SVINFO 6 3 0 :%ld", static_cast<long>(Anope::CurTime)); -} - -void ratbox_cmd_svsinfo() -{ -} - -/* CAPAB */ -/* - QS - Can handle quit storm removal - EX - Can do channel +e exemptions - CHW - Can do channel wall @# - LL - Can do lazy links - IE - Can do invite exceptions - EOB - Can do EOB message - KLN - Can do KLINE message - GLN - Can do GLINE message - HUB - This server is a HUB - UID - Can do UIDs - ZIP - Can do ZIPlinks - ENC - Can do ENCrypted links - KNOCK - supports KNOCK - TBURST - supports TBURST - PARA - supports invite broadcasting for +p - ENCAP - ? -*/ -void ratbox_cmd_capab() -{ - send_cmd("", "CAPAB :QS EX CHW IE KLN GLN KNOCK TB UNKLN CLUSTER ENCAP TS6"); -} - -/* PASS */ -void ratbox_cmd_pass(const Anope::string &pass) -{ - send_cmd("", "PASS %s TS 6 :%s", pass.c_str(), Config->Numeric.c_str()); -} - class RatboxProto : public IRCDProto { void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) { - send_cmd(source ? source->GetUID() : Config->Numeric, "OPERWALL :%s", buf.c_str()); + UplinkSocket::Message(source ? source->GetUID() : Me->GetSID()) << "OPERWALL :" << buf; } void SendSQLine(User *, const XLine *x) { - send_cmd(Config->Numeric, "RESV * %s :%s", x->Mask.c_str(), x->Reason.c_str()); + UplinkSocket::Message(Me->GetSID()) << "RESV * " << x->Mask << " :" << x->Reason; } void SendSGLineDel(const XLine *x) { BotInfo *bi = findbot(Config->OperServ); - send_cmd(bi ? bi->GetUID() : Config->OperServ, "UNXLINE * %s", x->Mask.c_str()); + UplinkSocket::Message(bi ? bi->GetUID() : Config->OperServ) << "UNXLINE * " << x->Mask; } void SendSGLine(User *, const XLine *x) { BotInfo *bi = findbot(Config->OperServ); - send_cmd(bi ? bi->GetUID() : Config->OperServ, "XLINE * %s 0 :%s", x->Mask.c_str(), x->Reason.c_str()); + UplinkSocket::Message(bi ? bi->GetUID() : Config->OperServ) << "XLINE * " << x->Mask << " 0 :" << x->Reason; } void SendAkillDel(const XLine *x) { BotInfo *bi = findbot(Config->OperServ); - send_cmd(bi ? bi->GetUID() : Config->OperServ, "UNKLINE * %s %s", x->GetUser().c_str(), x->GetHost().c_str()); + UplinkSocket::Message(bi ? bi->GetUID() : Config->OperServ) << "UNKLINE * " << x->GetUser() << " " << x->GetHost(); } void SendSQLineDel(const XLine *x) { - send_cmd(Config->Numeric, "UNRESV * %s", x->Mask.c_str()); + UplinkSocket::Message(Me->GetSID()) << "UNRESV * " << x->Mask; } void SendJoin(User *user, Channel *c, const ChannelStatus *status) @@ -132,7 +85,7 @@ class RatboxProto : public IRCDProto * can not add them to the mode stacker because ratbox * does not allow *any* client to op itself */ - send_cmd("", "SJOIN %ld %s +%s :%s%s", static_cast<long>(c->creation_time), c->name.c_str(), c->GetModes(true, true).c_str(), status != NULL ? status->BuildModePrefixList().c_str() : "", user->GetUID().c_str()); + UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " +" << c->GetModes(true, true) << " :" << (status != NULL ? status->BuildModePrefixList() : "") << user->GetUID(); /* And update our internal status for this user since this is not going through our mode handling system */ if (status != NULL) { @@ -149,66 +102,92 @@ class RatboxProto : public IRCDProto if (timeleft > 172800 || !x->Expires) timeleft = 172800; BotInfo *bi = findbot(Config->OperServ); - send_cmd(bi ? bi->GetUID() : Config->OperServ, "KLINE * %ld %s %s :%s", static_cast<long>(timeleft), x->GetUser().c_str(), x->GetHost().c_str(), x->Reason.c_str()); + UplinkSocket::Message(bi ? bi->GetUID() : Config->OperServ) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << 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() : Me->GetSID()) << "KILL " << user->GetUID() << " :" << buf; } /* SERVER name hop descript */ 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() { - ratbox_cmd_pass(Config->Uplinks[CurrentUplink]->password); - ratbox_cmd_capab(); + UplinkSocket::Message() << "PASS " << Config->Uplinks[CurrentUplink]->password << " TS 6 :" << Me->GetSID(); + /* + QS - Can handle quit storm removal + EX - Can do channel +e exemptions + CHW - Can do channel wall @# + LL - Can do lazy links + IE - Can do invite exceptions + EOB - Can do EOB message + KLN - Can do KLINE message + GLN - Can do GLINE message + HUB - This server is a HUB + UID - Can do UIDs + ZIP - Can do ZIPlinks + ENC - Can do ENCrypted links + KNOCK - supports KNOCK + TBURST - supports TBURST + PARA - supports invite broadcasting for +p + ENCAP - ? + */ + UplinkSocket::Message() << "CAPAB :QS EX CHW IE KLN GLN KNOCK TB UNKLN CLUSTER ENCAP TS6"; /* Make myself known to myself in the serverlist */ SendServer(Me); - ratbox_cmd_svinfo(); + /* + * 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 6 3 0 :" << Anope::CurTime; } void SendClientIntroduction(const User *u) { Anope::string modes = "+" + u->GetModes(); - send_cmd(Config->Numeric, "UID %s 1 %ld %s %s %s 0 %s :%s", u->nick.c_str(), static_cast<long>(u->timestamp), modes.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->GetUID().c_str(), u->realname.c_str()); + UplinkSocket::Message(Me->GetSID()) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " :" << u->realname; } void SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf) { if (!buf.empty()) - send_cmd(bi->GetUID(), "PART %s :%s", chan->name.c_str(), buf.c_str()); + UplinkSocket::Message(bi->GetUID()) << "PART " << chan->name << " :" << buf; else - send_cmd(bi->GetUID(), "PART %s", chan->name.c_str()); + UplinkSocket::Message(bi->GetUID()) << "PART " << chan->name; } void SendModeInternal(const BotInfo *bi, const Channel *dest, const Anope::string &buf) { - send_cmd(bi ? bi->GetUID() : Config->Numeric, "MODE %s %s", dest->name.c_str(), buf.c_str()); + UplinkSocket::Message(bi ? bi->GetUID() : Me->GetSID()) << "MODE " << dest->name << " " << buf; } void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) { - send_cmd(bi ? bi->GetUID() : Config->Numeric, "SVSMODE %s %s", u->nick.c_str(), buf.c_str()); + UplinkSocket::Message(bi ? bi->GetUID() : Me->GetSID()) << "SVSMODE " << u->nick << " " << buf; } void SendKickInternal(const BotInfo *bi, const Channel *chan, const User *user, const Anope::string &buf) { if (!buf.empty()) - send_cmd(bi->GetUID(), "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), buf.c_str()); + UplinkSocket::Message(bi->GetUID()) << "KICK " << chan->name << " " << user->GetUID() << " :" << buf; else - send_cmd(bi->GetUID(), "KICK %s %s", chan->name.c_str(), user->GetUID().c_str()); + UplinkSocket::Message(bi->GetUID()) << "KICK " << chan->name << " " << user->GetUID(); } /* INVITE */ void SendInvite(BotInfo *source, const Anope::string &chan, const Anope::string &nick) { User *u = finduser(nick); - send_cmd(source->GetUID(), "INVITE %s %s", u ? u->GetUID().c_str() : nick.c_str(), chan.c_str()); + UplinkSocket::Message(source->GetUID()) << "INVITE " << (u ? u->GetUID() : nick) << " " << chan; } void SendLogin(User *u) @@ -216,12 +195,12 @@ class RatboxProto : public IRCDProto if (!u->Account()) return; - send_cmd(Config->Numeric, "ENCAP * SU %s %s", u->GetUID().c_str(), u->Account()->display.c_str()); + UplinkSocket::Message(Me->GetSID()) << "ENCAP * SU " << u->GetUID() << " " << u->Account()->display; } void SendLogout(User *u) { - send_cmd(Config->Numeric, "ENCAP * SU %s", u->GetUID().c_str()); + UplinkSocket::Message(Me->GetSID()) << "ENCAP * SU " << u->GetUID(); } void SendChannel(Channel *c) @@ -229,7 +208,7 @@ class RatboxProto : 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 << " :"; } bool IsNickValid(const Anope::string &nick) @@ -250,7 +229,7 @@ class RatboxProto : public IRCDProto status.SetFlag(CMODE_OP); bi->Join(c, &status); } - send_cmd(bi->GetUID(), "TOPIC %s :%s", c->name.c_str(), c->topic.c_str()); + UplinkSocket::Message(bi->GetUID()) << "TOPIC " << c->name << " :" << c->topic; if (needjoin) bi->Part(c); } diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 51b248278..5a5a2fd55 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -44,67 +44,22 @@ IRCDVar myIrcd[] = { {NULL} }; -/* PROTOCTL */ -/* - NICKv2 = Nick Version 2 - VHP = Sends hidden host - UMODE2 = sends UMODE2 on user modes - NICKIP = Sends IP on NICK - TOKEN = Use tokens to talk - SJ3 = Supports SJOIN - NOQUIT = No Quit - TKLEXT = Extended TKL we don't use it but best to have it - SJB64 = Base64 encoded time stamps - VL = Version Info - NS = Config->Numeric Server - -*/ -void unreal_cmd_capab() -{ - if (!Config->Numeric.empty()) - send_cmd("", "PROTOCTL NICKv2 VHP UMODE2 NICKIP TOKEN SJOIN SJOIN2 SJ3 NOQUIT TKLEXT VL"); - else - send_cmd("", "PROTOCTL NICKv2 VHP UMODE2 NICKIP TOKEN SJOIN SJOIN2 SJ3 NOQUIT TKLEXT"); -} - -/* PASS */ -void unreal_cmd_pass(const Anope::string &pass) -{ - send_cmd("", "PASS :%s", pass.c_str()); -} - -/* CHGHOST */ -void unreal_cmd_chghost(const Anope::string &nick, const Anope::string &vhost) -{ - if (nick.empty() || vhost.empty()) - return; - send_cmd(Config->ServerName, "AL %s %s", nick.c_str(), vhost.c_str()); -} - -/* CHGIDENT */ -void unreal_cmd_chgident(const Anope::string &nick, const Anope::string &vIdent) -{ - if (nick.empty() || vIdent.empty()) - return; - send_cmd(Config->ServerName, "AZ %s %s", nick.c_str(), vIdent.c_str()); -} - class UnrealIRCdProto : public IRCDProto { /* SVSNOOP */ void SendSVSNOOP(const Server *server, bool set) { - send_cmd("", "f %s %s", server->GetName().c_str(), set ? "+" : "-"); + UplinkSocket::Message() << "f " << server->GetName() << " " << (set ? "+" : "-"); } void SendAkillDel(const XLine *x) { - send_cmd("", "BD - G %s %s %s", x->GetUser().c_str(), x->GetHost().c_str(), Config->OperServ.c_str()); + UplinkSocket::Message() << "BD - G " << x->GetUser() << " " << x->GetHost() << " " << Config->OperServ; } void SendTopic(BotInfo *whosets, Channel *c) { - send_cmd(whosets->nick, ") %s %s %lu :%s", c->name.c_str(), c->topic_setter.c_str(), static_cast<unsigned long>(c->topic_time + 1), c->topic.c_str()); + UplinkSocket::Message(whosets->nick) << ") " << c->name << " " << c->topic_setter << " " << c->topic_time + 1 << " :" << c->topic; } void SendVhostDel(User *u) @@ -122,36 +77,36 @@ class UnrealIRCdProto : public IRCDProto time_t timeleft = x->Expires - Anope::CurTime; if (timeleft > 172800) timeleft = 172800; - send_cmd("", "BD + G %s %s %s %ld %ld :%s", x->GetUser().c_str(), x->GetHost().c_str(), x->By.c_str(), static_cast<long>(Anope::CurTime + timeleft), static_cast<long>(x->Created), x->Reason.c_str()); + UplinkSocket::Message() << "BD + G " << x->GetUser() << " " << x->GetHost() << " " << x->By << " " << Anope::CurTime + timeleft << " " << x->Created << " :" << x->Reason; } void SendSVSKillInternal(const BotInfo *source, const User *user, const Anope::string &buf) { - send_cmd(source ? source->nick : Config->ServerName, "h %s :%s", user->nick.c_str(), buf.c_str()); + UplinkSocket::Message(source ? source->nick : Config->ServerName) << "h " << user->nick << " :" << buf; } void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) { - send_cmd(source ? source->nick : Config->ServerName, "G %s %s", dest->name.c_str(), buf.c_str()); + UplinkSocket::Message(source ? source->nick : Config->ServerName) << "G " << dest->name << " " << buf; } void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) { - send_cmd(bi ? bi->nick : Config->ServerName, "v %s %s", u->nick.c_str(), buf.c_str()); + UplinkSocket::Message(bi ? bi->nick : Config->ServerName) << "v " << u->nick <<" " << buf; } void SendClientIntroduction(const User *u) { Anope::string modes = "+" + u->GetModes(); - send_cmd("", "& %s 1 %ld %s %s %s 0 %s %s * :%s", u->nick.c_str(), static_cast<long>(u->timestamp), u->GetIdent().c_str(), u->host.c_str(), u->server->GetName().c_str(), modes.c_str(), u->host.c_str(), u->realname.c_str()); + UplinkSocket::Message() << "& " << u->nick << " 1 " << u->timestamp << " " << u->GetIdent() << " " << u->host << " " << u->server->GetName() << " 0 " << modes << " " << u->host << " * :" << u->realname; } void SendKickInternal(const BotInfo *source, const Channel *chan, const User *user, const Anope::string &buf) { if (!buf.empty()) - send_cmd(source->nick, "H %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf.c_str()); + UplinkSocket::Message(source->nick) << "H " << chan->name << " " << user->nick << " :" << buf; else - send_cmd(source->nick, "H %s %s", chan->name.c_str(), user->nick.c_str()); + UplinkSocket::Message(source->nick) << "H " << chan->name << " " << user->nick; } /* SERVER name hop descript */ @@ -159,15 +114,15 @@ class UnrealIRCdProto : public IRCDProto void SendServer(const Server *server) { if (!Config->Numeric.empty()) - send_cmd("", "SERVER %s %d :U0-*-%s %s", server->GetName().c_str(), server->GetHops(), Config->Numeric.c_str(), server->GetDescription().c_str()); + UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :U0-*-" << Config->Numeric << " " << server->GetDescription(); else - 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(); } /* JOIN */ void SendJoin(User *user, Channel *c, const ChannelStatus *status) { - send_cmd(Config->ServerName, "~ %ld %s :%s", static_cast<long>(c->creation_time), c->name.c_str(), user->nick.c_str()); + UplinkSocket::Message(Config->ServerName) << "~ " << c->creation_time << " " << c->name << " :" << user->nick; if (status) { /* First save the channel status incase uc->Status == status */ @@ -190,7 +145,7 @@ class UnrealIRCdProto : public IRCDProto */ void SendSQLineDel(const XLine *x) { - send_cmd("", "d %s", x->Mask.c_str()); + UplinkSocket::Message() << "d " << x->Mask; } /* SQLINE */ @@ -200,7 +155,7 @@ class UnrealIRCdProto : public IRCDProto */ void SendSQLine(User *, const XLine *x) { - send_cmd("", "c %s :%s", x->Mask.c_str(), x->Reason.c_str()); + UplinkSocket::Message() << "c " << x->Mask << " :" << x->Reason; } /* @@ -211,13 +166,13 @@ class UnrealIRCdProto : public IRCDProto */ void SendSVSO(const Anope::string &source, const Anope::string &nick, const Anope::string &flag) { - send_cmd(source, "BB %s %s", nick.c_str(), flag.c_str()); + UplinkSocket::Message(source) << "BB " << nick << " " << flag; } /* NICK <newnick> */ void SendChangeBotNick(const BotInfo *oldnick, const Anope::string &newnick) { - send_cmd(oldnick->nick, "& %s %ld", newnick.c_str(), static_cast<long>(Anope::CurTime)); + UplinkSocket::Message(oldnick->nick) << "& " << newnick << " " << Anope::CurTime; } /* Functions that use serval cmd functions */ @@ -225,28 +180,44 @@ class UnrealIRCdProto : public IRCDProto void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) { if (!vIdent.empty()) - unreal_cmd_chgident(u->nick, vIdent); + UplinkSocket::Message(Config->ServerName) << "AZ " << u->nick << " " << vIdent; if (!vhost.empty()) - unreal_cmd_chghost(u->nick, vhost); + UplinkSocket::Message(Config->ServerName) << "AL " << u->nick << " " << vhost; } void SendConnect() { - unreal_cmd_capab(); - unreal_cmd_pass(Config->Uplinks[CurrentUplink]->password); + /* + NICKv2 = Nick Version 2 + VHP = Sends hidden host + UMODE2 = sends UMODE2 on user modes + NICKIP = Sends IP on NICK + TOKEN = Use tokens to talk + SJ3 = Supports SJOIN + NOQUIT = No Quit + TKLEXT = Extended TKL we don't use it but best to have it + SJB64 = Base64 encoded time stamps + VL = Version Info + NS = Config->Numeric Server + */ + if (!Config->Numeric.empty()) + UplinkSocket::Message() << "PROTOCTL NICKv2 VHP UMODE2 NICKIP TOKEN SJOIN SJOIN2 SJ3 NOQUIT TKLEXT VL"; + else + UplinkSocket::Message() << "PROTOCTL NICKv2 VHP UMODE2 NICKIP TOKEN SJOIN SJOIN2 SJ3 NOQUIT TKLEXT"; + UplinkSocket::Message() << "PASS :" << Config->Uplinks[CurrentUplink]->password; SendServer(Me); } /* SVSHOLD - set */ void SendSVSHold(const Anope::string &nick) { - send_cmd("", "BD + Q H %s %s %ld %ld :Being held for registered user", nick.c_str(), Config->ServerName.c_str(), static_cast<long>(Anope::CurTime + Config->NSReleaseTimeout), static_cast<long>(Anope::CurTime)); + UplinkSocket::Message() << "BD + Q H " << nick << " " << Config->ServerName << " " << Anope::CurTime + Config->NSReleaseTimeout << " " << Anope::CurTime << " :Being held for registered user"; } /* SVSHOLD - release */ void SendSVSHoldDel(const Anope::string &nick) { - send_cmd("", "BD - Q * %s %s", nick.c_str(), Config->ServerName.c_str()); + UplinkSocket::Message() << "BD - Q * " << nick << " " << Config->ServerName; } /* UNSGLINE */ @@ -255,13 +226,13 @@ class UnrealIRCdProto : public IRCDProto */ void SendSGLineDel(const XLine *x) { - send_cmd("", "BR - :%s", x->Mask.c_str()); + UplinkSocket::Message() << "BR - :" << x->Mask; } /* UNSZLINE */ void SendSZLineDel(const XLine *x) { - send_cmd("", "BD - Z * %s %s", x->GetHost().c_str(), Config->OperServ.c_str()); + UplinkSocket::Message() << "BD - Z * " << x->GetHost() << " " << Config->OperServ; } /* SZLINE */ @@ -271,7 +242,7 @@ class UnrealIRCdProto : public IRCDProto time_t timeleft = x->Expires - Anope::CurTime; if (timeleft > 172800 || !x->Expires) timeleft = 172800; - send_cmd("", "BD + Z * %s %s %ld %ld :%s", x->GetHost().c_str(), x->By.c_str(), static_cast<long>(Anope::CurTime + timeleft), static_cast<long>(x->Created), x->Reason.c_str()); + UplinkSocket::Message() << "BD + Z * " << x->GetHost() << " " << x->By << " " << Anope::CurTime + timeleft << " " << x->Created << " :" << x->Reason; } /* SGLINE */ @@ -282,7 +253,7 @@ class UnrealIRCdProto : public IRCDProto { Anope::string edited_reason = x->Reason; edited_reason = edited_reason.replace_all_cs(" ", "_"); - send_cmd("", "BR + %s :%s", edited_reason.c_str(), x->Mask.c_str()); + UplinkSocket::Message() << "BR + " << edited_reason << " :" << x->Mask; } /* svsjoin @@ -297,19 +268,19 @@ class UnrealIRCdProto : public IRCDProto void SendSVSJoin(const Anope::string &source, const Anope::string &nick, const Anope::string &chan, const Anope::string ¶m) { if (!param.empty()) - send_cmd(source, "BX %s %s :%s", nick.c_str(), chan.c_str(), param.c_str()); + UplinkSocket::Message(source) << "BX " << nick << " " << chan << " :" << param; else - send_cmd(source, "BX %s :%s", nick.c_str(), chan.c_str()); + UplinkSocket::Message(source) << "BX " << nick << " :" << chan; } void SendSWhois(const Anope::string &source, const Anope::string &who, const Anope::string &mask) { - send_cmd(source, "BA %s :%s", who.c_str(), mask.c_str()); + UplinkSocket::Message(source) << "BA " << who << " :" << mask; } void SendEOB() { - send_cmd(Config->ServerName, "ES"); + UplinkSocket::Message(Config->ServerName) << "ES"; } bool IsNickValid(const Anope::string &nick) @@ -938,7 +909,7 @@ bool event_pong(const Anope::string &source, const std::vector<Anope::string> &p */ bool event_netinfo(const Anope::string &source, const std::vector<Anope::string> ¶ms) { - send_cmd("", "AO %ld %ld %d %s 0 0 0 :%s", static_cast<long>(maxusercnt), static_cast<long>(Anope::CurTime), Anope::string(params[2]).is_number_only() ? convertTo<int>(params[2]) : 0, params[3].c_str(), params[7].c_str()); + UplinkSocket::Message() << "AO " << maxusercnt << " " << Anope::CurTime << " " << convertTo<int>(params[2]) << " " << params[3] << " 0 0 0 :" << params[7]; return true; } |