summaryrefslogtreecommitdiff
path: root/src/xline.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-29 00:35:17 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-29 00:35:17 +0000
commitb253374745d237924c9478ec94ffa333c5492ed1 (patch)
treebcd03f1411533779379d0af4da10a41e7d13a68c /src/xline.cpp
parent145f7fbe605785a76a78f57982d5d24ddaee2bf3 (diff)
Add the lookup_lines stuff. Sorry i havent documented this yet, i am tired.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8422 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/xline.cpp')
-rw-r--r--src/xline.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/xline.cpp b/src/xline.cpp
index bfa21b21d..072320555 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -138,15 +138,18 @@ bool XLine::Matches(User *u)
}
//XXX perhaps move into xlinemanager
-void CheckELines(InspIRCd *ServerInstance, std::map<std::string, ELine *> &ELines)
+void CheckELines(InspIRCd *ServerInstance, std::map<std::string, XLine *> &ELines)
{
+ if (ELines.empty())
+ return;
+
for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++)
{
User* u = (User*)(*u2);
- for (std::map<std::string, ELine *>::iterator i = ELines.begin(); i != ELines.end(); i++)
+ for (std::map<std::string, XLine *>::iterator i = ELines.begin(); i != ELines.end(); i++)
{
- ELine *e = i->second;
+ XLine *e = i->second;
u->exempt = e->Matches(u);
}
}
@@ -188,6 +191,7 @@ bool XLineManager::AddGLine(long duration, const char* source,const char* reason
active_lines.push_back(item);
sort(active_lines.begin(), active_lines.end(),XLineManager::XSortComparison);
pending_lines.push_back(item);
+ lookup_lines['G'][hostmask] = item;
return true;
}
@@ -225,6 +229,7 @@ bool XLineManager::AddQLine(long duration, const char* source, const char* reaso
active_lines.push_back(item);
sort(active_lines.begin(), active_lines.end(), XLineManager::XSortComparison);
pending_lines.push_back(item);
+ lookup_lines['Q'][nickname] = item;
return true;
}
@@ -248,6 +253,7 @@ bool XLineManager::AddZLine(long duration, const char* source, const char* reaso
active_lines.push_back(item);
sort(active_lines.begin(), active_lines.end(),XLineManager::XSortComparison);
pending_lines.push_back(item);
+ lookup_lines['Z'][ipaddr] = item;
return true;
}
@@ -266,6 +272,7 @@ bool XLineManager::AddKLine(long duration, const char* source, const char* reaso
active_lines.push_back(item);
sort(active_lines.begin(), active_lines.end(),XLineManager::XSortComparison);
pending_lines.push_back(item);
+ lookup_lines['K'][hostmask] = item;
return true;
}
@@ -286,6 +293,8 @@ bool XLineManager::DelLine(const char* hostmask, char type, bool simulate)
(*i)->Unset();
delete *i;
active_lines.erase(i);
+ if (lookup_lines.find(type) != lookup_lines.end())
+ lookup_lines[type].erase(hostmask);
/* XXX: Should erase from pending lines here */
}
return true;
@@ -305,14 +314,18 @@ void ELine::Unset()
User* u = (User*)(*u2);
u->exempt = false;
}
- ServerInstance->XLines->lookup_lines['E'].erase(this->identmask + std::string("@") + this->hostmask);
- CheckELines(ServerInstance, ServerInstance->XLines->lookup_lines['E']);
+
+ if (ServerInstance->XLines->lookup_lines.find('E') != ServerInstance->XLines->lookup_lines.end())
+ CheckELines(ServerInstance, ServerInstance->XLines->lookup_lines['E']);
}
// returns a pointer to the reason if a nickname matches a qline, NULL if it didnt match
QLine* XLineManager::matches_qline(const char* nick)
{
+ if (lookup_lines.find('Q') != lookup_lines.end() && lookup_lines['Q'].empty())
+ return NULL;
+
for (std::vector<XLine*>::iterator i = active_lines.begin(); i != active_lines.end(); i++)
if ((*i)->type == 'Q' && (*i)->Matches(nick))
return (QLine*)(*i);
@@ -323,6 +336,9 @@ QLine* XLineManager::matches_qline(const char* nick)
GLine* XLineManager::matches_gline(User* user)
{
+ if (lookup_lines.find('G') != lookup_lines.end() && lookup_lines['G'].empty())
+ return NULL;
+
for (std::vector<XLine*>::iterator i = active_lines.begin(); i != active_lines.end(); i++)
if ((*i)->type == 'G' && (*i)->Matches(user))
return (GLine*)(*i);
@@ -332,7 +348,7 @@ GLine* XLineManager::matches_gline(User* user)
ELine* XLineManager::matches_exception(User* user)
{
- if (lookup_lines['E'].empty())
+ if (lookup_lines.find('E') != lookup_lines.end() && lookup_lines['E'].empty())
return NULL;
for (std::vector<XLine*>::iterator i = active_lines.begin(); i != active_lines.end(); i++)
@@ -408,6 +424,9 @@ void XLineManager::zline_set_creation_time(const char* ip, time_t create_time)
ZLine* XLineManager::matches_zline(User *u)
{
+ if (lookup_lines.find('Z') != lookup_lines.end() && lookup_lines['Z'].empty())
+ return NULL;
+
for (std::vector<XLine*>::iterator i = active_lines.begin(); i != active_lines.end(); i++)
if ((*i)->type == 'Z' && (*i)->Matches(u))
return (ZLine*)(*i);
@@ -418,6 +437,9 @@ ZLine* XLineManager::matches_zline(User *u)
KLine* XLineManager::matches_kline(User* user)
{
+ if (lookup_lines.find('K') != lookup_lines.end() && lookup_lines['K'].empty())
+ return NULL;
+
for (std::vector<XLine*>::iterator i = active_lines.begin(); i != active_lines.end(); i++)
if ((*i)->Matches(user))
return (KLine*)(*i);