summaryrefslogtreecommitdiff
path: root/modules/protocol
diff options
context:
space:
mode:
authorlethality <lethality@anope.org>2012-02-23 00:04:36 +0000
committerlethality <lethality@anope.org>2012-02-23 00:04:36 +0000
commitf01aab5f9bf5c14162438d1707e6e6cd9730c703 (patch)
tree4df360cd61e7dd1fd749d90e9dbe9e3cf1d739af /modules/protocol
parent826de43724d4584f9150a1fb8cebe8f49d9431a7 (diff)
parent3850b073ddf610415de54dced9ff134397779676 (diff)
Merge branch '1.9' of ssh://anope.git.sf.net/gitroot/anope/anope into 1.9
Diffstat (limited to 'modules/protocol')
-rw-r--r--modules/protocol/bahamut.cpp108
-rw-r--r--modules/protocol/inspircd-ts6.h145
-rw-r--r--modules/protocol/inspircd11.cpp126
-rw-r--r--modules/protocol/inspircd12.cpp12
-rw-r--r--modules/protocol/inspircd20.cpp22
-rw-r--r--modules/protocol/plexus.cpp109
-rw-r--r--modules/protocol/ratbox.cpp97
-rw-r--r--modules/protocol/unreal.cpp101
8 files changed, 454 insertions, 266 deletions
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index 8645c7176..a26669a9b 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,32 +44,40 @@ 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 */
void SendSQLine(User *, const XLine *x) anope_override
{
- UplinkSocket::Message() << "SQLINE " << x->Mask << " :" << x->Reason;
+ UplinkSocket::Message() << "SQLINE " << x->Mask << " :" << x->GetReason();
}
/* UNSLINE */
@@ -98,9 +103,9 @@ class BahamutIRCdProto : public IRCDProto
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
/* this will likely fail so its only here for legacy */
- UplinkSocket::Message() << "SZLINE " << x->GetHost() << " :" << x->Reason;
+ UplinkSocket::Message() << "SZLINE " << x->GetHost() << " :" << x->GetReason();
/* this is how we are supposed to deal with it */
- UplinkSocket::Message() << "AKILL " << x->GetHost() << " * " << timeleft << " " << x->By << " " << Anope::CurTime << " :" << x->Reason;
+ UplinkSocket::Message() << "AKILL " << x->GetHost() << " * " << timeleft << " " << x->By << " " << Anope::CurTime << " :" << x->GetReason();
}
/* SVSNOOP */
@@ -112,19 +117,34 @@ class BahamutIRCdProto : public IRCDProto
/* SGLINE */
void SendSGLine(User *, const XLine *x) anope_override
{
- UplinkSocket::Message() << "SGLINE " << x->Mask.length() << " :" << x->Mask << ":" << x->Reason;
+ UplinkSocket::Message() << "SGLINE " << x->Mask.length() << " :" << x->Mask << ":" << x->GetReason();
}
/* RAKILL */
void SendAkillDel(const XLine *x) anope_override
{
+ if (x->IsRegex() || x->HasNickOrReal())
+ return;
+
+ /* ZLine if we can instead */
+ try
+ {
+ if (x->GetUser() == "*")
+ {
+ sockaddrs(x->GetHost());
+ ircdproto->SendSZLineDel(x);
+ return;
+ }
+ }
+ catch (const SocketException &) { }
+
UplinkSocket::Message() << "RAKILL " << x->GetHost() << " " << x->GetUser();
}
/* 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 +156,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 */
@@ -155,13 +175,48 @@ class BahamutIRCdProto : public IRCDProto
}
}
- void SendAkill(User *, const XLine *x) anope_override
+ void SendAkill(User *u, XLine *x) anope_override
{
+ if (x->IsRegex() || x->HasNickOrReal())
+ {
+ if (!u)
+ {
+ /* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
+ for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ if (x->manager->Check(it->second, x))
+ this->SendAkill(it->second, x);
+ return;
+ }
+
+ XLine *old = x;
+
+ if (old->manager->HasEntry("*@" + u->host))
+ return;
+
+ /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */
+ x = new XLine("*@" + u->host, old->By, old->Expires, old->Reason, old->UID);
+ old->manager->AddXLine(x);
+
+ Log(findbot(Config->OperServ), "akill") << "AKILL: Added an akill for " << x->Mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->Mask;
+ }
+
+ /* ZLine if we can instead */
+ try
+ {
+ if (x->GetUser() == "*")
+ {
+ sockaddrs(x->GetHost());
+ ircdproto->SendSZLine(u, x);
+ return;
+ }
+ }
+ catch (const SocketException &) { }
+
// Calculate the time left before this would expire, capping it at 2 days
time_t timeleft = x->Expires - Anope::CurTime;
if (timeleft > 172800)
timeleft = 172800;
- UplinkSocket::Message() << "AKILL " << x->GetHost() << " " << x->GetUser() << " " << timeleft << " " << x->By << " " << Anope::CurTime << " :" << x->Reason;
+ UplinkSocket::Message() << "AKILL " << x->GetHost() << " " << x->GetUser() << " " << timeleft << " " << x->By << " " << Anope::CurTime << " :" << x->GetReason();
}
/*
@@ -169,7 +224,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 +240,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 +594,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..ec6246e49 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,7 +44,7 @@ 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:
@@ -52,12 +52,26 @@ class InspIRCdTS6Proto : public IRCDProto
void SendAkillDel(const XLine *x) anope_override
{
BotInfo *bi = findbot(Config->OperServ);
- UplinkSocket::Message(bi ? bi->GetUID() : Config->Numeric) << "GLINE " << x->Mask;
+
+ /* InspIRCd may support regex bans */
+ if (x->IsRegex() && has_rlinemod)
+ {
+ Anope::string mask = x->Mask;
+ size_t h = x->Mask.find('#');
+ if (h != Anope::string::npos)
+ mask = mask.replace(h, 1, ' ');
+ UplinkSocket::Message(bi) << "RLINE " << mask;
+ return;
+ }
+ else if (x->IsRegex() || x->HasNickOrReal())
+ return;
+
+ UplinkSocket::Message(bi) << "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
@@ -71,60 +85,93 @@ class InspIRCdTS6Proto : public IRCDProto
this->SendChgIdentInternal(u->nick, u->GetIdent());
}
- void SendAkill(User *, const XLine *x) anope_override
+ void SendAkill(User *u, XLine *x) anope_override
{
// 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;
- 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);
+ /* InspIRCd may support regex bans, if they do we can send this and forget about it */
+ if (x->IsRegex() && has_rlinemod)
+ {
+ Anope::string mask = x->Mask;
+ size_t h = x->Mask.find('#');
+ if (h != Anope::string::npos)
+ mask = mask.replace(h, 1, ' ');
+ UplinkSocket::Message(bi) << "RLINE " << mask << " " << timeleft << " :" << x->Reason;
+ return;
+ }
+ else if (x->IsRegex() || x->HasNickOrReal())
+ {
+ if (!u)
+ {
+ /* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
+ for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ if (x->manager->Check(it->second, x))
+ this->SendAkill(it->second, x);
+ return;
+ }
+
+ XLine *old = x;
+
+ if (old->manager->HasEntry("*@" + u->host))
+ return;
+
+ /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */
+ x = new XLine("*@" + u->host, old->By, old->Expires, old->Reason, old->UID);
+ old->manager->AddXLine(x);
+
+ Log(bi, "akill") << "AKILL: Added an akill for " << x->Mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->Mask;
+ }
+
+ /* ZLine if we can instead */
+ try
+ {
+ if (x->GetUser() == "*")
+ {
+ sockaddrs(x->GetHost());
+ ircdproto->SendSZLine(u, x);
+ return;
+ }
+ }
+ catch (const SocketException &) { }
+
+ 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 +197,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 +207,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 +223,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 +233,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 +241,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 +257,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 +296,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 +501,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 +511,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 +520,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..f4c8c2202 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,27 @@ class InspIRCdProto : public IRCDProto
{
void SendAkillDel(const XLine *x) anope_override
{
- UplinkSocket::Message(Config->OperServ) << "GLINE " << x->Mask;
+ if (x->IsRegex() || x->HasNickOrReal())
+ return;
+
+ /* ZLine if we can instead */
+ try
+ {
+ if (x->GetUser() == "*")
+ {
+ sockaddrs(x->GetHost());
+ ircdproto->SendSZLineDel(x);
+ return;
+ }
+ }
+ catch (const SocketException &) { }
+
+ 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
@@ -103,60 +115,104 @@ class InspIRCdProto : public IRCDProto
inspircd_cmd_chgident(u->nick, u->GetIdent());
}
- void SendAkill(User *, const XLine *x) anope_override
+ void SendAkill(User *u, XLine *x) anope_override
{
+ if (x->IsRegex() || x->HasNickOrReal())
+ {
+ if (!u)
+ {
+ /* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
+ for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ if (x->manager->Check(it->second, x))
+ this->SendAkill(it->second, x);
+ return;
+ }
+
+ XLine *old = x;
+
+ if (old->manager->HasEntry("*@" + u->host))
+ return;
+
+ /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */
+ x = new XLine("*@" + u->host, old->By, old->Expires, old->Reason, old->UID);
+ old->manager->AddXLine(x);
+
+ Log(findbot(Config->OperServ), "akill") << "AKILL: Added an akill for " << x->Mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->Mask;
+ }
+
+ /* ZLine if we can instead */
+ try
+ {
+ if (x->GetUser() == "*")
+ {
+ sockaddrs(x->GetHost());
+ ircdproto->SendSZLine(u, x);
+ return;
+ }
+ }
+ catch (const SocketException &) { }
+
// 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;
- 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->GetReason();
}
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 +234,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 +244,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 <<