summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-02-19 20:54:55 -0500
committerAdam <Adam@anope.org>2012-02-19 20:54:55 -0500
commitb84e0804636d3868684c6ec2670207e7ae1cadeb (patch)
tree059be9a9da7b530970bc44f2c8eee5f61497a82e
parent0ba58d7d0eea4e2a0e0d18a66880f84af6fea60e (diff)
Made our message sources actual clients/servers, and put in a few more default messages for very standard things (KICK etc)
-rw-r--r--include/protocol.h22
-rw-r--r--include/uplink.h8
-rw-r--r--modules/commands/cs_invite.cpp2
-rw-r--r--modules/commands/ns_ajoin.cpp12
-rw-r--r--modules/commands/os_oline.cpp4
-rw-r--r--modules/protocol/bahamut.cpp46
-rw-r--r--modules/protocol/inspircd-ts6.h86
-rw-r--r--modules/protocol/inspircd11.cpp74
-rw-r--r--modules/protocol/inspircd12.cpp9
-rw-r--r--modules/protocol/inspircd20.cpp13
-rw-r--r--modules/protocol/plexus.cpp78
-rw-r--r--modules/protocol/ratbox.cpp66
-rw-r--r--modules/protocol/unreal.cpp41
-rw-r--r--src/main.cpp71
-rw-r--r--src/messages.cpp32
-rw-r--r--src/protocol.cpp78
16 files changed, 302 insertions, 340 deletions
diff --git a/include/protocol.h b/include/protocol.h
index f1bb9dbbe..40ddb75b3 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -48,11 +48,11 @@ struct IRCDVar
class CoreExport IRCDProto
{
- private:
- virtual void SendSVSKillInternal(const BotInfo *, const User *, const Anope::string &) = 0;
- virtual void SendModeInternal(const BotInfo *, const Channel *, const Anope::string &) = 0;
+ protected:
+ virtual void SendSVSKillInternal(const BotInfo *, const User *, const Anope::string &);
+ virtual void SendModeInternal(const BotInfo *, const Channel *, const Anope::string &);
virtual void SendModeInternal(const BotInfo *, const User *, const Anope::string &) = 0;
- virtual void SendKickInternal(const BotInfo *, const Channel *, const User *, const Anope::string &) = 0;
+ virtual void SendKickInternal(const BotInfo *, const Channel *, const User *, const Anope::string &);
virtual void SendMessageInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
virtual void SendNoticeInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &msg);
virtual void SendPrivmsgInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
@@ -60,12 +60,12 @@ class CoreExport IRCDProto
virtual void SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf);
virtual void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf);
virtual void SendCTCPInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
- virtual void SendNumericInternal(const Anope::string &source, int numeric, const Anope::string &dest, const Anope::string &buf);
+ virtual void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf);
public:
virtual ~IRCDProto() { }
virtual void SendSVSNOOP(const Server *, bool) { }
- virtual void SendTopic(BotInfo *, Channel *) = 0;
+ virtual void SendTopic(BotInfo *, Channel *);
virtual void SendVhostDel(User *) { }
virtual void SendAkill(User *, const XLine *) = 0;
virtual void SendAkillDel(const XLine *) = 0;
@@ -86,12 +86,12 @@ class CoreExport IRCDProto
virtual void SendPong(const Anope::string &servname, const Anope::string &who);
virtual void SendJoin(User *, Channel *, const ChannelStatus *) = 0;
virtual void SendSQLineDel(const XLine *x) { }
- virtual void SendInvite(const BotInfo *bi, const Anope::string &chan, const Anope::string &nick);
+ virtual void SendInvite(const BotInfo *bi, const Channel *c, const User *u);
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(Server *, const Anope::string &message);
- virtual void SendSVSO(const Anope::string &, const Anope::string &, const Anope::string &) { }
+ virtual void SendSVSO(const BotInfo *, 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);
virtual void SendVhost(User *, const Anope::string &, const Anope::string &) { }
@@ -103,14 +103,14 @@ class CoreExport IRCDProto
virtual void SendSZLine(User *u, const XLine *) { }
virtual void SendSGLine(User *, const XLine *) { }
virtual void SendCTCP(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
- virtual void SendSVSJoin(const Anope::string &, const Anope::string &, const Anope::string &, const Anope::string &) { }
- virtual void SendSWhois(const Anope::string &, const Anope::string &, const Anope::string &) { }
+ virtual void SendSVSJoin(const BotInfo *bi, const Anope::string &, const Anope::string &, const Anope::string &) { }
+ virtual void SendSWhois(const BotInfo *bi, const Anope::string &, const Anope::string &) { }
virtual void SendBOB() { }
virtual void SendEOB() { }
virtual void SendServer(const Server *) = 0;
virtual bool IsNickValid(const Anope::string &) { return true; }
virtual bool IsChannelValid(const Anope::string &);
- virtual void SendNumeric(const Anope::string &source, int numeric, const Anope::string &dest, const char *fmt, ...);
+ virtual void SendNumeric(int numeric, const Anope::string &dest, const char *fmt, ...);
virtual void SendLogin(User *u) = 0;
virtual void SendLogout(User *u) = 0;
diff --git a/include/uplink.h b/include/uplink.h
index 7f200d426..70b20a28b 100644
--- a/include/uplink.h
+++ b/include/uplink.h
@@ -25,11 +25,15 @@ class UplinkSocket : public ConnectionSocket, public BufferedSocket
class CoreExport Message
{
- Anope::string source;
+ private:
+ const Server *server;
+ const User *user;
std::stringstream buffer;
+
public:
Message();
- Message(const Anope::string &);
+ explicit Message(const Server *);
+ explicit Message(const User *);
~Message();
template<typename T> Message &operator<<(const T &val)
{
diff --git a/modules/commands/cs_invite.cpp b/modules/commands/cs_invite.cpp
index b38828c9d..be3132907 100644
--- a/modules/commands/cs_invite.cpp
+++ b/modules/commands/cs_invite.cpp
@@ -71,7 +71,7 @@ class CommandCSInvite : public Command
{
bool override = !ci->AccessFor(u).HasPriv("INVITE");
- ircdproto->SendInvite(ci->WhoSends(), chan, u2->nick);
+ ircdproto->SendInvite(ci->WhoSends(), c, u2);
if (u2 != u)
{
source.Reply(_("\002%s\002 has been invited to \002%s\002."), u2->nick.c_str(), c->name.c_str());
diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp
index 5a5dbe7f0..03b710356 100644
--- a/modules/commands/ns_ajoin.cpp
+++ b/modules/commands/ns_ajoin.cpp
@@ -194,8 +194,9 @@ class NSAJoin : public Module
void OnNickIdentify(User *u) anope_override
{
AJoinList *channels = u->Account()->GetExt<AJoinList *>("ns_ajoin_channels");
+ BotInfo *bi = findbot(Config->NickServ);
- if (channels == NULL)
+ if (channels == NULL || bi == NULL)
return;
for (unsigned i = 0; i < channels->size(); ++i)
@@ -255,15 +256,14 @@ class NSAJoin : public Module
}
}
- if (need_invite)
+ if (need_invite && c != NULL)
{
- BotInfo *bi = findbot(Config->NickServ);
- if (!bi || !ci->AccessFor(u).HasPriv("INVITE"))
+ if (!ci->AccessFor(u).HasPriv("INVITE"))
continue;
- ircdproto->SendInvite(bi, channels->at(i).first, u->nick);
+ ircdproto->SendInvite(bi, c, u);
}
- ircdproto->SendSVSJoin(Config->NickServ, u->nick, channels->at(i).first, key);
+ ircdproto->SendSVSJoin(bi, u->nick, channels->at(i).first, key);
}
}
};
diff --git a/modules/commands/os_oline.cpp b/modules/commands/os_oline.cpp
index 5992f296e..3076da434 100644
--- a/modules/commands/os_oline.cpp
+++ b/modules/commands/os_oline.cpp
@@ -34,7 +34,7 @@ class CommandOSOLine : public Command
source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
else if (u2 && flag[0] == '+')
{
- ircdproto->SendSVSO(Config->OperServ, nick, flag);
+ ircdproto->SendSVSO(source.owner, nick, flag);
u2->SetMode(source.owner, UMODE_OPER);
u2->SendMessage(source.owner, _("You are now an IRC Operator."));
source.Reply(_("Operflags \002%s\002 have been added for \002%s\002."), flag.c_str(), nick.c_str());
@@ -42,7 +42,7 @@ class CommandOSOLine : public Command
}
else if (u2 && flag[0] == '-')
{
- ircdproto->SendSVSO(Config->OperServ, nick, flag);
+ ircdproto->SendSVSO(source.owner, nick, flag);
source.Reply(_("Operflags \002%s\002 have been added for \002%s\002."), flag.c_str(), nick.c_str());
Log(LOG_ADMIN, u, this) << "for " << nick;
}
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index 8645c7176..078e19a7d 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -13,8 +13,8 @@
#include "module.h"
-IRCDVar myIrcd[] = {
- {"Bahamut 1.8.x", /* ircd name */
+IRCDVar myIrcd = {
+ "Bahamut 1.8.x", /* ircd name */
"+", /* Modes used by pseudoclients */
1, /* SVSNICK */
0, /* Vhost */
@@ -35,10 +35,7 @@ IRCDVar myIrcd[] = {
0, /* ts6 */
"$", /* TLD Prefix for Global */
6, /* Max number of modes we can send per line */
- 0, /* IRCd sends a SSL users certificate fingerprint */
- }
- ,
- {NULL}
+ 0 /* IRCd sends a SSL users certificate fingerprint */
};
@@ -47,26 +44,34 @@ class BahamutIRCdProto : public IRCDProto
void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) anope_override
{
if (Capab.count("TSMODE") > 0)
- UplinkSocket::Message(source ? source->nick : Config->ServerName) << "MODE " << dest->name << " " << dest->creation_time << " " << buf;
+ {
+ if (source)
+ UplinkSocket::Message(source) << "MODE " << dest->name << " " << dest->creation_time << " " << buf;
+ else
+ UplinkSocket::Message(Me) << "MODE " << dest->name << " " << dest->creation_time << " " << buf;
+ }
else
- UplinkSocket::Message(source ? source->nick : Config->ServerName) << "MODE " << dest->name << " " << buf;
+ IRCDProto::SendModeInternal(source, dest, buf);
}
void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override
{
- UplinkSocket::Message(bi ? bi->nick : Config->ServerName) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf;
+ if (bi)
+ UplinkSocket::Message(bi) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf;
+ else
+ UplinkSocket::Message(Me) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf;
}
/* SVSHOLD - set */
void SendSVSHold(const Anope::string &nick) anope_override
{
- UplinkSocket::Message(Config->ServerName) << "SVSHOLD " << nick << " " << Config->NSReleaseTimeout << " :Being held for registered user";
+ UplinkSocket::Message(Me) << "SVSHOLD " << nick << " " << Config->NSReleaseTimeout << " :Being held for registered user";
}
/* SVSHOLD - release */
void SendSVSHoldDel(const Anope::string &nick) anope_override
{
- UplinkSocket::Message(Config->ServerName) << "SVSHOLD " << nick << " 0";
+ UplinkSocket::Message(Me) << "SVSHOLD " << nick << " 0";
}
/* SQLINE */
@@ -124,7 +129,7 @@ class BahamutIRCdProto : public IRCDProto
/* TOPIC */
void SendTopic(BotInfo *whosets, Channel *c) anope_override
{
- UplinkSocket::Message(whosets->nick) << "TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_time << " :" << c->topic;
+ UplinkSocket::Message(whosets) << "TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_time << " :" << c->topic;
}
/* UNSQLINE */
@@ -136,7 +141,7 @@ class BahamutIRCdProto : public IRCDProto
/* JOIN - SJOIN */
void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
{
- UplinkSocket::Message(user->nick) << "SJOIN " << c->creation_time << " " << c->name;
+ UplinkSocket::Message(user) << "SJOIN " << c->creation_time << " " << c->name;
if (status)
{
/* First save the channel status incase uc->Status == status */
@@ -169,7 +174,10 @@ class BahamutIRCdProto : public IRCDProto
*/
void SendSVSKillInternal(const BotInfo *source, const User *user, const Anope::string &buf) anope_override
{
- UplinkSocket::Message(source ? source->nick : "") << "SVSKILL " << user->nick << " :" << buf;
+ if (source)
+ UplinkSocket::Message(source) << "SVSKILL " << user->nick << " :" << buf;
+ else
+ UplinkSocket::Message() << "SVSKILL " << user->nick << " :" << buf;
}
void SendBOB() anope_override
@@ -182,14 +190,6 @@ class BahamutIRCdProto : public IRCDProto
UplinkSocket::Message() << "BURST 0";
}
- void SendKickInternal(const BotInfo *source, const Channel *chan, const User *user, const Anope::string &buf) anope_override
- {
- if (!buf.empty())
- UplinkSocket::Message(source->nick) << "KICK " << chan->name << " " << user->nick << " :" << buf;
- else
- UplinkSocket::Message(source->nick) << "KICK " << chan->name << " " << user->nick;
- }
-
void SendClientIntroduction(const User *u) anope_override
{
Anope::string modes = "+" + u->GetModes();
@@ -544,7 +544,7 @@ class ProtoBahamut : public Module
{
this->SetAuthor("Anope");
- pmodule_ircd_var(myIrcd);
+ pmodule_ircd_var(&myIrcd);
pmodule_ircd_proto(&this->ircd_proto);
pmodule_ircd_message(&this->ircd_message);
diff --git a/modules/protocol/inspircd-ts6.h b/modules/protocol/inspircd-ts6.h
index 8ba879c4c..99b86d3ce 100644
--- a/modules/protocol/inspircd-ts6.h
+++ b/modules/protocol/inspircd-ts6.h
@@ -36,7 +36,7 @@ class InspIRCdTS6Proto : public IRCDProto
if (!has_chgidentmod)
Log() << "CHGIDENT not loaded!";
else
- UplinkSocket::Message(Config->HostServ) << "CHGIDENT " << nick << " " << vIdent;
+ UplinkSocket::Message(findbot(Config->HostServ)) << "CHGIDENT " << nick << " " << vIdent;
}
void SendChgHostInternal(const Anope::string &nick, const Anope::string &vhost)
@@ -44,20 +44,19 @@ class InspIRCdTS6Proto : public IRCDProto
if (!has_chghostmod)
Log() << "CHGHOST not loaded!";
else
- UplinkSocket::Message(Config->Numeric) << "CHGHOST " << nick << " " << vhost;
+ UplinkSocket::Message(Me) << "CHGHOST " << nick << " " << vhost;
}
public:
void SendAkillDel(const XLine *x) anope_override
{
- BotInfo *bi = findbot(Config->OperServ);
- UplinkSocket::Message(bi ? bi->GetUID() : Config->Numeric) << "GLINE " << x->Mask;
+ UplinkSocket::Message(findbot(Config->OperServ)) << "GLINE " << x->Mask;
}
void SendTopic(BotInfo *whosets, Channel *c) anope_override
{
- UplinkSocket::Message(whosets->GetUID()) << "FTOPIC " << c->name << " " << Anope::CurTime << " " << c->topic_setter << " :" << c->topic;
+ UplinkSocket::Message(whosets) << "FTOPIC " << c->name << " " << Anope::CurTime << " " << c->topic_setter << " :" << c->topic;
}
void SendVhostDel(User *u) anope_override
@@ -77,54 +76,41 @@ class InspIRCdTS6Proto : public IRCDProto
time_t timeleft = x->Expires - Anope::CurTime;
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
- User *u = finduser(Config->OperServ);
- 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) anope_override
- {
- UplinkSocket::Message(source ? source->GetUID() : Config->Numeric) << "KILL " << user->GetUID() << " :" << buf;
+ BotInfo *bi = findbot(Config->OperServ);
+ UplinkSocket::Message(bi) << "ADDLINE G " << x->GetUser() << "@" << x->GetHost() << " " << x->By << " " << Anope::CurTime << " " << timeleft << " :" << x->Reason;
}
- void SendNumericInternal(const Anope::string &source, int numeric, const Anope::string &dest, const Anope::string &buf) anope_override
+ void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) anope_override
{
- UplinkSocket::Message(Config->Numeric) << "PUSH " << dest << " ::" << source << " " << numeric << " " << dest << " " << buf;
+ UplinkSocket::Message() << "PUSH " << dest << " ::" << Me->GetName() << " " << numeric << " " << dest << " " << buf;
}
void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) anope_override
{
- UplinkSocket::Message(source ? source->GetUID() : Config->Numeric) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf;
+ UplinkSocket::Message(source) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf;
}
void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override
{
- UplinkSocket::Message(bi ? bi->GetUID() : Config->Numeric) << "MODE " << u->GetUID() << " " << buf;
+ UplinkSocket::Message(bi) << "MODE " << u->GetUID() << " " << buf;
}
void SendClientIntroduction(const User *u) anope_override
{
Anope::string modes = "+" + u->GetModes();
- 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) anope_override
- {
- if (!buf.empty())
- UplinkSocket::Message(source->GetUID()) << "KICK " << chan->name << " " << user->GetUID() << " :" << buf;
- else
- UplinkSocket::Message(source->GetUID()) << "KICK " << chan->name << " " << user->GetUID() << " :" << user->nick;
+ UplinkSocket::Message(Me) << "UID " << u->GetUID() << " " << u->timestamp << " " << u->nick << " " << u->host << " " << u->host << " " << u->GetIdent() << " 0.0.0.0 " << u->my_signon << " " << modes << " :" << u->realname;
}
/* SERVER services-dev.chatspike.net password 0 :Description here */
void SendServer(const Server *server) anope_override
{
- UplinkSocket::Message("") << "SERVER " << server->GetName() << " " << Config->Uplinks[CurrentUplink]->password << " " << server->GetHops() << " " << server->GetSID() << " :" << server->GetDescription();
+ 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) anope_override
{
- UplinkSocket::Message(Config->Numeric) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :," << user->GetUID();
+ UplinkSocket::Message(Me) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :," << user->GetUID();
/* Note that we can send this with the FJOIN but choose not to
* because the mode stacker will handle this and probably will
* merge these modes with +nrt and other mlocked modes
@@ -150,7 +136,7 @@ class InspIRCdTS6Proto : public IRCDProto
/* UNSQLINE */
void SendSQLineDel(const XLine *x) anope_override
{
- UplinkSocket::Message(Config->Numeric) << "DELLINE Q " << x->Mask;
+ UplinkSocket::Message(Me) << "DELLINE Q " << x->Mask;
}
/* SQLINE */
@@ -160,7 +146,7 @@ class InspIRCdTS6Proto : public IRCDProto
time_t timeleft = x->Expires - Anope::CurTime;
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
- UplinkSocket::Message(Config->Numeric) << "ADDLINE Q " << x->Mask << " " << Config->OperServ << " " << Anope::CurTime << " " << timeleft << " :" << x->Reason;
+ UplinkSocket::Message(Me) << "ADDLINE Q " << x->Mask << " " << Config->OperServ << " " << Anope::CurTime << " " << timeleft << " :" << x->Reason;
}
/* Functions that use serval cmd functions */
@@ -176,9 +162,9 @@ class InspIRCdTS6Proto : public IRCDProto
void SendConnect() anope_override
{
SendServer(Me);
- UplinkSocket::Message(Config->Numeric) << "BURST";
+ UplinkSocket::Message(Me) << "BURST";
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
- UplinkSocket::Message(Config->Numeric) << "VERSION :Anope-" << Anope::Version() << " " << Config->ServerName << " :" << ircd->name << " - (" << (enc ? enc->name : "unknown") << ") -- " << Anope::VersionBuildString();
+ UplinkSocket::Message(Me) << "VERSION :Anope-" << Anope::Version() << " " << Config->ServerName << " :" << ircd->name << " - (" << (enc ? enc->name : "unknown") << ") -- " << Anope::VersionBuildString();
}
/* SVSHOLD - set */
@@ -186,7 +172,7 @@ class InspIRCdTS6Proto : public IRCDProto
{
BotInfo *bi = findbot(Config->NickServ);
if (bi)
- UplinkSocket::Message(bi->GetUID()) << "SVSHOLD " << nick << " " << Config->NSReleaseTimeout << " :Being held for registered user";
+ UplinkSocket::Message(bi) << "SVSHOLD " << nick << " " << Config->NSReleaseTimeout << " :Being held for registered user";
}
/* SVSHOLD - release */
@@ -194,13 +180,13 @@ class InspIRCdTS6Proto : public IRCDProto
{
BotInfo *bi = findbot(Config->NickServ);
if (bi)
- UplinkSocket::Message(bi->GetUID()) << "SVSHOLD " << nick;
+ UplinkSocket::Message(bi) << "SVSHOLD " << nick;
}
/* UNSZLINE */
void SendSZLineDel(const XLine *x) anope_override
{
- UplinkSocket::Message(Config->Numeric) << "DELLINE Z " << x->GetHost();
+ UplinkSocket::Message(Me) << "DELLINE Z " << x->GetHost();
}
/* SZLINE */
@@ -210,39 +196,38 @@ class InspIRCdTS6Proto : public IRCDProto
time_t timeleft = x->Expires - Anope::CurTime;
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
- UplinkSocket::Message(Config->Numeric) << "ADDLINE Z " << x->GetHost() << " " << x->By << " " << Anope::CurTime << " " << timeleft <<" :" << x->Reason;
+ UplinkSocket::Message(Me) << "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 &) anope_override
+ void SendSVSJoin(const BotInfo *source, const Anope::string &nick, const Anope::string &chan, const Anope::string &) anope_override
{
User *u = finduser(nick);
- BotInfo *bi = findbot(source);
- UplinkSocket::Message(bi->GetUID()) << "SVSJOIN " << u->GetUID() << " " << chan;
+ UplinkSocket::Message(source) << "SVSJOIN " << u->GetUID() << " " << chan;
}
- void SendSWhois(const Anope::string &, const Anope::string &who, const Anope::string &mask) anope_override
+ void SendSWhois(const BotInfo *, const Anope::string &who, const Anope::string &mask) anope_override
{
User *u = finduser(who);
- UplinkSocket::Message(Config->Numeric) << "METADATA " << u->GetUID() << " swhois :" << mask;
+ UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " swhois :" << mask;
}
void SendBOB() anope_override
{
- UplinkSocket::Message(Config->Numeric) << "BURST " << Anope::CurTime;
+ UplinkSocket::Message(Me) << "BURST " << Anope::CurTime;
}
void SendEOB() anope_override
{
- UplinkSocket::Message(Config->Numeric) << "ENDBURST";
+ UplinkSocket::Message(Me) << "ENDBURST";
}
void SendGlobopsInternal(BotInfo *source, const Anope::string &buf)
{
if (has_globopsmod)
- UplinkSocket::Message(source ? source->GetUID() : Config->Numeric) << "SNONOTICE g :" << buf;
+ UplinkSocket::Message(source) << "SNONOTICE g :" << buf;
else
- UplinkSocket::Message(source ? source->GetUID() : Config->Numeric) << "SNONOTICE A :" << buf;
+ UplinkSocket::Message(source) << "SNONOTICE A :" << buf;
}
void SendLogin(User *u) anope_override
@@ -250,17 +235,17 @@ class InspIRCdTS6Proto : public IRCDProto
if (!u->Account() || u->Account()->HasFlag(NI_UNCONFIRMED))
return;
- UplinkSocket::Message(Config->Numeric) << "METADATA " << u->GetUID() << " accountname :" << u->Account()->display;
+ UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :" << u->Account()->display;
}
void SendLogout(User *u) anope_override
{
- UplinkSocket::Message(Config->Numeric) << "METADATA " << u->GetUID() << " accountname :";
+ UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :";
}
void SendChannel(Channel *c) anope_override
{
- UplinkSocket::Message(Config->Numeric) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :";
+ UplinkSocket::Message(Me) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :";
}
bool IsNickValid(const Anope::string &nick) anope_override
@@ -455,7 +440,8 @@ 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);
+ if (bi)
+ UplinkSocket::Message(bi) << "IDLE " << source << " " << start_time << " " << (Anope::CurTime - bi->lastmsg);
return true;
}
@@ -464,7 +450,7 @@ bool event_time(const Anope::string &source, const std::vector<Anope::string> &p
if (params.size() < 2)
return true;
- UplinkSocket::Message(Config->Numeric) << "TIME " << source << " " << params[1] << " " << Anope::CurTime;
+ UplinkSocket::Message(Me) << "TIME " << source << " " << params[1] << " " << Anope::CurTime;
return true;
}
@@ -473,7 +459,7 @@ bool event_rsquit(const Anope::string &source, const std::vector<Anope::string>
/* 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() : "");
+ UplinkSocket::Message(Me) << "SQUIT " << s->GetSID() << " :" << (params.size() > 1 ? params[1].c_str() : "");
ircdmessage->OnSQuit(source, params);
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index 49a90f831..d25fd5a86 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -13,8 +13,8 @@
#include "module.h"
-IRCDVar myIrcd[] = {
- {"InspIRCd 1.1", /* ircd name */
+IRCDVar myIrcd = {
+ "InspIRCd 1.1", /* ircd name */
"+I", /* Modes used by pseudoclients */
1, /* SVSNICK */
1, /* Vhost */
@@ -35,10 +35,7 @@ IRCDVar myIrcd[] = {
0, /* ts6 */
"$", /* TLD Prefix for Global */
20, /* Max number of modes we can send per line */
- 0, /* IRCd sends a SSL users certificate fingerprint */
- }
- ,
- {NULL}
+ 0 /* IRCd sends a SSL users certificate fingerprint */
};
static bool has_servicesmod = false;
@@ -51,15 +48,15 @@ static bool has_hidechansmod = false;
/* CHGHOST */
void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost)
{
+ BotInfo *bi = findbot(Config->OperServ);
if (has_chghostmod)
{
if (nick.empty() || vhost.empty())
return;
- UplinkSocket::Message(Config->OperServ) << "CHGHOST " << nick << " " << vhost;
+ UplinkSocket::Message(bi) << "CHGHOST " << nick << " " << vhost;
}
else
{
- BotInfo *bi = findbot(Config->OperServ);
if (bi)
ircdproto->SendGlobops(bi, "CHGHOST not loaded!");
}
@@ -67,8 +64,8 @@ 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())
- UplinkSocket::Message(params[0]) << "IDLE " << source << " " << Anope::CurTime << " 0";
+ BotInfo *bi = findbot(params[0]);
+ UplinkSocket::Message(bi) << "IDLE " << source << " " << start_time << " " << (bi ? Anope::CurTime - bi->lastmsg : 0);
return true;
}
@@ -84,12 +81,12 @@ class InspIRCdProto : public IRCDProto
{
void SendAkillDel(const XLine *x) anope_override
{
- UplinkSocket::Message(Config->OperServ) << "GLINE " << x->Mask;
+ UplinkSocket::Message(findbot(Config->OperServ)) << "GLINE " << x->Mask;
}
void SendTopic(BotInfo *whosets, Channel *c) anope_override
{
- UplinkSocket::Message(whosets->nick) << "FTOPIC " << c->name << " " << c->topic_time << " " << c->topic_setter <<" :" << c->topic;
+ UplinkSocket::Message(whosets) << "FTOPIC " << c->name << " " << c->topic_time << " " << c->topic_setter <<" :" << c->topic;
}
void SendVhostDel(User *u) anope_override
@@ -109,54 +106,63 @@ class InspIRCdProto : public IRCDProto
time_t timeleft = x->Expires - Anope::CurTime;
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
- UplinkSocket::Message(Config->ServerName) << "ADDLINE G " << x->Mask << " " << x->By << " " << Anope::CurTime << " " << timeleft << " :" << x->Reason;
+ UplinkSocket::Message(Me) << "ADDLINE G " << x->Mask << " " << x->By << " " << Anope::CurTime << " " << timeleft << " :" << x->Reason;
}
void SendSVSKillInternal(const BotInfo *source, const User *user, const Anope::string &buf) anope_override
{
- UplinkSocket::Message(source ? source->nick : Config->ServerName) << "KILL " << user->nick << " :" << buf;
+ if (source)
+ UplinkSocket::Message(source) << "KILL " << user->nick << " :" << buf;
+ else
+ UplinkSocket::Message(Me) << "KILL " << user->nick << " :" << buf;
}
- void SendNumericInternal(const Anope::string &source, int numeric, const Anope::string &dest, const Anope::string &buf) anope_override
+ void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) anope_override
{
- UplinkSocket::Message(source) << "PUSH " << dest << " ::" << source << " " << numeric << " " << dest << " " << buf;
+ UplinkSocket::Message() << "PUSH " << dest << " ::" << Me->GetName() << " " << numeric << " " << dest << " " << buf;
}
void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) anope_override
{
- UplinkSocket::Message(source ? source->nick : Config->ServerName) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf;
+ if (source)
+ UplinkSocket::Message(source) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf;
+ else
+ UplinkSocket::Message(Me) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf;
}
void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override
{
- UplinkSocket::Message(bi ? bi->nick : Config->ServerName) << "MODE " << u->nick << " " << buf;
+ if (bi)
+ UplinkSocket::Message(bi) << "MODE " << u->nick << " " << buf;
+ else
+ UplinkSocket::Message(Me) << "MODE " << u->nick << " " << buf;
}
void SendClientIntroduction(const User *u) anope_override
{
Anope::string modes = "+" + u->GetModes();
- 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";
+ UplinkSocket::Message(Me) << "NICK " << u->timestamp << " " << u->nick << " " << u->host << " " << u->host << " " << u->GetIdent() << " " << modes << " 0.0.0.0 :" << u->realname;
+ UplinkSocket::Message(u) << "OPERTYPE Service";
}
void SendKickInternal(const BotInfo *source, const Channel *chan, const User *user, const Anope::string &buf) anope_override
{
if (!buf.empty())
- UplinkSocket::Message(source->nick) << "KICK " << chan->name << " " << user->nick << " :" << buf;
+ UplinkSocket::Message(source) << "KICK " << chan->name << " " << user->nick << " :" << buf;
else
- UplinkSocket::Message(source->nick) << "KICK " << chan->name << " " << user->nick << " :" << user->nick;
+ UplinkSocket::Message(source) << "KICK " << chan->name << " " << user->nick << " :" << user->nick;
}
/* SERVER services-dev.chatspike.net password 0 :Description here */
void SendServer(const Server *server) anope_override
{
- UplinkSocket::Message(Config->ServerName) << "SERVER " << server->GetName() << " " << currentpass << " " << server->GetHops() << " :" << server->GetDescription();
+ UplinkSocket::Message(Me) << "SERVER " << server->GetName() << " " << currentpass << " " << server->GetHops() << " :" << server->GetDescription();
}
/* JOIN */
void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
{
- UplinkSocket::Message(user->nick) << "JOIN " << c->name << " " << c->creation_time;
+ UplinkSocket::Message(user) << "JOIN " << c->name << " " << c->creation_time;
if (status)
{
/* First save the channel status incase uc->Status == status */
@@ -178,7 +184,7 @@ class InspIRCdProto : public IRCDProto
/* UNSQLINE */
void SendSQLineDel(const XLine *x) anope_override
{
- UplinkSocket::Message(Config->OperServ) << "QLINE " << x->Mask;
+ UplinkSocket::Message(findbot(Config->OperServ)) << "QLINE " << x->Mask;
}
/* SQLINE */
@@ -188,7 +194,7 @@ class InspIRCdProto : public IRCDProto
time_t timeleft = x->Expires - Anope::CurTime;
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
- UplinkSocket::Message(Config->ServerName) << "ADDLINE Q " << x->Mask << " " << x->By << " " << Anope::CurTime << " " << timeleft << " :" << x->Reason;
+ UplinkSocket::Message(Me) << "ADDLINE Q " << x->Mask << " " << x->By << " " << Anope::CurTime << " " << timeleft << " :" << x->Reason;
}
/* Functions that use serval cmd functions */
@@ -207,7 +213,7 @@ class InspIRCdProto : public IRCDProto
SendServer(Me);
UplinkSocket::Message() << "BURST";
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
- UplinkSocket::Message(Config->ServerName) << "VERSION :Anope-" << Anope::Version() << " " << Me->GetName() << " :" << ircd->name << " - (" << (enc ? enc->name : "unknown") << ") -- " << Anope::VersionBuildString();
+ UplinkSocket::Message(Me) << "VERSION :Anope-" << Anope::Version() << " " << Me->GetName() << " :" << ircd->name << " - (" << (enc ? enc->name : "unknown") << ") -- " << Anope::VersionBuildString();
}
/* CHGIDENT */
@@ -217,7 +223,7 @@ class InspIRCdProto : public IRCDProto
{
if (nick.empty() || vIdent.empty())
return;
- UplinkSocket::Message(Config->OperServ) << "CHGIDENT " << nick << " " << vIdent;
+ UplinkSocket::Message(findbot(Config->OperServ)) << "CHGIDENT " << nick << " " << vIdent;
}
else
Log() << "CHGIDENT not loaded!";
@@ -226,19 +232,19 @@ class InspIRCdProto : public IRCDProto
/* SVSHOLD - set */
void SendSVSHold(const Anope::string &nick) anope_override
{
- UplinkSocket::Message(Config->OperServ) << "SVSHOLD " << nick << " " << Config->NSReleaseTimeout << "s :Being held for registered user";
+ UplinkSocket::Message(findbot(Config->OperServ)) << "SVSHOLD " << nick << " " << Config->NSReleaseTimeout << "s :Being held for registered user";
}
/* SVSHOLD - release */
void SendSVSHoldDel(const Anope::string &nick) anope_override
{
- UplinkSocket::Message(Config->OperServ) << "SVSHOLD " << nick;
+ UplinkSocket::Message(findbot(Config->OperServ)) << "SVSHOLD " << nick;
}
/* UNSZLINE */
void SendSZLineDel(const XLine *x) anope_override
{
- UplinkSocket::Message(Config->OperServ) << "ZLINE " << x->GetHost();
+ UplinkSocket::Message(findbot(Config->OperServ)) << "ZLINE " << x->GetHost();
}
/* SZLINE */
@@ -248,10 +254,10 @@ class InspIRCdProto : public IRCDProto
time_t timeleft = x->Expires - Anope::CurTime;
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
- UplinkSocket::Message(Config->ServerName) << "ADDLINE Z " << x->GetHost() << " " << x->By << " " << Anope::CurTime << " " << timeleft << " :" << x->Reason;
+ UplinkSocket::Message(Me) << "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 &) anope_override
+ void SendSVSJoin(const BotInfo *source, const Anope::string &nick, const Anope::string &chan, const Anope::string &) anope_override
{
UplinkSocket::Message(source) << "SVSJOIN " << nick << " " << chan;
}
@@ -914,7 +920,7 @@ class ProtoInspIRCd : public Module
{
this->SetAuthor("Anope");
- pmodule_ircd_var(myIrcd);
+ pmodule_ircd_var(&myIrcd);
pmodule_ircd_proto(&this->ircd_proto);
pmodule_ircd_message(&this->ircd_message);
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index e2ec39ebe..68014c52b 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -19,8 +19,8 @@ static bool has_chghostmod = false;
static bool has_chgidentmod = false;
#include "inspircd-ts6.h"
-IRCDVar myIrcd[] = {
- {"InspIRCd 1.2", /* ircd name */
+IRCDVar myIrcd = {
+ "InspIRCd 1.2", /* ircd name */
"+I", /* Modes used by pseudoclients */
1, /* SVSNICK */
1, /* Vhost */
@@ -42,9 +42,6 @@ IRCDVar myIrcd[] = {
"$", /* TLD Prefix for Global */
20, /* Max number of modes we can send per line */
1, /* IRCd sends a SSL users certificate fingerprint */
- }
- ,
- {NULL}
};
static bool has_servicesmod = false;
@@ -705,7 +702,7 @@ class ProtoInspIRCd : public Module
{
this->SetAuthor("Anope");
- pmodule_ircd_var(myIrcd);
+ pmodule_ircd_var(&myIrcd);
pmodule_ircd_proto(&this->ircd_proto);
pmodule_ircd_message(&this->ircd_message);
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index 619afdbde..c5034e47e 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -19,8 +19,8 @@ static bool has_chgidentmod = false;
static bool has_globopsmod = true; // Not a typo
#include "inspircd-ts6.h"
-IRCDVar myIrcd[] = {
- {"InspIRCd 2.0", /* ircd name */
+IRCDVar myIrcd = {
+ "InspIRCd 2.0", /* ircd name */
"+I", /* Modes used by pseudoclients */
1, /* SVSNICK */
1, /* Vhost */
@@ -42,9 +42,6 @@ IRCDVar myIrcd[] = {
"$", /* TLD Prefix for Global */
20, /* Max number of modes we can send per line */
1, /* IRCd sends a SSL users certificate fingerprint */
- }
- ,
- {NULL}
};
static bool has_servicesmod = false;
@@ -58,9 +55,9 @@ class InspIRCdProto : public InspIRCdTS6Proto
UplinkSocket::Message() << "CAPAB CAPABILITIES :PROTOCOL=1202";
UplinkSocket::Message() << "CAPAB END";
SendServer(Me);
- UplinkSocket::Message(Config->Numeric) << "BURST";
+ UplinkSocket::Message(Me) << "BURST";
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
- UplinkSocket::Message(Config->Numeric) << "VERSION :Anope-" << Anope::Version() << " " << Me->GetName() << " :" << ircd->name <<" - (" << (enc ? enc->name : "unknown") << ") -- " << Anope::VersionBuildString();
+ UplinkSocket::Message(Me) << "VERSION :Anope-" << Anope::Version() << " " << Me->GetName() << " :" << ircd->name <<" - (" << (enc ? enc->name : "unknown") << ") -- " << Anope::VersionBuildString();
}
};
@@ -718,7 +715,7 @@ class ProtoInspIRCd : public Module
{
this->SetAuthor("Anope");
- pmodule_ircd_var(myIrcd);
+ pmodule_ircd_var(&myIrcd);
pmodule_ircd_proto(&this->ircd_proto);
pmodule_ircd_message(&this->ircd_message);
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index 0755ac327..3d28f9b7e 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -13,8 +13,8 @@
static Anope::string TS6UPLINK;
-IRCDVar myIrcd[] = {
- {"hybrid-7.2.3+plexus-3.0.1", /* ircd name */
+IRCDVar myIrcd = {
+ "hybrid-7.2.3+plexus-3.0.1", /* ircd name */
"+oi", /* Modes used by pseudoclients */
1, /* SVSNICK */
1, /* Vhost */
@@ -36,49 +36,46 @@ IRCDVar myIrcd[] = {
"$$", /* TLD Prefix for Global */
4, /* Max number of modes we can send per line */
1, /* IRCd sends a SSL users certificate fingerprint */
- }
- ,
- {NULL}
};
class PlexusProto : public IRCDProto
{
void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) anope_override
{
- UplinkSocket::Message(source ? source->GetUID() : Me->GetSID()) << "OPERWALL :" << buf;
+ UplinkSocket::Message(source) << "OPERWALL :" << buf;
}
void SendSQLine(User *, const XLine *x) anope_override
{
- UplinkSocket::Message(Me->GetSID()) << "RESV * " << x->Mask << " :" << x->Reason;
+ UplinkSocket::Message(Me) << "RESV * " << x->Mask << " :" << x->Reason;
}
void SendSGLineDel(const XLine *x) anope_override
{
BotInfo *bi = findbot(Config->OperServ);
- UplinkSocket::Message(bi ? bi->GetUID() : Config->OperServ) << "UNXLINE * " << x->Mask;
+ UplinkSocket::Message(bi) << "UNXLINE * " << x->Mask;
}
void SendSGLine(User *, const XLine *x) anope_override
{
BotInfo *bi = findbot(Config->OperServ);
- UplinkSocket::Message(bi ? bi->GetUID() : Config->OperServ) << "XLINE * " << x->Mask << " 0 :" << x->Reason;
+ UplinkSocket::Message(bi) << "XLINE * " << x->Mask << " 0 :" << x->Reason;
}
void SendAkillDel(const XLine *x) anope_override
{
BotInfo *bi = findbot(Config->OperServ);
- UplinkSocket::Message(bi ? bi->GetUID() : Config->OperServ) << "UNKLINE * " << x->GetUser() << " " << x->GetHost();
+ UplinkSocket::Message(bi) << "UNKLINE * " << x->GetUser() << " " << x->GetHost();
}
void SendSQLineDel(const XLine *x) anope_override
{
- UplinkSocket::Message(Me->GetSID()) << "UNRESV * " << x->Mask;
+ UplinkSocket::Message(Me) << "UNRESV * " << x->Mask;
}
void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
{
- UplinkSocket::Message(Me->GetSID()) << "SJOIN " << c->creation_time << " " << c->name << " +" << c->GetModes(true, true) << " :" << user->GetUID();
+ UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " +" << c->GetModes(true, true) << " :" << user->GetUID();
if (status)
{
/* First save the channel status incase uc->Status == status */
@@ -104,12 +101,7 @@ class PlexusProto : public IRCDProto
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
BotInfo *bi = findbot(Config->OperServ);
- 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) anope_override
- {
- UplinkSocket::Message(source ? source->GetUID() : Me->GetSID()) << "KILL " << user->GetUID() << " :" << buf;
+ UplinkSocket::Message(bi) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->Reason;
}
void SendServer(const Server *server) anope_override
@@ -117,12 +109,12 @@ class PlexusProto : public IRCDProto
if (server == Me)
UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription();
else
- UplinkSocket::Message(Me->GetSID()) << "SID " << server->GetName() << " " << server->GetHops() << " " << server->GetSID() << " :" << server->GetDescription();
+ UplinkSocket::Message(Me) << "SID " << server->GetName() << " " << server->GetHops() << " " << server->GetSID() << " :" << server->GetDescription();
}
void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when) anope_override
{
- UplinkSocket::Message(Me->GetSID()) << "ENCAP " << u->server->GetName() << " SVSNICK " << u->GetUID() << " " << u->timestamp << " " << newnick << " " << when;
+ UplinkSocket::Message(Me) << "ENCAP " << u->server->GetName() << " SVSNICK " << u->GetUID() << " " << u->timestamp << " " << newnick << " " << when;
}
void SendVhostDel(User *u) anope_override
@@ -137,8 +129,8 @@ class PlexusProto : public IRCDProto
void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) anope_override
{
if (!ident.empty())
- UplinkSocket::Message(Me->GetSID()) << "ENCAP * CHGIDENT " << u->GetUID() << " " << ident;
- UplinkSocket::Message(Me->GetSID()) << "ENCAP * CHGHOST " << u->GetUID() << " " << host;
+ UplinkSocket::Message(Me) << "ENCAP * CHGIDENT " << u->GetUID() << " " << ident;
+ UplinkSocket::Message(Me) << "ENCAP * CHGHOST " << u->GetUID() << " " << host;
}
void SendConnect() anope_override
@@ -181,40 +173,12 @@ class PlexusProto : public IRCDProto
void SendClientIntroduction(const User *u) anope_override
{
Anope::string modes = "+" + u->GetModes();
- 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) anope_override
- {
- if (!buf.empty())
- UplinkSocket::Message(bi->GetUID()) << "PART " << chan->name << " :" << buf;
- else
- UplinkSocket::Message(bi->GetUID()) << "PART " << chan->name;
- }
-
- void SendModeInternal(const BotInfo *bi, const Channel *dest, const Anope::string &buf) anope_override
- {
- UplinkSocket::Message(bi ? bi->GetUID() : Me->GetSID()) << "MODE " << dest->name << " " << buf;
+ UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 255.255.255.255 " << u->GetUID() << " 0 " << u->host << " :" << u->realname;
}
void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override
{
- 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) anope_override
- {
- if (!buf.empty())
- UplinkSocket::Message(bi->GetUID()) << "KICK " << chan->name << " " << user->GetUID() << " :" << buf;
- else
- UplinkSocket::Message(bi->GetUID()) << "KICK " << chan->name << " " << user->GetUID();
- }
-
- /* INVITE */
- void SendInvite(const BotInfo *source, const Anope::string &chan, const Anope::string &nick) anope_override
- {
- User *u = finduser(nick);
- UplinkSocket::Message(source->GetUID()) << "INVITE " << (u ? u->GetUID() : nick) << " " << chan;
+ UplinkSocket::Message(bi) << "ENCAP * SVSMODE " << u->GetUID() << " " << u->timestamp << " " << buf;
}
void SendLogin(User *u) anope_override
@@ -222,17 +186,17 @@ class PlexusProto : public IRCDProto
if (!u->Account())
return;
- UplinkSocket::Message(Me->GetSID()) << "ENCAP * SU " << u->GetUID() << " " << u->Account()->display;
+ UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID() << " " << u->Account()->display;
}
void SendLogout(User *u) anope_override
{
- UplinkSocket::Message(Me->GetSID()) << "ENCAP * SU " << u->GetUID();
+ UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID();
}
void SendTopic(BotInfo *bi, Channel *c) anope_override
{
- UplinkSocket::Message(bi->GetUID()) << "ENCAP * TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_time + 1 << " :" << c->topic;
+ UplinkSocket::Message(bi) << "ENCAP * TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_time + 1 << " :" << c->topic;
}
void SendChannel(Channel *c) anope_override
@@ -240,7 +204,7 @@ class PlexusProto : public IRCDProto
Anope::string modes = c->GetModes(true, true);
if (modes.empty())
modes = "+";
- UplinkSocket::Message(Me->GetSID()) << "SJOIN " << c->creation_time << " " << c->name << " " << modes << "%s :";
+ UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :";
}
};
@@ -656,7 +620,7 @@ class ProtoPlexus : public Module
{
this->SetAuthor("Anope");
- pmodule_ircd_var(myIrcd);
+ pmodule_ircd_var(&myIrcd);
pmodule_ircd_proto(&this->ircd_proto);
pmodule_ircd_message(&this->ircd_message);
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index c694b1ddc..eeb0a50ac 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -13,8 +13,8 @@
static Anope::string TS6UPLINK;
-IRCDVar myIrcd[] = {
- {"Ratbox 2.0+", /* ircd name */
+IRCDVar myIrcd = {
+ "Ratbox 2.0+", /* ircd name */
"+oiS", /* Modes used by pseudoclients */
0, /* SVSNICK */
0, /* Vhost */
@@ -36,44 +36,41 @@ IRCDVar myIrcd[] = {
"$$", /* TLD Prefix for Global */
4, /* Max number of modes we can send per line */
0, /* IRCd sends a SSL users certificate fingerprint */
- }
- ,
- {NULL}
};
class RatboxProto : public IRCDProto
{
void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) anope_override
{
- UplinkSocket::Message(source ? source->GetUID() : Me->GetSID()) << "OPERWALL :" << buf;
+ UplinkSocket::Message(source) << "OPERWALL :" << buf;
}
void SendSQLine(User *, const XLine *x) anope_override
{
- UplinkSocket::Message(Me->GetSID()) << "RESV * " << x->Mask << " :" << x->Reason;
+ UplinkSocket::Message(Me) << "RESV * " << x->Mask << " :" << x->Reason;
}
void SendSGLineDel(const XLine *x) anope_override
{
BotInfo *bi = findbot(Config->OperServ);
- UplinkSocket::Message(bi ? bi->GetUID() : Config->OperServ) << "UNXLINE * " << x->Mask;
+ UplinkSocket::Message(bi) << "UNXLINE * " << x->Mask;
}
void SendSGLine(User *, const XLine *x) anope_override
{
BotInfo *bi = findbot(Config->OperServ);
- UplinkSocket::Message(bi ? bi->GetUID() : Config->OperServ) << "XLINE * " << x->Mask << " 0 :" << x->Reason;
+ UplinkSocket::Message(bi) << "XLINE * " << x->Mask << " 0 :" << x->Reason;
}
void SendAkillDel(const XLine *x) anope_override
{
BotInfo *bi = findbot(Config->OperServ);
- UplinkSocket::Message(bi ? bi->GetUID() : Config->OperServ) << "UNKLINE * " << x->GetUser() << " " << x->GetHost();
+ UplinkSocket::Message(bi) << "UNKLINE * " << x->GetUser() << " " << x->GetHost();
}
void SendSQLineDel(const XLine *x) anope_override
{
- UplinkSocket::Message(Me->GetSID()) << "UNRESV * " << x->Mask;
+ UplinkSocket::Message(Me) << "UNRESV * " << x->Mask;
}
void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
@@ -99,12 +96,7 @@ class RatboxProto : public IRCDProto
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
BotInfo *bi = findbot(Config->OperServ);
- 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) anope_override
- {
- UplinkSocket::Message(source ? source->GetUID() : Me->GetSID()) << "KILL " << user->GetUID() << " :" << buf;
+ UplinkSocket::Message(bi) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->Reason;
}
/* SERVER name hop descript */
@@ -151,40 +143,12 @@ class RatboxProto : public IRCDProto
void SendClientIntroduction(const User *u) anope_override
{
Anope::string modes = "+" + u->GetModes();
- 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) anope_override
- {
- if (!buf.empty())
- UplinkSocket::Message(bi->GetUID()) << "PART " << chan->name << " :" << buf;
- else
- UplinkSocket::Message(bi->GetUID()) << "PART " << chan->name;
- }
-
- void SendModeInternal(const BotInfo *bi, const Channel *dest, const Anope::string &buf) anope_override
- {
- UplinkSocket::Message(bi ? bi->GetUID() : Me->GetSID()) << "MODE " << dest->name << " " << buf;
+ UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " :" << u->realname;
}
void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override
{
- 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) anope_override
- {
- if (!buf.empty())
- UplinkSocket::Message(bi->GetUID()) << "KICK " << chan->name << " " << user->GetUID() << " :" << buf;
- else
- UplinkSocket::Message(bi->GetUID()) << "KICK " << chan->name << " " << user->GetUID();
- }
-
- /* INVITE */
- void SendInvite(const BotInfo *source, const Anope::string &chan, const Anope::string &nick) anope_override
- {
- User *u = finduser(nick);
- UplinkSocket::Message(source->GetUID()) << "INVITE " << (u ? u->GetUID() : nick) << " " << chan;
+ UplinkSocket::Message(bi) << "SVSMODE " << u->nick << " " << buf;
}
void SendLogin(User *u) anope_override
@@ -192,12 +156,12 @@ class RatboxProto : public IRCDProto
if (!u->Account())
return;
- UplinkSocket::Message(Me->GetSID()) << "ENCAP * SU " << u->GetUID() << " " << u->Account()->display;
+ UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID() << " " << u->Account()->display;
}
void SendLogout(User *u) anope_override
{
- UplinkSocket::Message(Me->GetSID()) << "ENCAP * SU " << u->GetUID();
+ UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID();
}
void SendChannel(Channel *c) anope_override
@@ -226,7 +190,7 @@ class RatboxProto : public IRCDProto
status.SetFlag(CMODE_OP);
bi->Join(c, &status);
}
- UplinkSocket::Message(bi->GetUID()) << "TOPIC " << c->name << " :" << c->topic;
+ IRCDProto::SendTopic(bi, c);
if (needjoin)
bi->Part(c);
}
@@ -570,7 +534,7 @@ class ProtoRatbox : public Module
{
this->SetAuthor("Anope");
- pmodule_ircd_var(myIrcd);
+ pmodule_ircd_var(&myIrcd);
pmodule_ircd_proto(&this->ircd_proto);
pmodule_ircd_message(&this->ircd_message);
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp
index 78d4a04be..5a3a44bd7 100644
--- a/modules/protocol/unreal.cpp
+++ b/modules/protocol/unreal.cpp
@@ -13,8 +13,8 @@
#include "module.h"
-IRCDVar myIrcd[] = {
- {"UnrealIRCd 3.2.x", /* ircd name */
+IRCDVar myIrcd = {
+ "UnrealIRCd 3.2.x", /* ircd name */
"+Soiq", /* Modes used by pseudoclients */
1, /* SVSNICK */
1, /* Vhost */
@@ -35,10 +35,7 @@ IRCDVar myIrcd[] = {
0, /* ts6 */
"$", /* TLD Prefix for Global */
12, /* Max number of modes we can send per line */
- 0, /* IRCd sends a SSL users certificate fingerprint */
- }
- ,
- {NULL}
+ 0 /* IRCd sends a SSL users certificate fingerprint */
};
class UnrealIRCdProto : public IRCDProto
@@ -56,7 +53,7 @@ class UnrealIRCdProto : public IRCDProto
void SendTopic(BotInfo *whosets, Channel *c) anope_override
{
- UplinkSocket::Message(whosets->nick) << ") " << c->name << " " << c->topic_setter << " " << c->topic_time + 1 << " :" << c->topic;
+ UplinkSocket::Message(whosets) << ") " << c->name << " " << c->topic_setter << " " << c->topic_time + 1 << " :" << c->topic;
}
void SendVhostDel(User *u) anope_override
@@ -72,24 +69,24 @@ class UnrealIRCdProto : public IRCDProto
{
// Calculate the time left before this would expire, capping it at 2 days
time_t timeleft = x->Expires - Anope::CurTime;
- if (timeleft > 172800)
+ if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
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) anope_override
{
- UplinkSocket::Message(source ? source->nick : Config->ServerName) << "h " << user->nick << " :" << buf;
+ UplinkSocket::Message(source) << "h " << user->nick << " :" << buf;
}
void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) anope_override
{
- UplinkSocket::Message(source ? source->nick : Config->ServerName) << "G " << dest->name << " " << buf;
+ UplinkSocket::Message(source) << "G " << dest->name << " " << buf;
}
void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override
{
- UplinkSocket::Message(bi ? bi->nick : Config->ServerName) << "v " << u->nick <<" " << buf;
+ UplinkSocket::Message(bi) << "v " << u->nick <<" " << buf;
}
void SendClientIntroduction(const User *u) anope_override
@@ -101,9 +98,9 @@ class UnrealIRCdProto : public IRCDProto
void SendKickInternal(const BotInfo *source, const Channel *chan, const User *user, const Anope::string &buf) anope_override
{
if (!buf.empty())
- UplinkSocket::Message(source->nick) << "H " << chan->name << " " << user->nick << " :" << buf;
+ UplinkSocket::Message(source) << "H " << chan->name << " " << user->nick << " :" << buf;
else
- UplinkSocket::Message(source->nick) << "H " << chan->name << " " << user->nick;
+ UplinkSocket::Message(source) << "H " << chan->name << " " << user->nick;
}
/* SERVER name hop descript */
@@ -119,7 +116,7 @@ class UnrealIRCdProto : public IRCDProto
/* JOIN */
void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override
{
- UplinkSocket::Message(Config->ServerName) << "~ " << c->creation_time << " " << c->name << " :" << user->nick;
+ UplinkSocket::Message(Me) << "~ " << c->creation_time << " " << c->name << " :" << user->nick;
if (status)
{
/* First save the channel status incase uc->Status == status */
@@ -161,7 +158,7 @@ class UnrealIRCdProto : public IRCDProto
** parv[1] = nick
** parv[2] = options
*/
- void SendSVSO(const Anope::string &source, const Anope::string &nick, const Anope::string &flag) anope_override
+ void SendSVSO(const BotInfo *source, const Anope::string &nick, const Anope::string &flag) anope_override
{
UplinkSocket::Message(source) << "BB " << nick << " " << flag;
}
@@ -169,7 +166,7 @@ class UnrealIRCdProto : public IRCDProto
/* NICK <newnick> */
void SendChangeBotNick(const BotInfo *oldnick, const Anope::string &newnick) anope_override
{
- UplinkSocket::Message(oldnick->nick) << "& " << newnick << " " << Anope::CurTime;
+ UplinkSocket::Message(oldnick) << "& " << newnick << " " << Anope::CurTime;
}
/* Functions that use serval cmd functions */
@@ -177,9 +174,9 @@ class UnrealIRCdProto : public IRCDProto
void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) anope_override
{
if (!vIdent.empty())
- UplinkSocket::Message(Config->ServerName) << "AZ " << u->nick << " " << vIdent;
+ UplinkSocket::Message(Me) << "AZ " << u->nick << " " << vIdent;
if (!vhost.empty())
- UplinkSocket::Message(Config->ServerName) << "AL " << u->nick << " " << vhost;
+ UplinkSocket::Message(Me) << "AL " << u->nick << " " << vhost;
}
void SendConnect() anope_override
@@ -263,7 +260,7 @@ class UnrealIRCdProto : public IRCDProto
/* In older Unreal SVSJOIN and SVSNLINE tokens were mixed so SVSJOIN and SVSNLINE are broken
when coming from a none TOKEN'd server
*/
- void SendSVSJoin(const Anope::string &source, const Anope::string &nick, const Anope::string &chan, const Anope::string &param) anope_override
+ void SendSVSJoin(const BotInfo *source, const Anope::string &nick, const Anope::string &chan, const Anope::string &param) anope_override
{
if (!param.empty())
UplinkSocket::Message(source) << "BX " << nick << " " << chan << " :" << param;
@@ -271,14 +268,14 @@ class UnrealIRCdProto : public IRCDProto
UplinkSocket::Message(source) << "BX " << nick << " :" << chan;
}
- void SendSWhois(const Anope::string &source, const Anope::string &who, const Anope::string &mask) anope_override
+ void SendSWhois(const BotInfo *source, const Anope::string &who, const Anope::string &mask) anope_override
{
UplinkSocket::Message(source) << "BA " << who << " :" << mask;
}
void SendEOB() anope_override
{
- UplinkSocket::Message(Config->ServerName) << "ES";
+ UplinkSocket::Message(Me) << "ES";
}
bool IsNickValid(const Anope::string &nick) anope_override
@@ -1157,7 +1154,7 @@ class ProtoUnreal : public Module
{
this->SetAuthor("Anope");
- pmodule_ircd_var(myIrcd);
+ pmodule_ircd_var(&myIrcd);
pmodule_ircd_proto(&this->ircd_proto);
pmodule_ircd_message(&this->ircd_message);
diff --git a/src/main.cpp b/src/main.cpp
index 55f185057..1d0a3e963 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -178,50 +178,71 @@ void UplinkSocket::OnError(const Anope::string &error)
Log(LOG_TERMINAL) << "Unable to connect to server " << Config->Uplinks[CurrentUplink]->host << ":" << Config->Uplinks[CurrentUplink]->port << (!error.empty() ? (": " + error) : "");
}
-UplinkSocket::Message::Message()
+UplinkSocket::Message::Message() : server(NULL), user(NULL)
{
}
-UplinkSocket::Message::Message(const Anope::string &s) : source(s)
+UplinkSocket::Message::Message(const Server *s) : server(s), user(NULL)
{
}
+UplinkSocket::Message::Message(const User *u) : server(NULL), user(u)
+{
+ if (!u)
+ server = Me;
+}
+
UplinkSocket::Message::~Message()
{
- if (!UplinkSock)
- {
- if (!this->source.empty())
- Log(LOG_DEBUG) << "Attempted to send \"" << this->source << " " << this->buffer.str() << "\" with UplinkSock NULL";
- else
- Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" with UplinkSock NULL";
- return;
- }
+ Anope::string message_source = "";
- if (this->source == Me->GetName())
+ if (this->server != NULL)
{
+ if (this->server != Me && !this->server->HasFlag(SERVER_JUPED))
+ {
+ Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" from " << this->server->GetName() << " who is not from me?";
+ return;
+ }
+
if (ircd->ts6)
- this->source = Me->GetSID();
+ message_source = this->server->GetSID();
+ else
+ message_source = this->server->GetName();
}
- else if (!this->source.empty() && this->source != Me->GetSID())
+ else if (this->user != NULL)
{
- BotInfo *bi = findbot(this->source);
- if (bi != NULL)
+ if (this->user->server != Me && !this->user->server->HasFlag(SERVER_JUPED))
{
- if (bi->introduced == false)
- {
- Log(LOG_DEBUG) << "Attempted to send \"" << this->source << " " << this->buffer.str() << "\" with source not introduced";
- return;
- }
+ Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" from " << this->user->nick << " who is not from me?";
+ return;
+ }
- if (ircd->ts6)
- this->source = bi->GetUID();
+ BotInfo *bi = findbot(this->user->nick);
+ if (bi != NULL && bi->introduced == false)
+ {
+ Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" from " << bi->nick << " when not introduced";
+ return;
}
+
+ if (ircd->ts6)
+ message_source = this->user->GetUID();
+ else
+ message_source = this->user->nick;
+ }
+
+ if (!UplinkSock)
+ {
+ if (!message_source.empty())
+ Log(LOG_DEBUG) << "Attempted to send \"" << message_source << " " << this->buffer.str() << "\" with UplinkSock NULL";
+ else
+ Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" with UplinkSock NULL";
+ return;
}
- if (!this->source.empty())
+ if (!message_source.empty())
{
- UplinkSock->Write(":" + this->source + " " + this->buffer.str());
- Log(LOG_RAWIO) << "Sent: :" << this->source << " " << this->buffer.str();
+ UplinkSock->Write(":" + message_source + " " + this->buffer.str());
+ Log(LOG_RAWIO) << "Sent: :" << message_source << " " << this->buffer.str();
}
else
{
diff --git a/src/messages.cpp b/src/messages.cpp
index fa93e528c..52e7c57c1 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -30,17 +30,17 @@ bool OnStats(const Anope::string &source, const std::vector<Anope::string> &para
case 'l':
if (u && u->HasMode(UMODE_OPER))
{
- ircdproto->SendNumeric(Config->ServerName, 211, source, "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime");
- ircdproto->SendNumeric(Config->ServerName, 211, source, "%s %d %d %d %d %d %d %ld", Config->Uplinks[CurrentUplink]->host.c_str(), UplinkSock->WriteBufferLen(), TotalWritten, -1, UplinkSock->ReadBufferLen(), TotalRead, -1, static_cast<long>(Anope::CurTime - start_time));
+ ircdproto->SendNumeric(211, source, "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime");
+ ircdproto->SendNumeric(211, source, "%s %d %d %d %d %d %d %ld", Config->Uplinks[CurrentUplink]->host.c_str(), UplinkSock->WriteBufferLen(), TotalWritten, -1, UplinkSock->ReadBufferLen(), TotalRead, -1, static_cast<long>(Anope::CurTime - start_time));
}
- ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", params[0][0]);
+ ircdproto->SendNumeric(219, source, "%c :End of /STATS report.", params[0][0]);
break;
case 'o':
case 'O':
/* Check whether the user is an operator */
if (u && !u->HasMode(UMODE_OPER) && Config->HideStatsO)
- ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", params[0][0]);
+ ircdproto->SendNumeric(219, source, "%c :End of /STATS report.", params[0][0]);
else
{
for (unsigned i = 0; i < Config->Opers.size(); ++i)
@@ -49,10 +49,10 @@ bool OnStats(const Anope::string &source, const std::vector<Anope::string> &para
NickAlias *na = findnick(o->name);
if (na)
- ircdproto->SendNumeric(Config->ServerName, 243, source, "O * * %s %s 0", o->name.c_str(), o->ot->GetName().c_str());
+ ircdproto->SendNumeric(243, source, "O * * %s %s 0", o->name.c_str(), o->ot->GetName().c_str());
}
- ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", params[0][0]);
+ ircdproto->SendNumeric(219, source, "%c :End of /STATS report.", params[0][0]);
}
break;
@@ -60,14 +60,14 @@ bool OnStats(const Anope::string &source, const std::vector<Anope::string> &para
case 'u':
{
time_t uptime = Anope::CurTime - start_time;
- ircdproto->SendNumeric(Config->ServerName, 242, source, ":Services up %d day%s, %02d:%02d:%02d", uptime / 86400, uptime / 86400 == 1 ? "" : "s", (uptime / 3600) % 24, (uptime / 60) % 60, uptime % 60);
- ircdproto->SendNumeric(Config->ServerName, 250, source, ":Current users: %d (%d ops); maximum %d", usercnt, opcnt, maxusercnt);
- ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", params[0][0]);
+ ircdproto->SendNumeric(242, source, ":Services up %d day%s, %02d:%02d:%02d", uptime / 86400, uptime / 86400 == 1 ? "" : "s", (uptime / 3600) % 24, (uptime / 60) % 60, uptime % 60);
+ ircdproto->SendNumeric(250, source, ":Current users: %d (%d ops); maximum %d", usercnt, opcnt, maxusercnt);
+ ircdproto->SendNumeric(219, source, "%c :End of /STATS report.", params[0][0]);
break;
} /* case 'u' */
default:
- ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", params[0][0]);
+ ircdproto->SendNumeric(219, source, "%c :End of /STATS report.", params[0][0]);
}
return true;
@@ -83,14 +83,14 @@ bool OnTime(const Anope::string &source, const std::vector<Anope::string> &)
struct tm *tm = localtime(&t);
char buf[64];
strftime(buf, sizeof(buf), "%a %b %d %H:%M:%S %Y %Z", tm);
- ircdproto->SendNumeric(Config->ServerName, 391, source, "%s :%s", Config->ServerName.c_str(), buf);
+ ircdproto->SendNumeric(391, source, "%s :%s", Config->ServerName.c_str(), buf);
return true;
}
bool OnVersion(const Anope::string &source, const std::vector<Anope::string> &)
{
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
- ircdproto->SendNumeric(Config->ServerName, 351, source, "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());
+ ircdproto->SendNumeric(351, source, "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());
return true;
}
@@ -103,18 +103,18 @@ bool OnMotd(const Anope::string &source, const std::vector<Anope::string> &)
FILE *f = fopen(Config->MOTDFilename.c_str(), "r");
if (f)
{
- ircdproto->SendNumeric(Config->ServerName, 375, source, ":- %s Message of the Day", Config->ServerName.c_str());
+ ircdproto->SendNumeric(375, source, ":- %s Message of the Day", Config->ServerName.c_str());
char buf[BUFSIZE];
while (fgets(buf, sizeof(buf), f))
{
buf[strlen(buf) - 1] = 0;
- ircdproto->SendNumeric(Config->ServerName, 372, source, ":- %s", buf);
+ ircdproto->SendNumeric(372, source, ":- %s", buf);
}
fclose(f);
- ircdproto->SendNumeric(Config->ServerName, 376, source, ":End of /MOTD command.");
+ ircdproto->SendNumeric(376, source, ":End of /MOTD command.");
}
else
- ircdproto->SendNumeric(Config->ServerName, 422, source, ":- MOTD file not found! Please contact your IRC administrator.");
+ ircdproto->SendNumeric(422, source, ":- MOTD file not found! Please contact your IRC administrator.");
return true;
}
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 051f6f2d1..f51880bbe 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -39,6 +39,24 @@ void pmodule_ircd_message(IRCdMessage *message)
ircdmessage = message;
}
+void IRCDProto::SendSVSKillInternal(const BotInfo *source, const User *user, const Anope::string &buf)
+{
+ UplinkSocket::Message(source) << "KILL " << (ircd->ts6 ? user->GetUID() : user->nick) << " :" << buf;
+}
+
+void IRCDProto::SendModeInternal(const BotInfo *bi, const Channel *dest, const Anope::string &buf)
+{
+ UplinkSocket::Message(bi) << "MODE " << dest->name << " " << buf;
+}
+
+void IRCDProto::SendKickInternal(const BotInfo *bi, const Channel *c, const User *u, const Anope::string &r)
+{
+ if (!r.empty())
+ UplinkSocket::Message(bi) << "KICK " << c->name << " " << (ircd->ts6 ? u->GetUID() : u->nick) << " :" << r;
+ else
+ UplinkSocket::Message(bi) << "KICK " << c->name << " " << (ircd->ts6 ? u->GetUID() : u->nick);
+}
+
void IRCDProto::SendMessageInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf)
{
if (Config->NSDefFlags.HasFlag(NI_MSG))
@@ -49,33 +67,36 @@ void IRCDProto::SendMessageInternal(const BotInfo *bi, const Anope::string &dest
void IRCDProto::SendNoticeInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &msg)
{
- UplinkSocket::Message(bi->nick) << "NOTICE " << dest << " :" << msg;
+ UplinkSocket::Message(bi) << "NOTICE " << dest << " :" << msg;
}
void IRCDProto::SendPrivmsgInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf)
{
- UplinkSocket::Message(bi->nick) << "PRIVMSG " << dest << " :" << buf;
+ UplinkSocket::Message(bi) << "PRIVMSG " << dest << " :" << buf;
}
void IRCDProto::SendQuitInternal(const User *u, const Anope::string &buf)
{
if (!buf.empty())
- UplinkSocket::Message(u->nick) << "QUIT :" << buf;
+ UplinkSocket::Message(u) << "QUIT :" << buf;
else
- UplinkSocket::Message(u->nick) << "QUIT";
+ UplinkSocket::Message(u) << "QUIT";
}
void IRCDProto::SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf)
{
if (!buf.empty())
- UplinkSocket::Message(bi->nick) << "PART " << chan->name << " :" << buf;
+ UplinkSocket::Message(bi) << "PART " << chan->name << " :" << buf;
else
- UplinkSocket::Message(bi->nick) << "PART " << chan->name;
+ UplinkSocket::Message(bi) << "PART " << chan->name;
}
void IRCDProto::SendGlobopsInternal(const BotInfo *source, const Anope::string &buf)
{
- UplinkSocket::Message(source ? source->nick : Config->ServerName) << "GLOBOPS :" << buf;
+ if (source)
+ UplinkSocket::Message(source) << "GLOBOPS :" << buf;
+ else
+ UplinkSocket::Message(Me) << "GLOBOPS :" << buf;
}
void IRCDProto::SendCTCPInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf)
@@ -84,14 +105,19 @@ void IRCDProto::SendCTCPInternal(const BotInfo *bi, const Anope::string &dest, c
this->SendNoticeInternal(bi, dest, "\1" + s + "\1");
}
-void IRCDProto::SendNumericInternal(const Anope::string &source, int numeric, const Anope::string &dest, const Anope::string &buf)
+void IRCDProto::SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf)
{
Anope::string n = stringify(numeric);
if (numeric < 10)
n = "0" + n;
if (numeric < 100)
n = "0" + n;
- UplinkSocket::Message(source) << n << " " << dest << " " << buf;
+ UplinkSocket::Message(Me) << n << " " << dest << " " << buf;
+}
+
+void IRCDProto::SendTopic(BotInfo *bi, Channel *c)
+{
+ UplinkSocket::Message(bi) << "TOPIC " << c->name << " :" << c->topic;
}
void IRCDProto::SendSVSKill(const BotInfo *source, const User *user, const char *fmt, ...)
@@ -183,12 +209,12 @@ void IRCDProto::SendPrivmsg(const BotInfo *bi, const Anope::string &dest, const
void IRCDProto::SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg)
{
- UplinkSocket::Message(bi->nick) << "NOTICE " << ircd->globaltldprefix << dest->GetName() << " :" << msg;
+ UplinkSocket::Message(bi) << "NOTICE " << ircd->globaltldprefix << dest->GetName() << " :" << msg;
}
void IRCDProto::SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg)
{
- UplinkSocket::Message(bi->nick) << "PRIVMSG " << ircd->globaltldprefix << dest->GetName() << " :" << msg;
+ UplinkSocket::Message(bi) << "PRIVMSG " << ircd->globaltldprefix << dest->GetName() << " :" << msg;
}
void IRCDProto::SendQuit(const User *u, const char *fmt, ...)
@@ -204,9 +230,9 @@ void IRCDProto::SendQuit(const User *u, const char *fmt, ...)
void IRCDProto::SendPing(const Anope::string &servname, const Anope::string &who)
{
if (servname.empty())
- UplinkSocket::Message(Config->ServerName) << "PING " << who;
+ UplinkSocket::Message(Me) << "PING " << who;
else
- UplinkSocket::Message(Config->ServerName) << "PING " << servname << " " << who;
+ UplinkSocket::Message(Me) << "PING " << servname << " " << who;
}
/**
@@ -218,14 +244,14 @@ void IRCDProto::SendPing(const Anope::string &servname, const Anope::string &who
void IRCDProto::SendPong(const Anope::string &servname, const Anope::string &who)
{
if (servname.empty())
- UplinkSocket::Message(Config->ServerName) << "PONG " << who;
+ UplinkSocket::Message(Me) << "PONG " << who;
else
- UplinkSocket::Message(Config->ServerName) << "PONG " << servname << " " << who;
+ UplinkSocket::Message(Me) << "PONG " << servname << " " << who;
}
-void IRCDProto::SendInvite(const BotInfo *bi, const Anope::string &chan, const Anope::string &nick)
+void IRCDProto::SendInvite(const BotInfo *bi, const Channel *c, const User *u)
{
- UplinkSocket::Message(bi->nick) << "INVITE " << nick << " " << chan;
+ UplinkSocket::Message(bi) << "INVITE " << (ircd->ts6 ? u->GetUID() : u->nick) << " " << c->name;
}
void IRCDProto::SendPart(const BotInfo *bi, const Channel *chan, const char *fmt, ...)
@@ -260,7 +286,7 @@ void IRCDProto::SendSquit(Server *s, const Anope::string &message)
void IRCDProto::SendChangeBotNick(const BotInfo *bi, const Anope::string &newnick)
{
- UplinkSocket::Message(bi->nick) << "NICK " << newnick << " " << Anope::CurTime;
+ UplinkSocket::Message(bi) << "NICK " << newnick << " " << Anope::CurTime;
}
void IRCDProto::SendForceNickChange(const User *u, const Anope::string &newnick, time_t when)
@@ -278,14 +304,14 @@ void IRCDProto::SendCTCP(const BotInfo *bi, const Anope::string &dest, const cha
SendCTCPInternal(bi, dest, buf);
}
-void IRCDProto::SendNumeric(const Anope::string &source, int numeric, const Anope::string &dest, const char *fmt, ...)
+void IRCDProto::SendNumeric(int numeric, const Anope::string &dest, const char *fmt, ...)
{
va_list args;
char buf[BUFSIZE] = "";
va_start(args, fmt);
vsnprintf(buf, BUFSIZE - 1, fmt, args);
va_end(args);
- SendNumericInternal(source, numeric, dest, buf);
+ SendNumericInternal(numeric, dest, buf);
}
bool IRCDProto::IsChannelValid(const Anope::string &chan)
@@ -518,16 +544,16 @@ bool IRCdMessage::OnWhois(const Anope::string &source, const std::vector<Anope::
if (u && u->server == Me)
{
BotInfo *bi = findbot(u->nick);
- ircdproto->SendNumeric(Config->ServerName, 311, source, "%s %s %s * :%s", u->nick.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->realname.c_str());
+ ircdproto->SendNumeric(311, source, "%s %s %s * :%s", u->nick.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->realname.c_str());
if (bi)
- ircdproto->SendNumeric(Config->ServerName, 307, source, "%s :is a registered nick", bi->nick.c_str());
- ircdproto->SendNumeric(Config->ServerName, 312, source, "%s %s :%s", u->nick.c_str(), Config->ServerName.c_str(), Config->ServerDesc.c_str());
+ ircdproto->SendNumeric(307, source, "%s :is a registered nick", bi->nick.c_str());
+ ircdproto->SendNumeric(312, source, "%s %s :%s", u->nick.c_str(), Config->ServerName.c_str(), Config->ServerDesc.c_str());
if (bi)
- ircdproto->SendNumeric(Config->ServerName, 317, source, "%s %ld %ld :seconds idle, signon time", bi->nick.c_str(), static_cast<long>(Anope::CurTime - bi->lastmsg), static_cast<long>(start_time));
- ircdproto->SendNumeric(Config->ServerName, 318, source, "%s :End of /WHOIS list.", params[0].c_str());
+ ircdproto->SendNumeric(317, source, "%s %ld %ld :seconds idle, signon time", bi->nick.c_str(), static_cast<long>(Anope::CurTime - bi->lastmsg), static_cast<long>(start_time));
+ ircdproto->SendNumeric(318, source, "%s :End of /WHOIS list.", params[0].c_str());
}
else
- ircdproto->SendNumeric(Config->ServerName, 401, source, "%s :No such user.", params[0].c_str());
+ ircdproto->SendNumeric(401, source, "%s :No such user.", params[0].c_str());
}
return true;