summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd_io.h4
-rw-r--r--include/modules.h7
-rw-r--r--src/InspIRCd.layout34
-rw-r--r--src/inspircd.cpp1
-rw-r--r--src/inspircd_io.cpp15
-rw-r--r--src/modules.cpp6
-rw-r--r--src/modules/m_filter.cpp71
7 files changed, 101 insertions, 37 deletions
diff --git a/include/inspircd_io.h b/include/inspircd_io.h
index 09d5e5674..df64228a4 100644
--- a/include/inspircd_io.h
+++ b/include/inspircd_io.h
@@ -19,11 +19,11 @@
void Exit (int);
void Start (void);
int DaemonSeed (void);
-int FileExists (char* file);
+bool FileExists (const char* file);
int OpenTCPSocket (void);
int BindSocket (int sockfd, struct sockaddr_in client, struct sockaddr_in server, int port, char* addr);
-void LoadConf(const char* filename, std::stringstream *target);
+bool LoadConf(const char* filename, std::stringstream *target);
int ConfValue(char* tag, char* var, int index, char *result, std::stringstream *config);
int ReadConf(std::stringstream *config_f,const char* tag, const char* var, int index, char *result);
int ConfValueEnum(char* tag,std::stringstream *config);
diff --git a/include/modules.h b/include/modules.h
index 8f95e4e86..9b6bd0bd8 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -471,6 +471,10 @@ class ConfigReader : public classbase
* (such as comments) stripped from it.
*/
std::stringstream *cache;
+ /** Used to store errors
+ */
+ bool error;
+
public:
/** Default constructor.
* This constructor initialises the ConfigReader class to read the inspircd.conf file
@@ -498,7 +502,8 @@ class ConfigReader : public classbase
*/
int Enumerate(std::string tag);
/** Returns true if a config file is valid.
- * This method is unimplemented and will always return true.
+ * This method is partially implemented and will only return false if the config
+ * file does not exist or could not be opened.
*/
bool Verify();
};
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;
}
}