diff options
-rw-r--r-- | include/configreader.h | 25 | ||||
-rw-r--r-- | include/xline.h | 31 | ||||
-rw-r--r-- | src/commands/cmd_rehash.cpp | 4 | ||||
-rw-r--r-- | src/configreader.cpp | 54 | ||||
-rw-r--r-- | src/inspircd.cpp | 4 | ||||
-rw-r--r-- | src/xline.cpp | 95 |
6 files changed, 110 insertions, 103 deletions
diff --git a/include/configreader.h b/include/configreader.h index 37e3c1f44..1a14a2854 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -803,5 +803,30 @@ bool DoClass(ServerConfig* conf, const char* tag, char** entries, ValueList &val */ bool DoneClassesAndTypes(ServerConfig* conf, const char* tag); + + +/** Initialize x line + */ +bool InitXLine(ServerConfig* conf, const char* tag); + +/** Add a config-defined zline + */ +bool DoZLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types); + +/** Add a config-defined qline + */ +bool DoQLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types); + +/** Add a config-defined kline + */ +bool DoKLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types); + +/** Add a config-defined eline + */ +bool DoELine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types); + + + + #endif diff --git a/include/xline.h b/include/xline.h index 7bf291253..6540d57f6 100644 --- a/include/xline.h +++ b/include/xline.h @@ -304,36 +304,10 @@ class CoreExport QLine : public XLine class ServerConfig; class InspIRCd; -/** Initialize x line - */ -bool InitXLine(ServerConfig* conf, const char* tag); - -/** Done adding zlines from the config - */ -bool DoneZLine(ServerConfig* conf, const char* tag); -/** Done adding qlines from the config - */ -bool DoneQLine(ServerConfig* conf, const char* tag); -/** Done adding klines from the config - */ -bool DoneKLine(ServerConfig* conf, const char* tag); /** Done adding elines from the config */ bool DoneELine(ServerConfig* conf, const char* tag); -/** Add a config-defined zline - */ -bool DoZLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types); -/** Add a config-defined qline - */ -bool DoQLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types); -/** Add a config-defined kline - */ -bool DoKLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types); -/** Add a config-defined eline - */ -bool DoELine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types); - /** Contains an ident and host split into two strings */ typedef std::pair<std::string, std::string> IdentHostPair; @@ -371,6 +345,11 @@ class CoreExport XLineManager */ IdentHostPair IdentSplit(const std::string &ident_and_host); + /** Checks what users match a given list of ELines and sets their ban exempt flag accordingly. + * @param ELines List of E:Lines to check. + */ + void CheckELines(std::map<std::string, XLine *> &ELines); + /** Add a new GLine * @param duration The duration of the line * @param source The source of the line diff --git a/src/commands/cmd_rehash.cpp b/src/commands/cmd_rehash.cpp index 2246c2f46..5b1ab019c 100644 --- a/src/commands/cmd_rehash.cpp +++ b/src/commands/cmd_rehash.cpp @@ -12,6 +12,7 @@ */ #include "inspircd.h" +#include "xline.h" #include "commands/cmd_rehash.h" @@ -39,6 +40,9 @@ CmdResult CommandRehash::Handle (const char** parameters, int pcnt, User *user) ServerInstance->RehashUsersAndChans(); 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->ApplyLines(); ServerInstance->Res->Rehash(); ServerInstance->ResetMaxBans(); } diff --git a/src/configreader.cpp b/src/configreader.cpp index d14fc92a8..e0d66d525 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -181,6 +181,11 @@ bool NoValidation(ServerConfig*, const char*, const char*, ValueItem&) return true; } +bool DoneConfItem(ServerConfig* conf, const char* tag) +{ + return true; +} + bool ValidateMaxTargets(ServerConfig* conf, const char*, const char*, ValueItem &data) { if ((data.GetInteger() < 0) || (data.GetInteger() > 31)) @@ -793,19 +798,19 @@ void ServerConfig::Read(bool bail, User* user) {"reason", "ipmask", NULL}, {"No reason", "", NULL}, {DT_CHARPTR, DT_CHARPTR}, - InitXLine, DoZLine, DoneZLine}, + InitXLine, DoZLine, DoneConfItem}, {"badnick", {"reason", "nick", NULL}, {"No reason", "", NULL}, {DT_CHARPTR, DT_CHARPTR}, - InitXLine, DoQLine, DoneQLine}, + InitXLine, DoQLine, DoneConfItem}, {"badhost", {"reason", "host", NULL}, {"No reason", "", NULL}, {DT_CHARPTR, DT_CHARPTR}, - InitXLine, DoKLine, DoneKLine}, + InitXLine, DoKLine, DoneConfItem}, {"exception", {"reason", "host", NULL}, @@ -1907,3 +1912,46 @@ bool DoneClassesAndTypes(ServerConfig*, const char*) return true; } + + +bool InitXLine(ServerConfig* conf, const char* tag) +{ + return true; +} + +bool DoZLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types) +{ + const char* reason = values[0].GetString(); + const char* ipmask = values[1].GetString(); + + conf->GetInstance()->XLines->AddZLine(0,"<Config>",reason,ipmask); + return true; +} + +bool DoQLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types) +{ + const char* reason = values[0].GetString(); + const char* nick = values[1].GetString(); + + conf->GetInstance()->XLines->AddQLine(0,"<Config>",reason,nick); + return true; +} + +bool DoKLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types) +{ + const char* reason = values[0].GetString(); + const char* host = values[1].GetString(); + + conf->GetInstance()->XLines->AddKLine(0,"<Config>",reason,host); + return true; +} + +bool DoELine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types) +{ + const char* reason = values[0].GetString(); + const char* host = values[1].GetString(); + + conf->GetInstance()->XLines->AddELine(0,"<Config>",reason,host); + return true; +} + diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 097cd6d0b..f671c9545 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -435,6 +435,10 @@ InspIRCd::InspIRCd(int argc, char** argv) Config->ClearStack(); Config->Read(true, NULL); + + // Get XLine to do it's thing. + this->XLines->CheckELines(this->XLines->lookup_lines['E']); + this->XLines->ApplyLines(); this->Modules->modules.resize(255); this->Modules->handles.resize(255); diff --git a/src/xline.cpp b/src/xline.cpp index 329b0e6e8..08226f650 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -63,82 +63,15 @@ * -- Brain */ -bool InitXLine(ServerConfig* conf, const char* tag) -{ - return true; -} - -bool DoneZLine(ServerConfig* conf, const char* tag) -{ - // XXX we should really only call this once - after we've finished processing configuration all together - conf->GetInstance()->XLines->ApplyLines(); - return true; -} - -bool DoneQLine(ServerConfig* conf, const char* tag) -{ - // XXX we should really only call this once - after we've finished processing configuration all together - conf->GetInstance()->XLines->ApplyLines(); - return true; -} - -bool DoneKLine(ServerConfig* conf, const char* tag) -{ - // XXX we should really only call this once - after we've finished processing configuration all together - conf->GetInstance()->XLines->ApplyLines(); - return true; -} - -bool DoneELine(ServerConfig* conf, const char* tag) -{ - // XXX we should really only call this once - after we've finished processing configuration all together - conf->GetInstance()->XLines->ApplyLines(); - return true; -} - -bool DoZLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types) -{ - const char* reason = values[0].GetString(); - const char* ipmask = values[1].GetString(); - - conf->GetInstance()->XLines->AddZLine(0,"<Config>",reason,ipmask); - return true; -} - -bool DoQLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types) -{ - const char* reason = values[0].GetString(); - const char* nick = values[1].GetString(); - - conf->GetInstance()->XLines->AddQLine(0,"<Config>",reason,nick); - return true; -} - -bool DoKLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types) -{ - const char* reason = values[0].GetString(); - const char* host = values[1].GetString(); - - conf->GetInstance()->XLines->AddKLine(0,"<Config>",reason,host); - return true; -} - -bool DoELine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types) -{ - const char* reason = values[0].GetString(); - const char* host = values[1].GetString(); - - conf->GetInstance()->XLines->AddELine(0,"<Config>",reason,host); - return true; -} - bool XLine::Matches(User *u) { return false; } -//XXX perhaps move into xlinemanager -void CheckELines(InspIRCd *ServerInstance, std::map<std::string, XLine *> &ELines) +/* + * 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) { if (ELines.empty()) return; @@ -155,6 +88,19 @@ void CheckELines(InspIRCd *ServerInstance, std::map<std::string, XLine *> &ELine } } +// 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) { @@ -212,8 +158,9 @@ bool XLineManager::AddELine(long duration, const char* source, const char* reaso lookup_lines['E'][hostmask] = item; // XXX we really only need to check one line (the new one) - this is a bit wasteful! - CheckELines(ServerInstance, lookup_lines['E']); - + // we should really create a temporary var here and pass that instead. + // hmm, perhaps we can merge this with line "application" somehow.. and just force a recheck on DelELine? + this->CheckELines(lookup_lines['E']); return true; } @@ -316,7 +263,7 @@ void ELine::Unset() } if (ServerInstance->XLines->lookup_lines.find('E') != ServerInstance->XLines->lookup_lines.end()) - CheckELines(ServerInstance, ServerInstance->XLines->lookup_lines['E']); + ServerInstance->XLines->CheckELines(ServerInstance->XLines->lookup_lines['E']); } // returns a pointer to the reason if a nickname matches a qline, NULL if it didnt match |