summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-28 21:23:07 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-28 21:23:07 +0000
commit7dbd30b89c18f212041582f6638f2ae1b62a5b4d (patch)
tree093324aa298d1e77ec62f232da94285d6109306a
parente8df3f491d67bc520f808c8b9ebfb54cfc1cce74 (diff)
Update User::exempt all the time we change an E:Line. Brain, can you check I've done this okay, and fix my XXX if you know how? ta.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8416 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/users.h6
-rw-r--r--src/xline.cpp32
2 files changed, 29 insertions, 9 deletions
diff --git a/include/users.h b/include/users.h
index b11d346b7..0cf786c76 100644
--- a/include/users.h
+++ b/include/users.h
@@ -661,11 +661,7 @@ class CoreExport User : public connection
*/
std::string WriteError;
- /** This is true if the user matched an exception when they connected to the ircd.
- * It isnt valid after this point, and you should not attempt to do anything with it
- * after this point, because the eline might be removed at a later time, and/or no
- * longer be applicable to this user. It is only used to save doing the eline lookup
- * twice (instead we do it once and set this value).
+ /** This is true if the user matched an exception (E:Line). It is used to save time on ban checks.
*/
bool exempt;
diff --git a/src/xline.cpp b/src/xline.cpp
index cb905440f..9af297e31 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -189,7 +189,9 @@ bool XLineManager::AddELine(long duration, const char* source, const char* reaso
elines.push_back(item);
sort(elines.begin(), elines.end(),XLineManager::XSortComparison);
- pending_lines.push_back(item);
+
+ // XXX we really only need to check one line (the new one) - this is a bit wasteful!
+ CheckELines(ServerInstance, elines);
return true;
}
@@ -283,8 +285,16 @@ bool XLineManager::DelELine(const char* hostmask, bool simulate)
{
if (!simulate)
{
+ /* remove exempt from everyone and force recheck after deleting eline */
+ for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++)
+ {
+ User* u = (User*)(*u2);
+ u->exempt = false;
+ }
+
delete *i;
elines.erase(i);
+ CheckELines(ServerInstance, elines);
}
return true;
}
@@ -543,8 +553,22 @@ void XLineManager::expire_lines()
}
-// applies lines, removing clients and changing nicks etc as applicable
+void CheckELines(InspIRCd *ServerInstance, const std::vector &ELines)
+{
+ for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++)
+ {
+ User* u = (User*)(*u2);
+ for (std::vector<ELine *>::iterator i = ELines.begin(); i != ELines.end(); i++)
+ {
+ ELine *e = (*i);
+
+ u->exempt = e->Matches(u);
+ }
+ }
+}
+
+// applies lines, removing clients and changing nicks etc as applicable
void XLineManager::ApplyLines()
{
for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++)
@@ -609,7 +633,7 @@ XLineManager::XLineManager(InspIRCd* Instance) : ServerInstance(Instance)
{
}
-bool XLine::Matches(const std::string &str)
+virtual bool Matches(const std::string &str)
{
return false;
}
@@ -695,7 +719,7 @@ void ZLine::Apply(User* u)
bool QLine::Matches(User *u)
{
- if (match(u->nick, this->nick))
+ if (match(user->nick, this->nick))
return true;
return false;