summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-28 18:33:06 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-28 18:33:06 +0000
commit4840d5e77572f42b710501912d59b5dbb6d2c2af (patch)
tree6ff11fbb04dd9a78ae9befdc66bcdb4ea03aa2a4
parentf35e50f35c0174973802721dc6aef980e2eb8196 (diff)
- Tear out a useless load of XLine clutters that did nothing much except confuse things
- Revert back to early 1.0 design of using a single list for line storage. We'll make this work more efficiently than 1.0 though of course. This simplifies the code for expiry, checking, etc. - Merge a bunch of sort callbacks into a single sort callback for class XLine. - Horribly break apply_lines() for the time being. .. and that's probably it. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8398 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/inspircd.h70
-rw-r--r--include/xline.h56
-rw-r--r--src/commands/cmd_gline.cpp5
-rw-r--r--src/commands/cmd_kline.cpp5
-rw-r--r--src/commands/cmd_qline.cpp4
-rw-r--r--src/commands/cmd_zline.cpp5
-rw-r--r--src/modules.cpp54
-rw-r--r--src/modules/m_antibear.cpp11
-rw-r--r--src/modules/m_dnsbl.cpp6
-rw-r--r--src/modules/m_filter.h4
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp20
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp26
-rw-r--r--src/modules/m_spanningtree/utils.cpp2
-rw-r--r--src/modules/m_spanningtree/utils.h5
-rw-r--r--src/userprocess.cpp3
-rw-r--r--src/xline.cpp522
16 files changed, 178 insertions, 620 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 320ac6b29..ee1a5120a 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -795,76 +795,6 @@ class CoreExport InspIRCd : public classbase
*/
bool IsValidModuleCommand(const std::string &commandname, int pcnt, User* user);
- /** Add a gline and apply it
- * @param duration How long the line should last
- * @param source Who set the line
- * @param reason The reason for the line
- * @param hostmask The hostmask to set the line against
- */
- void AddGLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask);
-
- /** Add a qline and apply it
- * @param duration How long the line should last
- * @param source Who set the line
- * @param reason The reason for the line
- * @param nickname The nickmask to set the line against
- */
- void AddQLine(long duration, const std::string &source, const std::string &reason, const std::string &nickname);
-
- /** Add a zline and apply it
- * @param duration How long the line should last
- * @param source Who set the line
- * @param reason The reason for the line
- * @param ipaddr The ip-mask to set the line against
- */
- void AddZLine(long duration, const std::string &source, const std::string &reason, const std::string &ipaddr);
-
- /** Add a kline and apply it
- * @param duration How long the line should last
- * @param source Who set the line
- * @param reason The reason for the line
- * @param hostmask The hostmask to set the line against
- */
- void AddKLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask);
-
- /** Add an eline
- * @param duration How long the line should last
- * @param source Who set the line
- * @param reason The reason for the line
- * @param hostmask The hostmask to set the line against
- */
- void AddELine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask);
-
- /** Delete a gline
- * @param hostmask The gline to delete
- * @return True if the item was removed
- */
- bool DelGLine(const std::string &hostmask);
-
- /** Delete a qline
- * @param nickname The qline to delete
- * @return True if the item was removed
- */
- bool DelQLine(const std::string &nickname);
-
- /** Delete a zline
- * @param ipaddr The zline to delete
- * @return True if the item was removed
- */
- bool DelZLine(const std::string &ipaddr);
-
- /** Delete a kline
- * @param hostmask The kline to delete
- * @return True if the item was removed
- */
- bool DelKLine(const std::string &hostmask);
-
- /** Delete an eline
- * @param hostmask The kline to delete
- * @return True if the item was removed
- */
- bool DelELine(const std::string &hostmask);
-
/** Return true if the given parameter is a valid nick!user\@host mask
* @param mask A nick!user\@host masak to match against
* @return True i the mask is valid
diff --git a/include/xline.h b/include/xline.h
index 5853e13c4..12b60ee6c 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -286,25 +286,9 @@ class CoreExport XLineManager
*/
InspIRCd* ServerInstance;
- /** This functor is used by the std::sort() function to keep glines in order
+ /** This functor is used by the std::sort() function to keep all lines in order
*/
- static bool GSortComparison ( const GLine* one, const GLine* two );
-
- /** This functor is used by the std::sort() function to keep elines in order
- */
- static bool ESortComparison ( const ELine* one, const ELine* two );
-
- /** This functor is used by the std::sort() function to keep zlines in order
- */
- static bool ZSortComparison ( const ZLine* one, const ZLine* two );
-
- /** This functor is used by the std::sort() function to keep klines in order
- */
- static bool KSortComparison ( const KLine* one, const KLine* two );
-
- /** This functor is used by the std::sort() function to keep qlines in order
- */
- static bool QSortComparison ( const QLine* one, const QLine* two );
+ static bool XSortComparison (const XLine *one, const XLine *two);
public:
/* Lists for temporary lines with an expiry time */
@@ -323,23 +307,6 @@ class CoreExport XLineManager
/** Temporary ELines */
std::vector<ELine*> elines;
- /* Seperate lists for perm XLines that isnt checked by expiry functions */
-
- /** Permenant KLines */
- std::vector<KLine*> pklines;
-
- /** Permenant GLines */
- std::vector<GLine*> pglines;
-
- /** Permenant ZLines */
- std::vector<ZLine*> pzlines;
-
- /** Permenant QLines */
- std::vector<QLine*> pqlines;
-
- /** Permenant ELines */
- std::vector<ELine*> pelines;
-
/** Constructor
* @param Instance A pointer to the creator object
*/
@@ -434,42 +401,39 @@ class CoreExport XLineManager
* @return nick The nick to check against
* @return The reason for the line if there is a match, or NULL if there is no match
*/
- QLine* matches_qline(const char* nick, bool permonly = false);
+ QLine* matches_qline(const char* nick);
/** Check if a hostname matches a GLine
* @param user The user to check against
* @return The reason for the line if there is a match, or NULL if there is no match
*/
- GLine* matches_gline(User* user, bool permonly = false);
+ GLine* matches_gline(User* user);
/** Check if a IP matches a ZLine
* @param ipaddr The IP to check against
* @return The reason for the line if there is a match, or NULL if there is no match
*/
- ZLine* matches_zline(const char* ipaddr, bool permonly = false);
+ ZLine* matches_zline(const char* ipaddr);
/** Check if a hostname matches a KLine
* @param user The user to check against
* @return The reason for the line if there is a match, or NULL if there is no match
*/
- KLine* matches_kline(User* user, bool permonly = false);
+ KLine* matches_kline(User* user);
/** Check if a hostname matches a ELine
* @param user The user to check against
* @return The reason for the line if there is a match, or NULL if there is no match
*/
- ELine* matches_exception(User* user, bool permonly = false);
+ ELine* matches_exception(User* user);
- /** Expire any pending non-permenant lines
+ /** Expire any lines that should be expired.
*/
void expire_lines();
- /** Apply any new lines
- * @param What The types of lines to apply, from the set
- * APPLY_GLINES | APPLY_KLINES | APPLY_QLINES | APPLY_ZLINES | APPLY_ALL
- * | APPLY_LOCAL_ONLY
+ /** Apply any new lines that are pending to be applied
*/
- void apply_lines(const int What);
+ void apply_lines();
/** Handle /STATS K
* @param user The username making the query
diff --git a/src/commands/cmd_gline.cpp b/src/commands/cmd_gline.cpp
index 3845c23ee..411df7b14 100644
--- a/src/commands/cmd_gline.cpp
+++ b/src/commands/cmd_gline.cpp
@@ -44,14 +44,11 @@ CmdResult CommandGline::Handle (const char** parameters, int pcnt, User *user)
long duration = ServerInstance->Duration(parameters[1]);
if (ServerInstance->XLines->add_gline(duration,user->nick,parameters[2],parameters[0]))
{
- int to_apply = APPLY_GLINES;
-
FOREACH_MOD(I_OnAddGLine,OnAddGLine(duration, user, parameters[2], parameters[0]));
if (!duration)
{
ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent G-line for %s.",user->nick,parameters[0]);
- to_apply |= APPLY_PERM_ONLY;
}
else
{
@@ -60,7 +57,7 @@ CmdResult CommandGline::Handle (const char** parameters, int pcnt, User *user)
ServerInstance->TimeString(c_requires_crap).c_str());
}
- ServerInstance->XLines->apply_lines(to_apply);
+ ServerInstance->XLines->apply_lines();
}
else
{
diff --git a/src/commands/cmd_kline.cpp b/src/commands/cmd_kline.cpp
index 5edb414ea..521159790 100644
--- a/src/commands/cmd_kline.cpp
+++ b/src/commands/cmd_kline.cpp
@@ -44,14 +44,11 @@ CmdResult CommandKline::Handle (const char** parameters, int pcnt, User *user)
long duration = ServerInstance->Duration(parameters[1]);
if (ServerInstance->XLines->add_kline(duration,user->nick,parameters[2],parameters[0]))
{
- int to_apply = APPLY_KLINES;
-
FOREACH_MOD(I_OnAddKLine,OnAddKLine(duration, user, parameters[2], parameters[0]));
if (!duration)
{
ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent K-line for %s.",user->nick,parameters[0]);
- to_apply |= APPLY_PERM_ONLY;
}
else
{
@@ -60,7 +57,7 @@ CmdResult CommandKline::Handle (const char** parameters, int pcnt, User *user)
ServerInstance->TimeString(c_requires_crap).c_str());
}
- ServerInstance->XLines->apply_lines(to_apply);
+ ServerInstance->XLines->apply_lines();
}
else
{
diff --git a/src/commands/cmd_qline.cpp b/src/commands/cmd_qline.cpp
index 16927d234..01f99546b 100644
--- a/src/commands/cmd_qline.cpp
+++ b/src/commands/cmd_qline.cpp
@@ -38,11 +38,9 @@ CmdResult CommandQline::Handle (const char** parameters, int pcnt, User *user)
long duration = ServerInstance->Duration(parameters[1]);
if (ServerInstance->XLines->add_qline(duration,user->nick,parameters[2],parameters[0]))
{
- int to_apply = APPLY_QLINES;
FOREACH_MOD(I_OnAddQLine,OnAddQLine(duration, user, parameters[2], parameters[0]));
if (!duration)
{
- to_apply |= APPLY_PERM_ONLY;
ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Q-line for %s.",user->nick,parameters[0]);
}
else
@@ -51,7 +49,7 @@ CmdResult CommandQline::Handle (const char** parameters, int pcnt, User *user)
ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Q-line for %s, expires on %s",user->nick,parameters[0],
ServerInstance->TimeString(c_requires_crap).c_str());
}
- ServerInstance->XLines->apply_lines(to_apply);
+ ServerInstance->XLines->apply_lines();
}
else
{
diff --git a/src/commands/cmd_zline.cpp b/src/commands/cmd_zline.cpp
index d6394a7a3..7e5d9b7b2 100644
--- a/src/commands/cmd_zline.cpp
+++ b/src/commands/cmd_zline.cpp
@@ -38,12 +38,9 @@ CmdResult CommandZline::Handle (const char** parameters, int pcnt, User *user)
long duration = ServerInstance->Duration(parameters[1]);
if (ServerInstance->XLines->add_zline(duration,user->nick,parameters[2],parameters[0]))
{
- int to_apply = APPLY_ZLINES;
-
FOREACH_MOD(I_OnAddZLine,OnAddZLine(duration, user, parameters[2], parameters[0]));
if (!duration)
{
- to_apply |= APPLY_PERM_ONLY;
ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Z-line for %s.",user->nick,parameters[0]);
}
else
@@ -52,7 +49,7 @@ CmdResult CommandZline::Handle (const char** parameters, int pcnt, User *user)
ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Z-line for %s, expires on %s",user->nick,parameters[0],
ServerInstance->TimeString(c_requires_crap).c_str());
}
- ServerInstance->XLines->apply_lines(to_apply);
+ ServerInstance->XLines->apply_lines();
}
else
{
diff --git a/src/modules.cpp b/src/modules.cpp
index 85e5d0f03..0c99218a1 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -846,60 +846,6 @@ bool InspIRCd::AddResolver(Resolver* r, bool cached)
}
}
-void InspIRCd::AddGLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask)
-{
- XLines->add_gline(duration, source.c_str(), reason.c_str(), hostmask.c_str());
- XLines->apply_lines(APPLY_GLINES);
-}
-
-void InspIRCd::AddQLine(long duration, const std::string &source, const std::string &reason, const std::string &nickname)
-{
- XLines->add_qline(duration, source.c_str(), reason.c_str(), nickname.c_str());
- XLines->apply_lines(APPLY_QLINES);
-}
-
-void InspIRCd::AddZLine(long duration, const std::string &source, const std::string &reason, const std::string &ipaddr)
-{
- XLines->add_zline(duration, source.c_str(), reason.c_str(), ipaddr.c_str());
- XLines->apply_lines(APPLY_ZLINES);
-}
-
-void InspIRCd::AddKLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask)
-{
- XLines->add_kline(duration, source.c_str(), reason.c_str(), hostmask.c_str());
- XLines->apply_lines(APPLY_KLINES);
-}
-
-void InspIRCd::AddELine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask)
-{
- XLines->add_eline(duration, source.c_str(), reason.c_str(), hostmask.c_str());
-}
-
-bool InspIRCd::DelGLine(const std::string &hostmask)
-{
- return XLines->del_gline(hostmask.c_str());
-}
-
-bool InspIRCd::DelQLine(const std::string &nickname)
-{
- return XLines->del_qline(nickname.c_str());
-}
-
-bool InspIRCd::DelZLine(const std::string &ipaddr)
-{
- return XLines->del_zline(ipaddr.c_str());
-}
-
-bool InspIRCd::DelKLine(const std::string &hostmask)
-{
- return XLines->del_kline(hostmask.c_str());
-}
-
-bool InspIRCd::DelELine(const std::string &hostmask)
-{
- return XLines->del_eline(hostmask.c_str());
-}
-
Module* ModuleManager::Find(const std::string &name)
{
for (int i = 0; i <= this->GetCount(); i++)
diff --git a/src/modules/m_antibear.cpp b/src/modules/m_antibear.cpp
index 5690572ce..3fced6079 100644
--- a/src/modules/m_antibear.cpp
+++ b/src/modules/m_antibear.cpp
@@ -46,12 +46,11 @@ class ModuleAntiBear : public Module
{
if (!strncmp(parameters[1], "\1TIME Mon May 01 18:54:20 2006", 30))
{
- if (ServerInstance->XLines->add_zline(86400, ServerInstance->Config->ServerName, "Unless you're stuck in a time warp, you appear to be a bear bot!", user->MakeHostIP()))
- {
- ServerInstance->XLines->apply_lines(APPLY_ZLINES);
- FOREACH_MOD(I_OnAddGLine,OnAddZLine(86400, NULL, "Unless you're stuck in a time warp, you appear to be a bear bot!", user->MakeHostIP()));
- return 1;
- }
+ ServerInstance->XLines->add_zline(86400, ServerInstance->Config->ServerName, "Unless you're stuck in a time warp, you appear to be a bear bot!", user->GetIPString());
+ // XXX move events into the damn XLineManager stuff
+ FOREACH_MOD(I_OnAddGLine,OnAddZLine(86400, NULL, "Unless you're stuck in a time warp, you appear to be a bear bot!", user->MakeHostIP()));
+ ServerInstance->XLines->apply_lines();
+ return 1;
}
user->Shrink("antibear_timewait");
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp
index c92a2c111..1d99943d5 100644
--- a/src/modules/m_dnsbl.cpp
+++ b/src/modules/m_dnsbl.cpp
@@ -115,7 +115,7 @@ class DNSBLResolver : public Resolver
{
std::string ban = std::string("*@") + them->GetIPString();
if (show)
- ServerInstance->XLines->apply_lines(APPLY_KLINES);
+ ServerInstance->XLines->apply_lines();
show = ServerInstance->XLines->add_kline(ConfEntry->duration, ServerInstance->Config->ServerName, reason.c_str(), ban.c_str());
FOREACH_MOD(I_OnAddKLine,OnAddKLine(ConfEntry->duration, NULL, reason, ban));
break;
@@ -125,7 +125,7 @@ class DNSBLResolver : public Resolver
std::string ban = std::string("*@") + them->GetIPString();
show = ServerInstance->XLines->add_gline(ConfEntry->duration, ServerInstance->Config->ServerName, reason.c_str(), ban.c_str());
if (show)
- ServerInstance->XLines->apply_lines(APPLY_GLINES);
+ ServerInstance->XLines->apply_lines();
FOREACH_MOD(I_OnAddGLine,OnAddGLine(ConfEntry->duration, NULL, reason, ban));
break;
}
@@ -133,7 +133,7 @@ class DNSBLResolver : public Resolver
{
show = ServerInstance->XLines->add_zline(ConfEntry->duration, ServerInstance->Config->ServerName, reason.c_str(), them->GetIPString());
if (show)
- ServerInstance->XLines->apply_lines(APPLY_ZLINES);
+ ServerInstance->XLines->apply_lines();
FOREACH_MOD(I_OnAddZLine,OnAddZLine(ConfEntry->duration, NULL, reason, them->GetIPString()));
break;
}
diff --git a/src/modules/m_filter.h b/src/modules/m_filter.h
index 0f1dc97bd..f88657ee8 100644
--- a/src/modules/m_filter.h
+++ b/src/modules/m_filter.h
@@ -282,7 +282,7 @@ int FilterBase::OnUserPreNotice(User* user,void* dest,int target_type, std::stri
{
if (ServerInstance->XLines->add_gline(f->gline_time, ServerInstance->Config->ServerName, f->reason.c_str(), user->MakeHostIP()))
{
- ServerInstance->XLines->apply_lines(APPLY_GLINES);
+ ServerInstance->XLines->apply_lines();
FOREACH_MOD(I_OnAddGLine,OnAddGLine(f->gline_time, NULL, f->reason, user->MakeHostIP()));
}
}
@@ -370,7 +370,7 @@ int FilterBase::OnPreCommand(const std::string &command, const char** parameters
if (ServerInstance->XLines->add_gline(f->gline_time, ServerInstance->Config->ServerName, f->reason.c_str(), wild.c_str()))
{
- ServerInstance->XLines->apply_lines(APPLY_GLINES);
+ ServerInstance->XLines->apply_lines();
FOREACH_MOD(I_OnAddGLine,OnAddGLine(f->gline_time, NULL, f->reason, user->MakeHostIP()));
}
}
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index d9d44733d..5b79e1aee 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -1238,26 +1238,6 @@ void TreeSocket::SendXLines(TreeServer* Current)
snprintf(data,MAXBUF,":%s ADDLINE E %s@%s %s %lu %lu :%s\r\n",sn,(*i)->identmask,(*i)->hostmask,(*i)->source,(unsigned long)(*i)->set_time,(unsigned long)(*i)->duration,(*i)->reason);
buffer.append(data);
}
- for (std::vector<ZLine*>::iterator i = Instance->XLines->pzlines.begin(); i != Instance->XLines->pzlines.end(); i++)
- {
- snprintf(data,MAXBUF,":%s ADDLINE Z %s %s %lu %lu :%s\r\n",sn,(*i)->ipaddr,(*i)->source,(unsigned long)(*i)->set_time,(unsigned long)(*i)->duration,(*i)->reason);
- buffer.append(data);
- }
- for (std::vector<QLine*>::iterator i = Instance->XLines->pqlines.begin(); i != Instance->XLines->pqlines.end(); i++)
- {
- snprintf(data,MAXBUF,":%s ADDLINE Q %s %s %lu %lu :%s\r\n",sn,(*i)->nick,(*i)->source,(unsigned long)(*i)->set_time,(unsigned long)(*i)->duration,(*i)->reason);
- buffer.append(data);
- }
- for (std::vector<GLine*>::iterator i = Instance->XLines->pglines.begin(); i != Instance->XLines->pglines.end(); i++)
- {
- snprintf(data,MAXBUF,":%s ADDLINE G %s@%s %s %lu %lu :%s\r\n",sn,(*i)->identmask,(*i)->hostmask,(*i)->source,(unsigned long)(*i)->set_time,(unsigned long)(*i)->duration,(*i)->reason);
- buffer.append(data);
- }
- for (std::vector<ELine*>::iterator i = Instance->XLines->pelines.begin(); i != Instance->XLines->pelines.end(); i++)
- {
- snprintf(data,MAXBUF,":%s ADDLINE E %s@%s %s %lu %lu :%s\r\n",sn,(*i)->identmask,(*i)->hostmask,(*i)->source,(unsigned long)(*i)->set_time,(unsigned long)(*i)->duration,(*i)->reason);
- buffer.append(data);
- }
if (!buffer.empty())
this->WriteLine(buffer);
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 01e1316f5..d8eab8a5e 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -522,22 +522,18 @@ bool TreeSocket::AddLine(const std::string &prefix, std::deque<std::string> &par
{
if (params.size() < 6)
return true;
+
bool propogate = false;
- if (!this->bursting)
- Utils->lines_to_apply = 0;
+
switch (*(params[0].c_str()))
{
case 'Z':
propogate = Instance->XLines->add_zline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
Instance->XLines->zline_set_creation_time(params[1].c_str(), atoi(params[3].c_str()));
- if (propogate)
- Utils->lines_to_apply |= APPLY_ZLINES;
break;
case 'Q':
propogate = Instance->XLines->add_qline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
Instance->XLines->qline_set_creation_time(params[1].c_str(), atoi(params[3].c_str()));
- if (propogate)
- Utils->lines_to_apply |= APPLY_QLINES;
break;
case 'E':
propogate = Instance->XLines->add_eline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
@@ -546,13 +542,9 @@ bool TreeSocket::AddLine(const std::string &prefix, std::deque<std::string> &par
case 'G':
propogate = Instance->XLines->add_gline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
Instance->XLines->gline_set_creation_time(params[1].c_str(), atoi(params[3].c_str()));
- if (propogate)
- Utils->lines_to_apply |= APPLY_GLINES;
break;
case 'K':
propogate = Instance->XLines->add_kline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
- if (propogate)
- Utils->lines_to_apply |= APPLY_KLINES;
break;
default:
/* Just in case... */
@@ -575,11 +567,12 @@ bool TreeSocket::AddLine(const std::string &prefix, std::deque<std::string> &par
params[5] = ":" + params[5];
Utils->DoOneToAllButSender(prefix,"ADDLINE",params,prefix);
}
+
if (!this->bursting)
{
- Instance->XLines->apply_lines(Utils->lines_to_apply);
- Utils->lines_to_apply = 0;
+ Instance->XLines->apply_lines();
}
+
return true;
}
@@ -1347,8 +1340,7 @@ bool TreeSocket::ProcessLine(std::string &line)
if (this->bursting)
{
this->bursting = false;
- Instance->XLines->apply_lines(Utils->lines_to_apply);
- Utils->lines_to_apply = 0;
+ Instance->XLines->apply_lines();
}
return this->LocalPing(prefix,params);
@@ -1367,8 +1359,7 @@ bool TreeSocket::ProcessLine(std::string &line)
if (this->bursting)
{
this->bursting = false;
- Instance->XLines->apply_lines(Utils->lines_to_apply);
- Utils->lines_to_apply = 0;
+ Instance->XLines->apply_lines();
}
return this->LocalPong(prefix,params);
@@ -1486,8 +1477,7 @@ bool TreeSocket::ProcessLine(std::string &line)
else if (command == "ENDBURST")
{
this->bursting = false;
- Instance->XLines->apply_lines(Utils->lines_to_apply);
- Utils->lines_to_apply = 0;
+ Instance->XLines->apply_lines();
std::string sourceserv = this->myhost;
if (!this->InboundServerName.empty())
sourceserv = this->InboundServerName;
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index 0376ea0c2..f147a6f79 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -177,8 +177,6 @@ SpanningTreeUtilities::SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningT
{
Bindings.clear();
- lines_to_apply = 0;
-
this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc, ServerInstance->Config->GetSID());
modulelist* ml = ServerInstance->Modules->FindInterface("BufferedSocketHook");
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index 38ddba0ed..d437b998b 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -94,11 +94,6 @@ class SpanningTreeUtilities
/** Holds the data from the <link> tags in the conf
*/
std::vector<Link> LinkBlocks;
- /** Holds a bitmask of queued xline types waiting to be applied.
- * Will be a mask containing values APPLY_GLINES, APPLY_KLINES,
- * APPLY_QLINES and APPLY_ZLINES.
- */
- int lines_to_apply;
/** If this is true, this server is the master sync server for time
* synching - e.g. it is the server with its clock correct. It will
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index eb5ea050c..d2c481fbb 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -26,10 +26,11 @@ void FloodQuitUserHandler::Call(User* current)
current->registered == REG_ALL ? current->nick : "",
current->registered == REG_ALL ? "!" : "", current->ident, current->host);
User::QuitUser(Server, current, "Excess flood");
+
if (current->registered != REG_ALL)
{
Server->XLines->add_zline(120, Server->Config->ServerName, "Flood from unregistered connection", current->GetIPString());
- Server->XLines->apply_lines(APPLY_ZLINES);
+ Server->XLines->apply_lines();
}
}
diff --git a/src/xline.cpp b/src/xline.cpp
index 93c9f795d..4022a27a8 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -17,6 +17,34 @@
#include "wildcard.h"
#include "xline.h"
+/*
+ * This is now version 3 of the XLine subsystem, let's see if we can get it as nice and
+ * efficient as we can this time so we can close this file and never ever touch it again ..
+ *
+ * Background:
+ * Version 1 stored all line types in one list (one for g, one for z, etc). This was fine,
+ * but both version 1 and 2 suck at applying lines efficiently. That is, every time a new line
+ * was added, it iterated every existing line for every existing user. Ow. Expiry was also
+ * expensive, as the lists were NOT sorted.
+ *
+ * Version 2 moved permanent lines into a seperate list from non-permanent to help optimize
+ * matching speed, but matched in the same way.
+ * Expiry was also sped up by sorting the list by expiry (meaning just remove the items at the
+ * head of the list that are outdated.)
+ *
+ * This was fine and good, but it looked less than ideal in code, and matching was still slower
+ * than it could have been, something which we address here.
+ *
+ * VERSION 3:
+ * All lines are (as in v1) stored together -- no seperation of perm and non-perm. Expiry will
+ * still use a sorted list, and we'll just ignore anything permanent.
+ *
+ * Application will be by a list of lines 'pending' application, meaning only the newly added lines
+ * will be gone over. Much faster.
+ *
+ * More of course is to come.
+ */
+
/* Version two, now with optimized expiry!
*
* Because the old way was horrendously slow, the new way of expiring xlines is very
@@ -42,25 +70,29 @@ bool InitXLine(ServerConfig* conf, const char* tag)
bool DoneZLine(ServerConfig* conf, const char* tag)
{
- conf->GetInstance()->XLines->apply_lines(APPLY_ZLINES|APPLY_PERM_ONLY);
+ // XXX we should really only call this once - after we've finished processing configuration all together
+ conf->GetInstance()->XLines->apply_lines();
return true;
}
bool DoneQLine(ServerConfig* conf, const char* tag)
{
- conf->GetInstance()->XLines->apply_lines(APPLY_QLINES|APPLY_PERM_ONLY);
+ // XXX we should really only call this once - after we've finished processing configuration all together
+ conf->GetInstance()->XLines->apply_lines();
return true;
}
bool DoneKLine(ServerConfig* conf, const char* tag)
{
- conf->GetInstance()->XLines->apply_lines(APPLY_KLINES|APPLY_PERM_ONLY);
+ // XXX we should really only call this once - after we've finished processing configuration all together
+ conf->GetInstance()->XLines->apply_lines();
return true;
}
bool DoneELine(ServerConfig* conf, const char* tag)
{
- /* Yes, this is supposed to do nothing, we dont 'apply' these */
+ // XXX we should really only call this once - after we've finished processing configuration all together
+ conf->GetInstance()->XLines->apply_lines();
return true;
}
@@ -132,15 +164,8 @@ bool XLineManager::add_gline(long duration, const char* source,const char* reaso
GLine* item = new GLine(ServerInstance->Time(), duration, source, reason, ih.first.c_str(), ih.second.c_str());
- if (duration)
- {
- glines.push_back(item);
- sort(glines.begin(), glines.end(),XLineManager::GSortComparison);
- }
- else
- {
- pglines.push_back(item);
- }
+ glines.push_back(item);
+ sort(glines.begin(), glines.end(),XLineManager::XSortComparison);
return true;
}
@@ -156,15 +181,9 @@ bool XLineManager::add_eline(long duration, const char* source, const char* reas
ELine* item = new ELine(ServerInstance->Time(), duration, source, reason, ih.first.c_str(), ih.second.c_str());
- if (duration)
- {
- elines.push_back(item);
- sort(elines.begin(), elines.end(),XLineManager::ESortComparison);
- }
- else
- {
- pelines.push_back(item);
- }
+ elines.push_back(item);
+ sort(elines.begin(), elines.end(),XLineManager::XSortComparison);
+
return true;
}
@@ -177,15 +196,9 @@ bool XLineManager::add_qline(long duration, const char* source, const char* reas
QLine* item = new QLine(ServerInstance->Time(), duration, source, reason, nickname);
- if (duration)
- {
- qlines.push_back(item);
- sort(qlines.begin(), qlines.end(),XLineManager::QSortComparison);
- }
- else
- {
- pqlines.push_back(item);
- }
+ qlines.push_back(item);
+ sort(qlines.begin(), qlines.end(),XLineManager::XSortComparison);
+
return true;
}
@@ -205,15 +218,9 @@ bool XLineManager::add_zline(long duration, const char* source, const char* reas
ZLine* item = new ZLine(ServerInstance->Time(), duration, source, reason, ipaddr);
- if (duration)
- {
- zlines.push_back(item);
- sort(zlines.begin(), zlines.end(),XLineManager::ZSortComparison);
- }
- else
- {
- pzlines.push_back(item);
- }
+ zlines.push_back(item);
+ sort(zlines.begin(), zlines.end(),XLineManager::XSortComparison);
+
return true;
}
@@ -228,15 +235,9 @@ bool XLineManager::add_kline(long duration, const char* source, const char* reas
KLine* item = new KLine(ServerInstance->Time(), duration, source, reason, ih.first.c_str(), ih.second.c_str());
- if (duration)
- {
- klines.push_back(item);
- sort(klines.begin(), klines.end(),XLineManager::KSortComparison);
- }
- else
- {
- pklines.push_back(item);
- }
+ klines.push_back(item);
+ sort(klines.begin(), klines.end(),XLineManager::XSortComparison);
+
return true;
}
@@ -257,18 +258,7 @@ bool XLineManager::del_gline(const char* hostmask, bool simulate)
return true;
}
}
- for (std::vector<GLine*>::iterator i = pglines.begin(); i != pglines.end(); i++)
- {
- if (!strcasecmp(ih.first.c_str(),(*i)->identmask) && !strcasecmp(ih.second.c_str(),(*i)->hostmask))
- {
- if (!simulate)
- {
- delete *i;
- pglines.erase(i);
- }
- return true;
- }
- }
+
return false;
}
@@ -289,18 +279,7 @@ bool XLineManager::del_eline(const char* hostmask, bool simulate)
return true;
}
}
- for (std::vector<ELine*>::iterator i = pelines.begin(); i != pelines.end(); i++)
- {
- if (!strcasecmp(ih.first.c_str(),(*i)->identmask) && !strcasecmp(ih.second.c_str(),(*i)->hostmask))
- {
- if (!simulate)
- {
- delete *i;
- pelines.erase(i);
- }
- return true;
- }
- }
+
return false;
}
@@ -320,18 +299,7 @@ bool XLineManager::del_qline(const char* nickname, bool simulate)
return true;
}
}
- for (std::vector<QLine*>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
- {
- if (!strcasecmp(nickname,(*i)->nick))
- {
- if (!simulate)
- {
- delete *i;
- pqlines.erase(i);
- }
- return true;
- }
- }
+
return false;
}
@@ -351,18 +319,7 @@ bool XLineManager::del_zline(const char* ipaddr, bool simulate)
return true;
}
}
- for (std::vector<ZLine*>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
- {
- if (!strcasecmp(ipaddr,(*i)->ipaddr))
- {
- if (!simulate)
- {
- delete *i;
- pzlines.erase(i);
- }
- return true;
- }
- }
+
return false;
}
@@ -383,34 +340,18 @@ bool XLineManager::del_kline(const char* hostmask, bool simulate)
return true;
}
}
- for (std::vector<KLine*>::iterator i = pklines.begin(); i != pklines.end(); i++)
- {
- if (!strcasecmp(ih.first.c_str(),(*i)->identmask) && !strcasecmp(ih.second.c_str(),(*i)->hostmask))
- {
- if (!simulate)
- {
- delete *i;
- pklines.erase(i);
- }
- return true;
- }
- }
+
return false;
}
// returns a pointer to the reason if a nickname matches a qline, NULL if it didnt match
-QLine* XLineManager::matches_qline(const char* nick, bool permonly)
+QLine* XLineManager::matches_qline(const char* nick)
{
- if ((qlines.empty()) && (pqlines.empty()))
+ if (qlines.empty())
return NULL;
- if (!permonly)
- {
- for (std::vector<QLine*>::iterator i = qlines.begin(); i != qlines.end(); i++)
- if (match(nick,(*i)->nick))
- return (*i);
- }
- for (std::vector<QLine*>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
+
+ for (std::vector<QLine*>::iterator i = qlines.begin(); i != qlines.end(); i++)
if (match(nick,(*i)->nick))
return (*i);
return NULL;
@@ -418,24 +359,12 @@ QLine* XLineManager::matches_qline(const char* nick, bool permonly)
// returns a pointer to the reason if a host matches a gline, NULL if it didnt match
-GLine* XLineManager::matches_gline(User* user, bool permonly)
+GLine* XLineManager::matches_gline(User* user)
{
- if ((glines.empty()) && (pglines.empty()))
+ if (glines.empty())
return NULL;
- if (!permonly)
- {
- for (std::vector<GLine*>::iterator i = glines.begin(); i != glines.end(); i++)
- {
- if ((match(user->ident,(*i)->identmask)))
- {
- if ((match(user->host,(*i)->hostmask, true)) || (match(user->GetIPString(),(*i)->hostmask, true)))
- {
- return (*i);
- }
- }
- }
- }
- for (std::vector<GLine*>::iterator i = pglines.begin(); i != pglines.end(); i++)
+
+ for (std::vector<GLine*>::iterator i = glines.begin(); i != glines.end(); i++)
{
if ((match(user->ident,(*i)->identmask)))
{
@@ -445,29 +374,18 @@ GLine* XLineManager::matches_gline(User* user, bool permonly)
}
}
}
+
return NULL;
}
-ELine* XLineManager::matches_exception(User* user, bool permonly)
+ELine* XLineManager::matches_exception(User* user)
{
- if ((elines.empty()) && (pelines.empty()))
+ if (elines.empty())
return NULL;
char host2[MAXBUF];
+
snprintf(host2,MAXBUF,"*@%s",user->host);
- if (!permonly)
- {
- for (std::vector<ELine*>::iterator i = elines.begin(); i != elines.end(); i++)
- {
- if ((match(user->ident,(*i)->identmask)))
- {
- if ((match(user->host,(*i)->hostmask, true)) || (match(user->GetIPString(),(*i)->hostmask, true)))
- {
- return (*i);
- }
- }
- }
- }
- for (std::vector<ELine*>::iterator i = pelines.begin(); i != pelines.end(); i++)
+ for (std::vector<ELine*>::iterator i = elines.begin(); i != elines.end(); i++)
{
if ((match(user->ident,(*i)->identmask)))
{
@@ -492,14 +410,7 @@ void XLineManager::gline_set_creation_time(const char* host, time_t create_time)
return;
}
}
- for (std::vector<GLine*>::iterator i = pglines.begin(); i != pglines.end(); i++)
- {
- if (!strcasecmp(host,(*i)->hostmask))
- {
- (*i)->set_time = create_time;
- return;
- }
- }
+
return ;
}
@@ -514,14 +425,7 @@ void XLineManager::eline_set_creation_time(const char* host, time_t create_time)
return;
}
}
- for (std::vector<ELine*>::iterator i = pelines.begin(); i != pelines.end(); i++)
- {
- if (!strcasecmp(host,(*i)->hostmask))
- {
- (*i)->set_time = create_time;
- return;
- }
- }
+
return;
}
@@ -536,14 +440,7 @@ void XLineManager::qline_set_creation_time(const char* nick, time_t create_time)
return;
}
}
- for (std::vector<QLine*>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
- {
- if (!strcasecmp(nick,(*i)->nick))
- {
- (*i)->set_time = create_time;
- return;
- }
- }
+
return;
}
@@ -558,30 +455,18 @@ void XLineManager::zline_set_creation_time(const char* ip, time_t create_time)
return;
}
}
- for (std::vector<ZLine*>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
- {
- if (!strcasecmp(ip,(*i)->ipaddr))
- {
- (*i)->set_time = create_time;
- return;
- }
- }
+
return;
}
// returns a pointer to the reason if an ip address matches a zline, NULL if it didnt match
-ZLine* XLineManager::matches_zline(const char* ipaddr, bool permonly)
+ZLine* XLineManager::matches_zline(const char* ipaddr)
{
- if ((zlines.empty()) && (pzlines.empty()))
+ if (zlines.empty())
return NULL;
- if (!permonly)
- {
- for (std::vector<ZLine*>::iterator i = zlines.begin(); i != zlines.end(); i++)
- if (match(ipaddr,(*i)->ipaddr, true))
- return (*i);
- }
- for (std::vector<ZLine*>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
+
+ for (std::vector<ZLine*>::iterator i = zlines.begin(); i != zlines.end(); i++)
if (match(ipaddr,(*i)->ipaddr, true))
return (*i);
return NULL;
@@ -589,24 +474,12 @@ ZLine* XLineManager::matches_zline(const char* ipaddr, bool permonly)
// returns a pointer to the reason if a host matches a kline, NULL if it didnt match
-KLine* XLineManager::matches_kline(User* user, bool permonly)
+KLine* XLineManager::matches_kline(User* user)
{
- if ((klines.empty()) && (pklines.empty()))
+ if (klines.empty())
return NULL;
- if (!permonly)
- {
- for (std::vector<KLine*>::iterator i = klines.begin(); i != klines.end(); i++)
- {
- if ((match(user->ident,(*i)->identmask)))
- {
- if ((match(user->host,(*i)->hostmask, true)) || (match(user->GetIPString(),(*i)->hostmask, true)))
- {
- return (*i);
- }
- }
- }
- }
- for (std::vector<KLine*>::iterator i = pklines.begin(); i != pklines.end(); i++)
+
+ for (std::vector<KLine*>::iterator i = klines.begin(); i != klines.end(); i++)
{
if ((match(user->ident,(*i)->identmask)))
{
@@ -616,36 +489,21 @@ KLine* XLineManager::matches_kline(User* user, bool permonly)
}
}
}
- return NULL;
-}
-bool XLineManager::GSortComparison ( const GLine* one, const GLine* two )
-{
- return (one->expiry) < (two->expiry);
-}
-
-bool XLineManager::ESortComparison ( const ELine* one, const ELine* two )
-{
- return (one->expiry) < (two->expiry);
-}
-
-bool XLineManager::ZSortComparison ( const ZLine* one, const ZLine* two )
-{
- return (one->expiry) < (two->expiry);
-}
-
-bool XLineManager::KSortComparison ( const KLine* one, const KLine* two )
-{
- return (one->expiry) < (two->expiry);
+ return NULL;
}
-bool XLineManager::QSortComparison ( const QLine* one, const QLine* two )
+bool XLineManager::XSortComparison(const XLine *one, const XLine *two)
{
+ // account for permanent lines
+ if (one->expiry == 0)
+ {
+ return false;
+ }
return (one->expiry) < (two->expiry);
}
// removes lines that have expired
-
void XLineManager::expire_lines()
{
time_t current = ServerInstance->Time();
@@ -655,35 +513,35 @@ void XLineManager::expire_lines()
* none left at the head of the queue that are after the current time.
*/
- while ((glines.size()) && (current > (*glines.begin())->expiry))
+ while ((glines.size()) && (current > (*glines.begin())->expiry) && ((*glines.begin())->duration != 0))
{
std::vector<GLine*>::iterator i = glines.begin();
ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed G-Line %s@%s (set by %s %d seconds ago)",(*i)->identmask,(*i)->hostmask,(*i)->source,(*i)->duration);
glines.erase(i);
}
- while ((elines.size()) && (current > (*elines.begin())->expiry))
+ while ((elines.size()) && (current > (*elines.begin())->expiry) && ((*elines.begin())->duration != 0))
{
std::vector<ELine*>::iterator i = elines.begin();
ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed E-Line %s@%s (set by %s %d seconds ago)",(*i)->identmask,(*i)->hostmask,(*i)->source,(*i)->duration);
elines.erase(i);
}
- while ((zlines.size()) && (current > (*zlines.begin())->expiry))
+ while ((zlines.size()) && (current > (*zlines.begin())->expiry) && ((*zlines.begin())->duration != 0))
{
std::vector<ZLine*>::iterator i = zlines.begin();
ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed Z-Line %s (set by %s %d seconds ago)",(*i)->ipaddr,(*i)->source,(*i)->duration);
zlines.erase(i);
}
- while ((klines.size()) && (current > (*klines.begin())->expiry))
+ while ((klines.size()) && (current > (*klines.begin())->expiry) && ((*klines.begin())->duration != 0))
{
std::vector<KLine*>::iterator i = klines.begin();
ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed K-Line %s@%s (set by %s %d seconds ago)",(*i)->identmask,(*i)->hostmask,(*i)->source,(*i)->duration);
klines.erase(i);
}
- while ((qlines.size()) && (current > (*qlines.begin())->expiry))
+ while ((qlines.size()) && (current > (*qlines.begin())->expiry) && ((*qlines.begin())->duration != 0))
{
std::vector<QLine*>::iterator i = qlines.begin();
ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed Q-Line %s (set by %s %d seconds ago)",(*i)->nick,(*i)->source,(*i)->duration);
@@ -694,154 +552,72 @@ void XLineManager::expire_lines()
// applies lines, removing clients and changing nicks etc as applicable
-void XLineManager::apply_lines(const int What)
+void XLineManager::apply_lines()
{
- if (!What)
- return;
+ int What = 0; // XXX remove me
+ char reason[MAXBUF];
- if (What & APPLY_PERM_ONLY)
+ XLine* check = NULL;
+ for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++)
{
- char reason[MAXBUF];
+ User* u = (User*)(*u2);
- if ((!pglines.size()) && (!pklines.size()) && (!pzlines.size()) && (!pqlines.size()))
- return;
-
- XLine* check = NULL;
- for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++)
+ if (elines.size())
{
- User* u = (User*)(*u2);
-
- if (elines.size() || pelines.size())
- if (matches_exception(u))
- continue;
-
- if ((What & APPLY_GLINES) && pglines.size())
- {
- if ((check = matches_gline(u,true)))
- {
- snprintf(reason,MAXBUF,"G-Lined: %s",check->reason);
- if (*ServerInstance->Config->MoronBanner)
- u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner);
- if (ServerInstance->Config->HideBans)
- User::QuitUser(ServerInstance, u, "G-Lined", reason);
- else
- User::QuitUser(ServerInstance, u, reason);
- }
- }
-
- if ((What & APPLY_KLINES) && pklines.size())
- {
- if ((check = matches_kline(u,true)))
- {
- snprintf(reason,MAXBUF,"K-Lined: %s",check->reason);
- if (*ServerInstance->Config->MoronBanner)
- u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner);
- if (ServerInstance->Config->HideBans)
- User::QuitUser(ServerInstance, u, "K-Lined", reason);
- else
- User::QuitUser(ServerInstance, u, reason);
- }
- }
-
- if ((What & APPLY_QLINES) && pqlines.size())
- {
- if ((check = matches_qline(u->nick,true)))
- {
- snprintf(reason,MAXBUF,"Q-Lined: %s",check->reason);
- if (*ServerInstance->Config->MoronBanner)
- u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner);
- if (ServerInstance->Config->HideBans)
- User::QuitUser(ServerInstance, u, "Q-Lined", reason);
- else
- User::QuitUser(ServerInstance, u, reason);
- }
- }
-
- if ((What & APPLY_ZLINES) && pzlines.size())
- {
- if ((check = matches_zline(u->GetIPString(),true)))
- {
- snprintf(reason,MAXBUF,"Z-Lined: %s",check->reason);
- if (*ServerInstance->Config->MoronBanner)
- u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner);
- if (ServerInstance->Config->HideBans)
- User::QuitUser(ServerInstance, u, "Z-Lined", reason);
- else
- User::QuitUser(ServerInstance, u, reason);
- }
- }
+ // ignore people matching exempts
+ if (matches_exception(u))
+ continue;
}
- }
- else
- {
- char reason[MAXBUF];
-
- if ((!glines.size()) && (!klines.size()) && (!zlines.size()) && (!qlines.size()) &&
- (!pglines.size()) && (!pklines.size()) && (!pzlines.size()) && (!pqlines.size()))
- return;
-
- XLine* check = NULL;
- for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++)
+ if ((What & APPLY_GLINES) && (glines.size()))
{
- User* u = (User*)(*u2);
-
- if (elines.size() || pelines.size())
+ if ((check = matches_gline(u)))
{
- // ignore people matching exempts
- if (matches_exception(u))
- continue;
+ snprintf(reason,MAXBUF,"G-Lined: %s",check->reason);
+ if (*ServerInstance->Config->MoronBanner)
+ u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner);
+ if (ServerInstance->Config->HideBans)
+ User::QuitUser(ServerInstance, u, "G-Lined", reason);
+ else
+ User::QuitUser(ServerInstance, u, reason);
}
- if ((What & APPLY_GLINES) && (glines.size() || pglines.size()))
- {
- if ((check = matches_gline(u)))
- {
- snprintf(reason,MAXBUF,"G-Lined: %s",check->reason);
- if (*ServerInstance->Config->MoronBanner)
- u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner);
- if (ServerInstance->Config->HideBans)
- User::QuitUser(ServerInstance, u, "G-Lined", reason);
- else
- User::QuitUser(ServerInstance, u, reason);
- }
- }
- if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
+ }
+ if ((What & APPLY_KLINES) && (klines.size()))
+ {
+ if ((check = matches_kline(u)))
{
- if ((check = matches_kline(u)))
- {
- snprintf(reason,MAXBUF,"K-Lined: %s",check->reason);
- if (*ServerInstance->Config->MoronBanner)
- u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner);
- if (ServerInstance->Config->HideBans)
- User::QuitUser(ServerInstance, u, "K-Lined", reason);
- else
- User::QuitUser(ServerInstance, u, reason);
- }
+ snprintf(reason,MAXBUF,"K-Lined: %s",check->reason);
+ if (*ServerInstance->Config->MoronBanner)
+ u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner);
+ if (ServerInstance->Config->HideBans)
+ User::QuitUser(ServerInstance, u, "K-Lined", reason);
+ else
+ User::QuitUser(ServerInstance, u, reason);
}
- if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
+ }
+ if ((What & APPLY_QLINES) && (qlines.size()))
+ {
+ if ((check = matches_qline(u->nick)))
{
- if ((check = matches_qline(u->nick)))
- {
- snprintf(reason,MAXBUF,"Q-Lined: %s",check->reason);
- if (*ServerInstance->Config->MoronBanner)
- u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner);
- if (ServerInstance->Config->HideBans)
- User::QuitUser(ServerInstance, u, "Q-Lined", reason);
- else
- User::QuitUser(ServerInstance, u, reason);
- }
+ snprintf(reason,MAXBUF,"Q-Lined: %s",check->reason);
+ if (*ServerInstance->Config->MoronBanner)
+ u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner);
+ if (ServerInstance->Config->HideBans)
+ User::QuitUser(ServerInstance, u, "Q-Lined", reason);
+ else
+ User::QuitUser(ServerInstance, u, reason);
}
- if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
+ }
+ if ((What & APPLY_ZLINES) && (zlines.size()))
+ {
+ if ((check = matches_zline(u->GetIPString())))
{
- if ((check = matches_zline(u->GetIPString())))
- {
- snprintf(reason,MAXBUF,"Z-Lined: %s", check->reason);
- if (*ServerInstance->Config->MoronBanner)
- u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner);
- if (ServerInstance->Config->HideBans)
- User::QuitUser(ServerInstance, u, "Z-Lined", reason);
- else
- User::QuitUser(ServerInstance, u, reason);
- }
+ snprintf(reason,MAXBUF,"Z-Lined: %s", check->reason);
+ if (*ServerInstance->Config->MoronBanner)
+ u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner);
+ if (ServerInstance->Config->HideBans)
+ User::QuitUser(ServerInstance, u, "Z-Lined", reason);
+ else
+ User::QuitUser(ServerInstance, u, reason);
}
}
}
@@ -852,8 +628,6 @@ void XLineManager::stats_k(User* user, string_list &results)
std::string sn = ServerInstance->Config->ServerName;
for (std::vector<KLine*>::iterator i = klines.begin(); i != klines.end(); i++)
results.push_back(sn+" 216 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
- for (std::vector<KLine*>::iterator i = pklines.begin(); i != pklines.end(); i++)
- results.push_back(sn+" 216 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
}
void XLineManager::stats_g(User* user, string_list &results)
@@ -861,8 +635,6 @@ void XLineManager::stats_g(User* user, string_list &results)
std::string sn = ServerInstance->Config->ServerName;
for (std::vector<GLine*>::iterator i = glines.begin(); i != glines.end(); i++)
results.push_back(sn+" 223 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
- for (std::vector<GLine*>::iterator i = pglines.begin(); i != pglines.end(); i++)
- results.push_back(sn+" 223 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
}
void XLineManager::stats_q(User* user, string_list &results)
@@ -870,8 +642,6 @@ void XLineManager::stats_q(User* user, string_list &results)
std::string sn = ServerInstance->Config->ServerName;
for (std::vector<QLine*>::iterator i = qlines.begin(); i != qlines.end(); i++)
results.push_back(sn+" 217 "+user->nick+" :"+(*i)->nick+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
- for (std::vector<QLine*>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
- results.push_back(sn+" 217 "+user->nick+" :"+(*i)->nick+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
}
void XLineManager::stats_z(User* user, string_list &results)
@@ -879,8 +649,6 @@ void XLineManager::stats_z(User* user, string_list &results)
std::string sn = ServerInstance->Config->ServerName;
for (std::vector<ZLine*>::iterator i = zlines.begin(); i != zlines.end(); i++)
results.push_back(sn+" 223 "+user->nick+" :"+(*i)->ipaddr+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
- for (std::vector<ZLine*>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
- results.push_back(sn+" 223 "+user->nick+" :"+(*i)->ipaddr+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
}
void XLineManager::stats_e(User* user, string_list &results)
@@ -888,8 +656,6 @@ void XLineManager::stats_e(User* user, string_list &results)
std::string sn = ServerInstance->Config->ServerName;
for (std::vector<ELine*>::iterator i = elines.begin(); i != elines.end(); i++)
results.push_back(sn+" 223 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
- for (std::vector<ELine*>::iterator i = pelines.begin(); i != pelines.end(); i++)
- results.push_back(sn+" 223 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
}
XLineManager::XLineManager(InspIRCd* Instance) : ServerInstance(Instance)