1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 05:56:38 +02:00

Made akills work on IRCds that do not support bans (ngircd)

This commit is contained in:
Adam
2011-02-27 16:47:23 -05:00
parent f234a2bfab
commit bcaf406747
17 changed files with 87 additions and 84 deletions
+7 -9
View File
@@ -97,10 +97,6 @@ class CoreExport XLineManager
*/
static std::pair<XLineManager *, XLine *> CheckAll(User *u);
/** Called on burst when all of our XLines should be bursted to the uplink
*/
static void Burst();
/** Get the number of XLines in this XLineManager
* @return The number of XLines
*/
@@ -184,8 +180,10 @@ class CoreExport XLineManager
virtual void OnExpire(XLine *x);
/** Called to send an XLine to the IRCd
* @param u The user, if we know it
* @param x The xline
*/
virtual void Send(XLine *x) = 0;
virtual void Send(User *u, XLine *x) = 0;
};
/* This is for AKILLS */
@@ -200,7 +198,7 @@ class SGLineManager : public XLineManager
void OnExpire(XLine *x);
void Send(XLine *x);
void Send(User *u, XLine *x);
};
class SNLineManager : public XLineManager
@@ -214,7 +212,7 @@ class SNLineManager : public XLineManager
void OnExpire(XLine *x);
void Send(XLine *x);
void Send(User *u, XLine *x);
XLine *Check(User *u);
};
@@ -230,7 +228,7 @@ class SQLineManager : public XLineManager
void OnExpire(XLine *x);
void Send(XLine *x);
void Send(User *u, XLine *x);
static bool Check(Channel *c);
};
@@ -246,7 +244,7 @@ class SZLineManager : public XLineManager
void OnExpire(XLine *x);
void Send(XLine *x);
void Send(User *u, XLine *x);
};
#endif // OPERSERV_H
+5 -5
View File
@@ -973,7 +973,7 @@ class CoreExport IRCDProto
virtual void SendSVSNOOP(const Anope::string &, int) { }
virtual void SendTopic(BotInfo *, Channel *) = 0;
virtual void SendVhostDel(User *) { }
virtual void SendAkill(const XLine *) = 0;
virtual void SendAkill(User *, const XLine *) = 0;
virtual void SendAkillDel(const XLine *) = 0;
virtual void SendSVSKill(const BotInfo *source, const User *user, const char *fmt, ...);
virtual void SendMode(const BotInfo *bi, const Channel *dest, const char *fmt, ...);
@@ -992,11 +992,11 @@ class CoreExport IRCDProto
virtual void SendPing(const Anope::string &servname, const Anope::string &who);
virtual void SendPong(const Anope::string &servname, const Anope::string &who);
virtual void SendJoin(BotInfo *, Channel *, const ChannelStatus *) = 0;
virtual void SendSQLineDel(const XLine *x) = 0;
virtual void SendSQLineDel(const XLine *x) { }
virtual void SendInvite(const BotInfo *bi, const Anope::string &chan, const Anope::string &nick);
virtual void SendPart(const BotInfo *bi, const Channel *chan, const char *fmt, ...);
virtual void SendGlobops(const BotInfo *source, const char *fmt, ...);
virtual void SendSQLine(const XLine *x) = 0;
virtual void SendSQLine(User *, const XLine *x) { }
virtual void SendSquit(const Anope::string &servname, const Anope::string &message);
virtual void SendSVSO(const Anope::string &, const Anope::string &, const Anope::string &) { }
virtual void SendChangeBotNick(const BotInfo *bi, const Anope::string &newnick);
@@ -1007,8 +1007,8 @@ class CoreExport IRCDProto
virtual void SendSVSHoldDel(const Anope::string &) { }
virtual void SendSGLineDel(const XLine *) { }
virtual void SendSZLineDel(const XLine *) { }
virtual void SendSZLine(const XLine *) { }
virtual void SendSGLine(const XLine *) { }
virtual void SendSZLine(User *u, const XLine *) { }
virtual void SendSGLine(User *, const XLine *) { }
virtual void SendUnregisteredNick(const User *) { }
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 &) { }
+2 -2
View File
@@ -241,7 +241,7 @@ class CommandBSBot : public Command
{
ircdproto->SendChangeBotNick(bi, nick);
XLine x(bi->nick, "Reserved for services");
ircdproto->SendSQLine(&x);
ircdproto->SendSQLine(NULL, &x);
}
if (!nick.equals_cs(bi->nick))
@@ -258,7 +258,7 @@ class CommandBSBot : public Command
{
ircdproto->SendClientIntroduction(bi, ircd->pseudoclient_mode);
XLine x(bi->nick, "Reserved for services");
ircdproto->SendSQLine(&x);
ircdproto->SendSQLine(NULL, &x);
bi->RejoinAll();
}
+1 -1
View File
@@ -82,7 +82,7 @@ class CommandCSForbid : public Command
if (ircd->chansqline)
{
XLine x(chan, "Forbidden");
ircdproto->SendSQLine(&x);
ircdproto->SendSQLine(NULL, &x);
}
Log(LOG_ADMIN, u, this, ci) << (!ci->forbidreason.empty() ? ci->forbidreason : "No reason");
+1 -1
View File
@@ -71,7 +71,7 @@ class CommandNSForbid : public Command
if (ircd->sqline)
{
XLine x(na->nick, !reason.empty() ? reason : "Forbidden");
ircdproto->SendSQLine(&x);
ircdproto->SendSQLine(NULL, &x);
}
Log(LOG_ADMIN, u, this) << "to forbid nick " << nick;
-1
View File
@@ -23,7 +23,6 @@ class CommandCSSetMisc : public Command
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
User *u = source.u;
ChannelInfo *ci = source.ci;
if (!ci)
throw CoreException("NULL ci in CommandCSSetMisc");
+2 -2
View File
@@ -66,13 +66,13 @@ class DNSBLResolver : public DNSRequest
Log(LOG_COMMAND, OperServ, &fake_akill) << "for " << user->GetMask() << " (Listed in " << this->blacklist.name << ")";
/* If AkillOnAdd is disabled send it anyway, noone wants bots around... */
if (!Config->AkillOnAdd)
ircdproto->SendAkill(x);
ircdproto->SendAkill(*user, x);
}
else
{
Log(OperServ) << "DNSBL: " << user->GetMask() << " appears in " << this->blacklist.name;
XLine xline(Anope::string("*@") + user->host, OperServ ? OperServ->nick : "OperServ", Anope::CurTime + this->blacklist.bantime, reason);
ircdproto->SendAkill(&xline);
ircdproto->SendAkill(*user, &xline);
}
}
};
+4 -4
View File
@@ -99,7 +99,7 @@ class BahamutIRCdProto : public IRCDProto
}
/* SQLINE */
void SendSQLine(const XLine *x)
void SendSQLine(User *, const XLine *x)
{
send_cmd("", "SQLINE %s :%s", x->Mask.c_str(), x->Reason.c_str());
}
@@ -120,7 +120,7 @@ class BahamutIRCdProto : public IRCDProto
}
/* SZLINE */
void SendSZLine(const XLine *x)
void SendSZLine(User *, const XLine *x)
{
/* this will likely fail so its only here for legacy */
send_cmd("", "SZLINE %s :%s", x->Mask.c_str(), x->Reason.c_str());
@@ -135,7 +135,7 @@ class BahamutIRCdProto : public IRCDProto
}
/* SGLINE */
void SendSGLine(const XLine *x)
void SendSGLine(User *, const XLine *x)
{
send_cmd("", "SGLINE %d :%s:%s", static_cast<int>(x->Mask.length()), x->Mask.c_str(), x->Reason.c_str());
}
@@ -168,7 +168,7 @@ class BahamutIRCdProto : public IRCDProto
c->SetMode(user, static_cast<ChannelModeName>(i), user->nick, false);
}
void SendAkill(const XLine *x)
void SendAkill(User *, const XLine *x)
{
// Calculate the time left before this would expire, capping it at 2 days
time_t timeleft = x->Expires - Anope::CurTime;
+3 -3
View File
@@ -51,7 +51,7 @@ class InspIRCdTS6Proto : public IRCDProto
this->SendChgIdentInternal(u->nick, u->GetIdent());
}
void SendAkill(const XLine *x)
void SendAkill(User *, const XLine *x)
{
// Calculate the time left before this would expire, capping it at 2 days
time_t timeleft = x->Expires - Anope::CurTime;
@@ -125,7 +125,7 @@ class InspIRCdTS6Proto : public IRCDProto
}
/* SQLINE */
void SendSQLine(const XLine *x)
void SendSQLine(User *, const XLine *x)
{
send_cmd(Config->Numeric, "ADDLINE Q %s %s %ld 0 :%s", x->Mask.c_str(), Config->s_OperServ.c_str(), static_cast<long>(Anope::CurTime), x->Reason.c_str());
}
@@ -172,7 +172,7 @@ class InspIRCdTS6Proto : public IRCDProto
}
/* SZLINE */
void SendSZLine(const XLine *x)
void SendSZLine(User *, const XLine *x)
{
send_cmd(Config->Numeric, "ADDLINE Z %s %s %ld 0 :%s", x->Mask.c_str(), x->By.c_str(), static_cast<long>(Anope::CurTime), x->Reason.c_str());
}
+3 -3
View File
@@ -99,7 +99,7 @@ class InspIRCdProto : public IRCDProto
inspircd_cmd_chgident(u->nick, u->GetIdent());
}
void SendAkill(const XLine *x)
void SendAkill(User *, const XLine *x)
{
// Calculate the time left before this would expire, capping it at 2 days
time_t timeleft = x->Expires - Anope::CurTime;
@@ -170,7 +170,7 @@ class InspIRCdProto : public IRCDProto
}
/* SQLINE */
void SendSQLine(const XLine *x)
void SendSQLine(User *, const XLine *x)
{
send_cmd(Config->ServerName, "ADDLINE Q %s %s %ld 0 :%s", x->Mask.c_str(), Config->s_OperServ.c_str(), static_cast<long>(Anope::CurTime), x->Reason.c_str());
}
@@ -231,7 +231,7 @@ class InspIRCdProto : public IRCDProto
}
/* SZLINE */
void SendSZLine(const XLine *x)
void SendSZLine(User *, const XLine *x)
{
send_cmd(Config->ServerName, "ADDLINE Z %s %s %ld 0 :%s", x->Mask.c_str(), x->By.c_str(), static_cast<long>(Anope::CurTime), x->Reason.c_str());
}
+9 -6
View File
@@ -18,7 +18,7 @@ IRCDVar myIrcd[] = {
0, /* SVSNICK */
0, /* Vhost */
0, /* Supports SNlines */
1, /* Supports SQlines */
0, /* Supports SQlines */
0, /* Supports SZlines */
0, /* Join 2 Message */
0, /* Chan SQlines */
@@ -42,12 +42,15 @@ IRCDVar myIrcd[] = {
/* PASS */
class ngIRCdProto : public IRCDProto
{
void SendAkill(const XLine *x) { }
void SendAkill(User *u, const XLine *x)
{
if (SGLine && u == NULL)
for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();)
if (SGLine->Check(*it) != NULL)
break;
}
void SendAkillDel(const XLine*) { }
void SendSQLine(const XLine*) { }
void SendSQLineDel(const XLine*) { }
void SendSGLine(const XLine *x) { }
void SendSGLineDel(const XLine *x) { }
void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf)
{
+3 -3
View File
@@ -92,7 +92,7 @@ class PlexusProto : public IRCDProto
send_cmd(source ? source->GetUID() : Config->Numeric, "OPERWALL :%s", buf.c_str());
}
void SendSQLine(const XLine *x)
void SendSQLine(User *, const XLine *x)
{
send_cmd(Config->Numeric, "RESV * %s :%s", x->Mask.c_str(), x->Reason.c_str());
}
@@ -103,7 +103,7 @@ class PlexusProto : public IRCDProto
send_cmd(bi ? bi->GetUID() : Config->s_OperServ, "UNXLINE * %s", x->Mask.c_str());
}
void SendSGLine(const XLine *x)
void SendSGLine(User *, const XLine *x)
{
BotInfo *bi = OperServ;
send_cmd(bi ? bi->GetUID() : Config->s_OperServ, "XLINE * %s 0 :%s", x->Mask.c_str(), x->Reason.c_str());
@@ -129,7 +129,7 @@ class PlexusProto : public IRCDProto
c->SetMode(user, static_cast<ChannelModeName>(i), user->nick, false);
}
void SendAkill(const XLine *x)
void SendAkill(User *, const XLine *x)
{
BotInfo *bi = OperServ;
send_cmd(bi ? bi->GetUID() : Config->s_OperServ, "KLINE * %ld %s %s :%s", static_cast<long>(x->Expires - Anope::CurTime), x->GetUser().c_str(), x->GetHost().c_str(), x->Reason.c_str());
+3 -3
View File
@@ -95,7 +95,7 @@ class RatboxProto : public IRCDProto
send_cmd(source ? source->GetUID() : Config->Numeric, "OPERWALL :%s", buf.c_str());
}
void SendSQLine(const XLine *x)
void SendSQLine(User *, const XLine *x)
{
send_cmd(Config->Numeric, "RESV * %s :%s", x->Mask.c_str(), x->Reason.c_str());
}
@@ -106,7 +106,7 @@ class RatboxProto : public IRCDProto
send_cmd(bi ? bi->GetUID() : Config->s_OperServ, "UNXLINE * %s", x->Mask.c_str());
}
void SendSGLine(const XLine *x)
void SendSGLine(User *, const XLine *x)
{
BotInfo *bi = OperServ;
send_cmd(bi ? bi->GetUID() : Config->s_OperServ, "XLINE * %s 0 :%s", x->Mask.c_str(), x->Reason.c_str());
@@ -139,7 +139,7 @@ class RatboxProto : public IRCDProto
}
}
void SendAkill(const XLine *x)
void SendAkill(User *, const XLine *x)
{
BotInfo *bi = OperServ;
send_cmd(bi ? bi->GetUID() : Config->s_OperServ, "KLINE * %ld %s %s :%s", static_cast<long>(x->Expires - Anope::CurTime), x->GetUser().c_str(), x->GetHost().c_str(), x->Reason.c_str());
+4 -4
View File
@@ -113,7 +113,7 @@ class UnrealIRCdProto : public IRCDProto
ModeManager::ProcessModes();
}
void SendAkill(const XLine *x)
void SendAkill(User *, const XLine *x)
{
// Calculate the time left before this would expire, capping it at 2 days
time_t timeleft = x->Expires - Anope::CurTime;
@@ -190,7 +190,7 @@ class UnrealIRCdProto : public IRCDProto
** - Unreal will translate this to TKL for us
**
*/
void SendSQLine(const XLine *x)
void SendSQLine(User *, const XLine *x)
{
send_cmd("", "c %s :%s", x->Mask.c_str(), x->Reason.c_str());
}
@@ -257,7 +257,7 @@ class UnrealIRCdProto : public IRCDProto
}
/* SZLINE */
void SendSZLine(const XLine *x)
void SendSZLine(User *, const XLine *x)
{
send_cmd("", "BD + Z * %s %s %ld %ld :%s", x->Mask.c_str(), x->By.c_str(), static_cast<long>(Anope::CurTime + 172800), static_cast<long>(Anope::CurTime), x->Reason.c_str());
}
@@ -266,7 +266,7 @@ class UnrealIRCdProto : public IRCDProto
/*
* SVSNLINE + reason_where_is_space :realname mask with spaces
*/
void SendSGLine(const XLine *x)
void SendSGLine(User *, const XLine *x)
{
Anope::string edited_reason = x->Reason;
edited_reason = edited_reason.replace_all_cs(" ", "_");
+1 -1
View File
@@ -55,7 +55,7 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
{
ircdproto->SendClientIntroduction(this, ircd->pseudoclient_mode);
XLine x(this->nick, "Reserved for services");
ircdproto->SendSQLine(&x);
ircdproto->SendSQLine(NULL, &x);
}
this->SetModeInternal(ModeManager::FindUserModeByName(UMODE_PROTECTED));
+2 -5
View File
@@ -34,7 +34,7 @@ void introduce_user(const Anope::string &user)
if (bi)
{
XLine x(bi->nick, "Reserved for services");
ircdproto->SendSQLine(&x);
ircdproto->SendSQLine(NULL, &x);
for (UChannelList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit)
ircdproto->SendJoin(bi, (*cit)->chan, &Config->BotModeList);
@@ -67,7 +67,7 @@ void introduce_user(const Anope::string &user)
if (bi)
{
XLine x(bi->nick, "Reserved for services");
ircdproto->SendSQLine(&x);
ircdproto->SendSQLine(NULL, &x);
for (UChannelList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit)
ircdproto->SendJoin(bi, (*cit)->chan, &Config->BotModeList);
@@ -77,9 +77,6 @@ void introduce_user(const Anope::string &user)
/* Load MLock from the database now that we know what modes exist */
for (registered_channel_map::iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
it->second->LoadMLock();
/* Add our SXLines */
XLineManager::Burst();
}
/*************************************************************************/
+37 -31
View File
@@ -252,17 +252,6 @@ std::pair<XLineManager *, XLine *> XLineManager::CheckAll(User *u)
return ret;
}
void XLineManager::Burst()
{
for (std::list<XLineManager *>::iterator it = XLineManagers.begin(), it_end = XLineManagers.end(); it != it_end; ++it)
{
XLineManager *xlm = *it;
for (std::vector<XLine *>::const_iterator it2 = xlm->GetList().begin(), it2_end = xlm->GetList().end(); it2 != it2_end; ++it2)
xlm->Send(*it2);
}
}
/** Get the number of XLines in this XLineManager
* @return The number of XLines
*/
@@ -446,7 +435,10 @@ XLine *XLineManager::Check(User *u)
{
cidr cidr_ip(x->GetHost());
if (cidr_ip.match(u->ip))
{
OnMatch(u, x);
return x;
}
}
catch (const SocketException &) { }
}
@@ -532,7 +524,7 @@ XLine *SGLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_
this->AddXLine(x);
if (UplinkSock && Config->AkillOnAdd)
this->Send(x);
this->Send(NULL, x);
return x;
}
@@ -544,7 +536,9 @@ void SGLineManager::Del(XLine *x)
void SGLineManager::OnMatch(User *u, XLine *x)
{
ircdproto->SendAkill(x);
if (u)
kill_user(Config->s_OperServ, u, x->Reason);
ircdproto->SendAkill(u, x);
}
void SGLineManager::OnExpire(XLine *x)
@@ -553,9 +547,9 @@ void SGLineManager::OnExpire(XLine *x)
ircdproto->SendGlobops(OperServ, "AKILL on %s has expired", x->Mask.c_str());
}
void SGLineManager::Send(XLine *x)
void SGLineManager::Send(User *u, XLine *x)
{
ircdproto->SendAkill(x);
ircdproto->SendAkill(u, x);
}
XLine *SNLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_t expires, const Anope::string &reason)
@@ -620,9 +614,12 @@ void SNLineManager::Del(XLine *x)
void SNLineManager::OnMatch(User *u, XLine *x)
{
this->Send(x);
Anope::string reason = "G-Lined: " + x->Reason;
kill_user(Config->s_OperServ, u, reason);
if (u)
{
Anope::string reason = "G-Lined: " + x->Reason;
kill_user(Config->s_OperServ, u, reason);
}
this->Send(u, x);
}
void SNLineManager::OnExpire(XLine *x)
@@ -631,9 +628,9 @@ void SNLineManager::OnExpire(XLine *x)
ircdproto->SendGlobops(OperServ, "SNLINE on \2%s\2 has expired", x->Mask.c_str());
}
void SNLineManager::Send(XLine *x)
void SNLineManager::Send(User *u, XLine *x)
{
ircdproto->SendSGLine(x);
ircdproto->SendSGLine(u, x);
}
XLine *SNLineManager::Check(User *u)
@@ -743,7 +740,7 @@ XLine *SQLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_
}
if (UplinkSock)
this->Send(x);
this->Send(NULL, x);
return x;
}
@@ -755,10 +752,13 @@ void SQLineManager::Del(XLine *x)
void SQLineManager::OnMatch(User *u, XLine *x)
{
ircdproto->SendSQLine(x);
if (u)
{
Anope::string reason = "Q-Lined: " + x->Reason;
kill_user(Config->s_OperServ, u, reason);
}
Anope::string reason = "Q-Lined: " + x->Reason;
kill_user(Config->s_OperServ, u, reason);
ircdproto->SendSQLine(u, x);
}
void SQLineManager::OnExpire(XLine *x)
@@ -767,16 +767,16 @@ void SQLineManager::OnExpire(XLine *x)
ircdproto->SendGlobops(OperServ, "SQLINE on \2%s\2 has expired", x->Mask.c_str());
}
void SQLineManager::Send(XLine *x)
void SQLineManager::Send(User *u, XLine *x)
{
ircdproto->SendSQLine(x);
ircdproto->SendSQLine(u, x);
}
bool SQLineManager::Check(Channel *c)
{
if (ircd->chansqline && SQLine)
{
for (std::vector<XLine *>::const_iterator it = SGLine->GetList().begin(), it_end = SGLine->GetList().end(); it != it_end; ++it)
for (std::vector<XLine *>::const_iterator it = SQLine->GetList().begin(), it_end = SQLine->GetList().end(); it != it_end; ++it)
{
XLine *x = *it;
@@ -831,7 +831,7 @@ XLine *SZLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_
this->AddXLine(x);
if (UplinkSock)
this->Send(x);
this->Send(NULL, x);
return x;
}
@@ -843,7 +843,13 @@ void SZLineManager::Del(XLine *x)
void SZLineManager::OnMatch(User *u, XLine *x)
{
ircdproto->SendSZLine(x);
if (u)
{
Anope::string reason = "Z-Lined: " + x->Reason;
kill_user(Config->s_OperServ, u, reason);
}
ircdproto->SendSZLine(u, x);
}
void SZLineManager::OnExpire(XLine *x)
@@ -852,8 +858,8 @@ void SZLineManager::OnExpire(XLine *x)
ircdproto->SendGlobops(OperServ, "SZLINE on \2%s\2 has expired", x->Mask.c_str());
}
void SZLineManager::Send(XLine *x)
void SZLineManager::Send(User *u, XLine *x)
{
ircdproto->SendSZLine(x);
ircdproto->SendSZLine(u, x);
}