diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-07 17:26:30 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-07 17:26:30 +0000 |
commit | b040f1c1a6b3140024a2eab0174415c0763ed6ae (patch) | |
tree | 38d09b749d99881279e2ceaf075631fdf3eb191f /src | |
parent | bd4c18aa1554e4fec0913b3c5f742080cbf0eab4 (diff) |
Added preliminary support for ConfigReader::Verify at request of the slug :p
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@419 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/InspIRCd.layout | 34 | ||||
-rw-r--r-- | src/inspircd.cpp | 1 | ||||
-rw-r--r-- | src/inspircd_io.cpp | 15 | ||||
-rw-r--r-- | src/modules.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_filter.cpp | 71 |
5 files changed, 93 insertions, 34 deletions
diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout index 0eb47174c..7b1852057 100644 --- a/src/InspIRCd.layout +++ b/src/InspIRCd.layout @@ -1,5 +1,5 @@ [Editors] -Focused=4 +Focused=2 Order=7,3,2,6,25,24,4,5,-1,1,0 [Editor_0] @@ -20,10 +20,10 @@ LeftChar=1 [Editor_2] Open=1 -Top=0 -CursorCol=1 -CursorRow=275 -TopLine=95 +Top=1 +CursorCol=23 +CursorRow=109 +TopLine=101 LeftChar=1 [Editor_3] @@ -36,10 +36,10 @@ LeftChar=1 [Editor_4] Open=1 -Top=1 -CursorCol=25 -CursorRow=213 -TopLine=181 +Top=0 +CursorCol=21 +CursorRow=350 +TopLine=326 LeftChar=1 [Editor_5] @@ -149,8 +149,8 @@ LeftChar=1 [Editor_18] Open=1 Top=0 -CursorCol=81 -CursorRow=27 +CursorCol=5 +CursorRow=26 TopLine=1 LeftChar=1 @@ -165,9 +165,9 @@ LeftChar=1 [Editor_20] Open=1 Top=0 -CursorCol=68 -CursorRow=288 -TopLine=254 +CursorCol=1 +CursorRow=508 +TopLine=463 LeftChar=1 [Editor_21] @@ -259,7 +259,7 @@ Top=0 [Editor_34] Open=1 Top=0 -CursorCol=25 -CursorRow=110 -TopLine=52 +CursorCol=29 +CursorRow=139 +TopLine=128 LeftChar=1 diff --git a/src/inspircd.cpp b/src/inspircd.cpp index f0fda4d7c..67bf10264 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -3419,6 +3419,7 @@ void Error(int status) exit(status); } + int main (int argc, char *argv[]) { Start(); diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp index 65597704f..bb78c2c4b 100644 --- a/src/inspircd_io.cpp +++ b/src/inspircd_io.cpp @@ -105,8 +105,12 @@ int DaemonSeed (void) /* Make Sure Modules Are Avaliable! - * (BugFix By Craig.. See? I do work! :p) */ -int FileExists (char* file) + * (BugFix By Craig.. See? I do work! :p) + * Modified by brain, requires const char* + * to work with other API functions + */ + +bool FileExists (const char* file) { FILE *input; @@ -115,9 +119,13 @@ int FileExists (char* file) } -void LoadConf(const char* filename, std::stringstream *target) +bool LoadConf(const char* filename, std::stringstream *target) { FILE* conf = fopen(filename,"r"); + if (!FileExists(filename)) + { + return false; + } char buffer[MAXBUF]; if (conf) { @@ -138,6 +146,7 @@ void LoadConf(const char* filename, std::stringstream *target) fclose(conf); } target->seekg(0); + return true; } /* Counts the number of tags of a certain type within the config file, e.g. to enumerate opers */ diff --git a/src/modules.cpp b/src/modules.cpp index d2263e352..46b24de7b 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -314,7 +314,7 @@ bool Server::AddExtendedMode(char modechar, int type, bool requires_oper, int pa ConfigReader::ConfigReader() { this->cache = new std::stringstream(stringstream::in | stringstream::out); - LoadConf(CONFIG_FILE,this->cache); + this->error = LoadConf(CONFIG_FILE,this->cache); } @@ -328,7 +328,7 @@ ConfigReader::~ConfigReader() ConfigReader::ConfigReader(std::string filename) { this->cache = new std::stringstream(stringstream::in | stringstream::out); - LoadConf(filename.c_str(),this->cache); + this->error = LoadConf(filename.c_str(),this->cache); }; std::string ConfigReader::ReadValue(std::string tag, std::string name, int index) @@ -347,7 +347,7 @@ int ConfigReader::Enumerate(std::string tag) bool ConfigReader::Verify() { - return true; + return this->error; } diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index d208e7a5a..3bda79022 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -56,6 +56,14 @@ class ModuleFilter : public Module { std::string target = ""; std::string reason = MyConf->ReadValue("keyword","reason",index); + std::string action = MyConf->ReadValue("keyword","action",index); + std::string operaction = MyConf->ReadValue("keyword","operaction",index); + std::string do_action = "none"; + + if (action == "") + action = "none"; + if (operaction == "") + operaction = "none"; if (target_type == TYPE_USER) { userrec* t = (userrec*)dest; @@ -66,15 +74,32 @@ class ModuleFilter : public Module chanrec* t = (chanrec*)dest; target = std::string(t->name); } - Srv->SendOpers(std::string("FILTER: ")+std::string(user->nick)+ - std::string(" had their message filtered, target was ")+ - target+": "+reason); + if (strchr(user->modes,'o')) + { + do_action = operaction; + } + else + { + do_action = action; + } + if (do_action == "block") + { + Srv->SendOpers(std::string("FILTER: ")+std::string(user->nick)+ + std::string(" had their message filtered, target was ")+ + target+": "+reason); + // this form of SendTo (with the source as NuLL) sends a server notice + Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+ + " :Your message has been filtered and opers notified: "+reason); + } + Srv->Log(DEFAULT,std::string("FILTER: ")+std::string(user->nick)+ std::string(" had their message filtered, target was ")+ target+": "+reason); - // this form of SendTo (with the source as NuLL) sends a server notice - Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+ - " :Your message has been filtered and opers notified: "+reason); + + if (do_action == "kill") + { + Srv->QuitUser(user,reason); + } return 1; } } @@ -91,6 +116,14 @@ class ModuleFilter : public Module { std::string target = ""; std::string reason = MyConf->ReadValue("keyword","reason",index); + std::string action = MyConf->ReadValue("keyword","action",index); + std::string operaction = MyConf->ReadValue("keyword","operaction",index); + std::string do_action = "none"; + + if (action == "") + action = "none"; + if (operaction == "") + operaction = "none"; if (target_type == TYPE_USER) { userrec* t = (userrec*)dest; @@ -101,14 +134,30 @@ class ModuleFilter : public Module chanrec* t = (chanrec*)dest; target = std::string(t->name); } - Srv->SendOpers(std::string("FILTER: ")+std::string(user->nick)+ - std::string(" had their notice filtered, target was ")+ - target+": "+MyConf->ReadValue("keyword","reason",index)); + if (strchr(user->modes,'o')) + { + do_action = operaction; + } + else + { + do_action = action; + } + if (do_action == "block") + { + Srv->SendOpers(std::string("FILTER: ")+std::string(user->nick)+ + std::string(" had their notice filtered, target was ")+ + target+": "+MyConf->ReadValue("keyword","reason",index)); + Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+ + " :Your notice has been filtered and opers notified: "+reason); + } Srv->Log(DEFAULT,std::string("FILTER: ")+std::string(user->nick)+ std::string(" had their notice filtered, target was ")+ target+": "+MyConf->ReadValue("keyword","reason",index)); - Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+ - " :Your notice has been filtered and opers notified: "+reason); + + if (do_action == "kill") + { + Srv->QuitUser(user,reason); + } return 1; } } |