summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands/cmd_eline.cpp2
-rw-r--r--src/commands/cmd_gline.cpp2
-rw-r--r--src/commands/cmd_kline.cpp2
-rw-r--r--src/commands/cmd_nick.cpp2
-rw-r--r--src/commands/cmd_qline.cpp2
-rw-r--r--src/commands/cmd_rehash.cpp2
-rw-r--r--src/commands/cmd_stats.cpp6
-rw-r--r--src/commands/cmd_zline.cpp2
-rw-r--r--src/configreader.cpp2
-rw-r--r--src/inspircd.cpp2
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp8
-rw-r--r--src/users.cpp10
-rw-r--r--src/xline.cpp106
13 files changed, 61 insertions, 87 deletions
diff --git a/src/commands/cmd_eline.cpp b/src/commands/cmd_eline.cpp
index cd0627178..83c921d8b 100644
--- a/src/commands/cmd_eline.cpp
+++ b/src/commands/cmd_eline.cpp
@@ -60,7 +60,7 @@ CmdResult CommandEline::Handle (const char** parameters, int pcnt, User *user)
}
else
{
- if (ServerInstance->XLines->DelLine(parameters[0], 'E', user))
+ if (ServerInstance->XLines->DelLine(parameters[0], "E", user))
{
ServerInstance->SNO->WriteToSnoMask('x',"%s Removed E-line on %s.",user->nick,parameters[0]);
}
diff --git a/src/commands/cmd_gline.cpp b/src/commands/cmd_gline.cpp
index abe29d18e..caed54ebe 100644
--- a/src/commands/cmd_gline.cpp
+++ b/src/commands/cmd_gline.cpp
@@ -67,7 +67,7 @@ CmdResult CommandGline::Handle (const char** parameters, int pcnt, User *user)
}
else
{
- if (ServerInstance->XLines->DelLine(parameters[0],'G',user))
+ if (ServerInstance->XLines->DelLine(parameters[0],"G",user))
{
ServerInstance->SNO->WriteToSnoMask('x',"%s Removed G-line on %s.",user->nick,parameters[0]);
}
diff --git a/src/commands/cmd_kline.cpp b/src/commands/cmd_kline.cpp
index de225b0f0..7058de77f 100644
--- a/src/commands/cmd_kline.cpp
+++ b/src/commands/cmd_kline.cpp
@@ -66,7 +66,7 @@ CmdResult CommandKline::Handle (const char** parameters, int pcnt, User *user)
}
else
{
- if (ServerInstance->XLines->DelLine(parameters[0],'K',user))
+ if (ServerInstance->XLines->DelLine(parameters[0],"K",user))
{
ServerInstance->SNO->WriteToSnoMask('x',"%s Removed K-line on %s.",user->nick,parameters[0]);
}
diff --git a/src/commands/cmd_nick.cpp b/src/commands/cmd_nick.cpp
index aaa6698ac..06fc5dcc3 100644
--- a/src/commands/cmd_nick.cpp
+++ b/src/commands/cmd_nick.cpp
@@ -60,7 +60,7 @@ CmdResult CommandNick::Handle (const char** parameters, int, User *user)
}
else
{
- XLine* mq = ServerInstance->XLines->MatchesLine('Q',parameters[0]);
+ XLine* mq = ServerInstance->XLines->MatchesLine("Q",parameters[0]);
if (mq)
{
ServerInstance->SNO->WriteToSnoMask('x', "Q-Lined nickname %s from %s!%s@%s: %s", parameters[0], user->nick, user->ident, user->host, mq->reason);
diff --git a/src/commands/cmd_qline.cpp b/src/commands/cmd_qline.cpp
index 2922c09cf..e4da8c5ff 100644
--- a/src/commands/cmd_qline.cpp
+++ b/src/commands/cmd_qline.cpp
@@ -59,7 +59,7 @@ CmdResult CommandQline::Handle (const char** parameters, int pcnt, User *user)
}
else
{
- if (ServerInstance->XLines->DelLine(parameters[0],'Q',user))
+ if (ServerInstance->XLines->DelLine(parameters[0],"Q",user))
{
ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Q-line on %s.",user->nick,parameters[0]);
}
diff --git a/src/commands/cmd_rehash.cpp b/src/commands/cmd_rehash.cpp
index 5b1ab019c..174fba8ba 100644
--- a/src/commands/cmd_rehash.cpp
+++ b/src/commands/cmd_rehash.cpp
@@ -41,7 +41,7 @@ CmdResult CommandRehash::Handle (const char** parameters, int pcnt, User *user)
FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
ServerInstance->Config->Read(false,user);
// Get XLine to do it's thing.
- ServerInstance->XLines->CheckELines(ServerInstance->XLines->lookup_lines['E']);
+ ServerInstance->XLines->CheckELines(ServerInstance->XLines->lookup_lines["E"]);
ServerInstance->XLines->ApplyLines();
ServerInstance->Res->Rehash();
ServerInstance->ResetMaxBans();
diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp
index 5d4417689..0e8a5a0b0 100644
--- a/src/commands/cmd_stats.cpp
+++ b/src/commands/cmd_stats.cpp
@@ -144,6 +144,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str
case 'q':
case 'Z':
case 'e':
+ {
/* FIXME: Make the 216 here different depending on stats char:
* k: 216
* g: 223
@@ -151,7 +152,10 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str
* z: 223
* e: 223
*/
- ServerInstance->XLines->InvokeStats(toupper(statschar),216,user,results);
+ std::string stat;
+ stat += toupper(statschar);
+ ServerInstance->XLines->InvokeStats(stat,216,user,results);
+ }
break;
/* stats m (list number of times each command has been used, plus bytecount) */
diff --git a/src/commands/cmd_zline.cpp b/src/commands/cmd_zline.cpp
index e701867fb..520bea306 100644
--- a/src/commands/cmd_zline.cpp
+++ b/src/commands/cmd_zline.cpp
@@ -67,7 +67,7 @@ CmdResult CommandZline::Handle (const char** parameters, int pcnt, User *user)
}
else
{
- if (ServerInstance->XLines->DelLine(parameters[0],'Z',user))
+ if (ServerInstance->XLines->DelLine(parameters[0],"Z",user))
{
ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Z-line on %s.",user->nick,parameters[0]);
}
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 8311ad58e..7c6f784f4 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -1983,7 +1983,7 @@ bool DoneELine(ServerConfig* conf, const char* tag)
u->exempt = false;
}
- conf->GetInstance()->XLines->CheckELines(conf->GetInstance()->XLines->lookup_lines['E']);
+ conf->GetInstance()->XLines->CheckELines();
return true;
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 095787376..f62e2a74b 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -437,7 +437,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
Config->Read(true, NULL);
// Get XLine to do it's thing.
- this->XLines->CheckELines(this->XLines->lookup_lines['E']);
+ this->XLines->CheckELines();
this->XLines->ApplyLines();
this->Modules->modules.resize(255);
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 5468be25b..914de861f 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -523,7 +523,7 @@ bool TreeSocket::AddLine(const std::string &prefix, std::deque<std::string> &par
if (params.size() < 6)
return true;
- XLineFactory* xlf = Instance->XLines->GetFactory(params[0][0]);
+ XLineFactory* xlf = Instance->XLines->GetFactory(params[0]);
if (!xlf)
return false;
@@ -534,11 +534,13 @@ bool TreeSocket::AddLine(const std::string &prefix, std::deque<std::string> &par
{
if (xl->expiry)
{
- this->Instance->SNO->WriteToSnoMask('x',"%s Added %cLINE on %s to expire on %s (%s).",prefix.c_str(),*(params[0].c_str()),params[1].c_str(),Instance->TimeString(xl->expiry).c_str(),params[5].c_str());
+ this->Instance->SNO->WriteToSnoMask('x',"%s Added %s%s on %s to expire on %s (%s).",prefix.c_str(),params[0].c_str(),params[0].length() == 1 ? "LINE" : "",
+ params[1].c_str(),Instance->TimeString(xl->expiry).c_str(),params[5].c_str());
}
else
{
- this->Instance->SNO->WriteToSnoMask('x',"%s Added permenant %cLINE on %s (%s).",prefix.c_str(),*(params[0].c_str()),params[1].c_str(),params[5].c_str());
+ this->Instance->SNO->WriteToSnoMask('x',"%s Added permenant %s%s on %s (%s).",prefix.c_str(),params[0].c_str(),params[0].length() == 1 ? "LINE" : "",
+ params[1].c_str(),params[5].c_str());
}
params[5] = ":" + params[5];
Utils->DoOneToAllButSender(prefix,"ADDLINE",params,prefix);
diff --git a/src/users.cpp b/src/users.cpp
index 0f451d2a9..3803a7a9e 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -830,10 +830,10 @@ void User::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, in
}
#endif
- New->exempt = (Instance->XLines->MatchesLine('E',New) != NULL);
+ New->exempt = (Instance->XLines->MatchesLine("E",New) != NULL);
if (!New->exempt)
{
- XLine* r = Instance->XLines->MatchesLine('Z',New);
+ XLine* r = Instance->XLines->MatchesLine("Z",New);
if (r)
{
@@ -942,7 +942,7 @@ void User::FullConnect()
if (!this->exempt)
{
- XLine* r = ServerInstance->XLines->MatchesLine('G',this);
+ XLine* r = ServerInstance->XLines->MatchesLine("G",this);
if (r)
{
@@ -955,7 +955,7 @@ void User::FullConnect()
return;
}
- XLine* n = ServerInstance->XLines->MatchesLine('K',this);
+ XLine* n = ServerInstance->XLines->MatchesLine("K",this);
if (n)
{
@@ -1065,7 +1065,7 @@ bool User::ForceNickChange(const char* newnick)
return false;
}
- if (ServerInstance->XLines->MatchesLine('Q',newnick))
+ if (ServerInstance->XLines->MatchesLine("Q",newnick))
{
ServerInstance->stats->statsCollisions++;
return false;
diff --git a/src/xline.cpp b/src/xline.cpp
index a26ca7f01..47522f77d 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -57,8 +57,15 @@ bool XLine::Matches(User *u)
/*
* Checks what users match a given vector of ELines and sets their ban exempt flag accordingly.
*/
-void XLineManager::CheckELines(std::map<std::string, XLine *> &ELines)
+void XLineManager::CheckELines()
{
+ ContainerIter n = ServerInstance->XLines->lookup_lines.find("E");
+
+ if (n == ServerInstance->XLines->lookup_lines.end())
+ return;
+
+ XLineLookup& ELines = n->second;
+
if (ELines.empty())
return;
@@ -66,7 +73,7 @@ void XLineManager::CheckELines(std::map<std::string, XLine *> &ELines)
{
User* u = (User*)(*u2);
- for (std::map<std::string, XLine *>::iterator i = ELines.begin(); i != ELines.end(); i++)
+ for (LookupIter i = ELines.begin(); i != ELines.end(); i++)
{
XLine *e = i->second;
u->exempt = e->Matches(u);
@@ -74,19 +81,6 @@ void XLineManager::CheckELines(std::map<std::string, XLine *> &ELines)
}
}
-// this should probably be moved to configreader, but atm it relies on CheckELines above.
-bool DoneELine(ServerConfig* conf, const char* tag)
-{
- for (std::vector<User*>::const_iterator u2 = conf->GetInstance()->local_users.begin(); u2 != conf->GetInstance()->local_users.end(); u2++)
- {
- User* u = (User*)(*u2);
- u->exempt = false;
- }
-
- conf->GetInstance()->XLines->CheckELines(conf->GetInstance()->XLines->lookup_lines['E']);
- return true;
-}
-
IdentHostPair XLineManager::IdentSplit(const std::string &ident_and_host)
{
@@ -109,9 +103,8 @@ IdentHostPair XLineManager::IdentSplit(const std::string &ident_and_host)
return n;
}
-// adds a g:line
+// adds a line
-/*bool XLineManager::AddELine(long duration, const char* source, const char* reason, const char* hostmask)*/
bool XLineManager::AddLine(XLine* line, User* user)
{
/*IdentHostPair ih = IdentSplit(hostmask);*/
@@ -131,14 +124,14 @@ bool XLineManager::AddLine(XLine* line, User* user)
// deletes a line, returns true if the line existed and was removed
-bool XLineManager::DelLine(const char* hostmask, char type, User* user, bool simulate)
+bool XLineManager::DelLine(const char* hostmask, const std::string &type, User* user, bool simulate)
{
- std::map<char, std::map<std::string, XLine*> >::iterator x = lookup_lines.find(type);
+ ContainerIter x = lookup_lines.find(type);
if (x == lookup_lines.end())
return false;
- std::map<std::string, XLine*>::iterator y = x->second.find(hostmask);
+ LookupIter y = x->second.find(hostmask);
if (y == x->second.end())
return false;
@@ -170,23 +163,23 @@ void ELine::Unset()
u->exempt = false;
}
- std::map<char, std::map<std::string, XLine*> >::iterator x = ServerInstance->XLines->lookup_lines.find('E');
+ ContainerIter x = ServerInstance->XLines->lookup_lines.find("E");
if (x != ServerInstance->XLines->lookup_lines.end())
- ServerInstance->XLines->CheckELines(x->second);
+ ServerInstance->XLines->CheckELines();
}
// returns a pointer to the reason if a nickname matches a qline, NULL if it didnt match
-XLine* XLineManager::MatchesLine(const char type, User* user)
+XLine* XLineManager::MatchesLine(const std::string &type, User* user)
{
- std::map<char, std::map<std::string, XLine*> >::iterator x = lookup_lines.find(type);
+ ContainerIter x = lookup_lines.find(type);
if (x == lookup_lines.end())
return NULL;
const time_t current = ServerInstance->Time();
- for (std::map<std::string, XLine*>::iterator i = x->second.begin(); i != x->second.end(); i++)
+ for (LookupIter i = x->second.begin(); i != x->second.end(); i++)
{
if (i->second->Matches(user))
{
@@ -203,16 +196,16 @@ XLine* XLineManager::MatchesLine(const char type, User* user)
return NULL;
}
-XLine* XLineManager::MatchesLine(const char type, const std::string &pattern)
+XLine* XLineManager::MatchesLine(const std::string &type, const std::string &pattern)
{
- std::map<char, std::map<std::string, XLine*> >::iterator x = lookup_lines.find(type);
+ ContainerIter x = lookup_lines.find(type);
if (x == lookup_lines.end())
return NULL;
const time_t current = ServerInstance->Time();
- for (std::map<std::string, XLine*>::iterator i = x->second.begin(); i != x->second.end(); i++)
+ for (LookupIter i = x->second.begin(); i != x->second.end(); i++)
{
if (i->second->Matches(pattern))
{
@@ -230,7 +223,7 @@ XLine* XLineManager::MatchesLine(const char type, const std::string &pattern)
}
// removes lines that have expired
-void XLineManager::ExpireLine(std::map<char, std::map<std::string, XLine*> >::iterator container, std::map<std::string, XLine*>::iterator item)
+void XLineManager::ExpireLine(ContainerIter container, LookupIter item)
{
item->second->DisplayExpiry();
item->second->Unset();
@@ -273,16 +266,16 @@ void XLineManager::ApplyLines()
* e: 223
*/
-void XLineManager::InvokeStats(const char type, int numeric, User* user, string_list &results)
+void XLineManager::InvokeStats(const std::string &type, int numeric, User* user, string_list &results)
{
std::string sn = ServerInstance->Config->ServerName;
- std::map<const char, std::map<std::string, XLine*> >::iterator n = lookup_lines.find(type);
+ ContainerIter n = lookup_lines.find(type);
if (n != lookup_lines.end())
{
- std::map<std::string, XLine*>& list = n->second;
- for (std::map<std::string, XLine*>::iterator i = list.begin(); i != list.end(); i++)
+ XLineLookup& list = n->second;
+ for (LookupIter i = list.begin(); i != list.end(); i++)
results.push_back(sn+" "+ConvToStr(numeric)+" "+user->nick+" :"+i->second->Displayable()+" "+
ConvToStr(i->second->set_time)+" "+ConvToStr(i->second->duration)+" "+std::string(i->second->source)+" :"+(i->second->reason));
}
@@ -323,14 +316,14 @@ void XLine::Apply(User* u)
{
}
-void XLine::DefaultApply(User* u, char line)
+void XLine::DefaultApply(User* u, const std::string &line)
{
char reason[MAXBUF];
- snprintf(reason, MAXBUF, "%c-Lined: %s", line, this->reason);
+ snprintf(reason, MAXBUF, "%s-Lined: %s", line.c_str(), this->reason);
if (*ServerInstance->Config->MoronBanner)
u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner);
if (ServerInstance->Config->HideBans)
- User::QuitUser(ServerInstance, u, line + std::string("-Lined"), reason);
+ User::QuitUser(ServerInstance, u, line + "-Lined", reason);
else
User::QuitUser(ServerInstance, u, reason);
}
@@ -353,7 +346,7 @@ bool KLine::Matches(User *u)
void KLine::Apply(User* u)
{
- DefaultApply(u, 'K');
+ DefaultApply(u, "K");
}
bool GLine::Matches(User *u)
@@ -374,7 +367,7 @@ bool GLine::Matches(User *u)
void GLine::Apply(User* u)
{
- DefaultApply(u, 'G');
+ DefaultApply(u, "G");
}
bool ELine::Matches(User *u)
@@ -406,7 +399,7 @@ bool ZLine::Matches(User *u)
void ZLine::Apply(User* u)
{
- DefaultApply(u, 'Z');
+ DefaultApply(u, "Z");
}
@@ -424,7 +417,7 @@ bool QLine::Matches(User *u)
void QLine::Apply(User* u)
{
/* Can we force the user to their uid here instead? */
- DefaultApply(u, 'Q');
+ DefaultApply(u, "Q");
}
@@ -459,31 +452,6 @@ bool GLine::Matches(const std::string &str)
return ((match(str.c_str(), matchtext.c_str(), true)));
}
-bool ELine::MatchesLiteral(const std::string &str)
-{
- return (assign(str) == matchtext);
-}
-
-bool ZLine::MatchesLiteral(const std::string &str)
-{
- return (assign(str) == this->ipaddr);
-}
-
-bool GLine::MatchesLiteral(const std::string &str)
-{
- return (assign(str) == matchtext);
-}
-
-bool KLine::MatchesLiteral(const std::string &str)
-{
- return (assign(str) == matchtext);
-}
-
-bool QLine::MatchesLiteral(const std::string &str)
-{
- return (assign(str) == this->nick);
-}
-
void ELine::OnAdd()
{
/* When adding one eline, only check the one eline */
@@ -547,7 +515,7 @@ const char* QLine::Displayable()
bool XLineManager::RegisterFactory(XLineFactory* xlf)
{
- std::map<char, XLineFactory*>::iterator n = line_factory.find(xlf->GetType());
+ XLineFactMap::iterator n = line_factory.find(xlf->GetType());
if (n != line_factory.end())
return false;
@@ -559,7 +527,7 @@ bool XLineManager::RegisterFactory(XLineFactory* xlf)
bool XLineManager::UnregisterFactory(XLineFactory* xlf)
{
- std::map<char, XLineFactory*>::iterator n = line_factory.find(xlf->GetType());
+ XLineFactMap::iterator n = line_factory.find(xlf->GetType());
if (n == line_factory.end())
return false;
@@ -569,9 +537,9 @@ bool XLineManager::UnregisterFactory(XLineFactory* xlf)
return true;
}
-XLineFactory* XLineManager::GetFactory(const char type)
+XLineFactory* XLineManager::GetFactory(const std::string &type)
{
- std::map<char, XLineFactory*>::iterator n = line_factory.find(type);
+ XLineFactMap::iterator n = line_factory.find(type);
if (n != line_factory.end())
return NULL;