- /* Read the configuration file on startup and rehash.
- * It is perfectly valid to set <filter file> to the value of the
- * main config file, then append your <keyword> tags to the bottom
- * of the main config... but rather messy. That's why the capability
- * of using a seperate config file is provided.
- */
-
- ConfigReader Conf(Srv);
-
- std::string filterfile = Conf.ReadValue("filter", "file", 0);
-
- ConfigReader MyConf(Srv, filterfile);
-
- if (filterfile.empty() || !MyConf.Verify())
+ for (std::vector<PCREFilter>::iterator i = filters.begin(); i != filters.end(); i++)
+ {
+ this->SendFilter(proto, opaque, &(*i));
+ }
+ }
+
+ virtual std::pair<bool, std::string> AddFilter(const std::string &freeform, const std::string &type, const std::string &reason, long duration, const std::string &flags)
+ {
+ for (std::vector<PCREFilter>::iterator i = filters.begin(); i != filters.end(); i++)
+ {
+ if (i->freeform == freeform)
+ {
+ return std::make_pair(false, "Filter already exists");
+ }
+ }
+
+ re = pcre_compile(freeform.c_str(),0,&error,&erroffset,NULL);
+
+ if (!re)
+ {
+ ServerInstance->Log(DEFAULT,"Error in regular expression: %s at offset %d: %s\n", freeform.c_str(), erroffset, error);
+ ServerInstance->Log(DEFAULT,"Regular expression %s not loaded.", freeform.c_str());
+ return std::make_pair(false, "Error in regular expression at offset " + ConvToStr(erroffset) + ": "+error);
+ }
+ else