- virtual void OnRehash()
- {
- delete Conf;
- Conf = new ConfigReader;
- MySuffix = Conf->ReadValue("host","suffix",0);
+ std::set<std::string> dupecheck;
+ ConfigTagList tags = ServerInstance->Config->ConfTags("hostchange");
+ for (ConfigIter i = tags.first; i != tags.second; ++i)
+ {
+ ConfigTag* tag = i->second;
+ std::string mask = tag->getString("mask");
+ if (!dupecheck.insert(mask).second)
+ throw ModuleException("Duplicate hostchange entry: " + mask);
+
+ Host::HostChangeAction act;
+ std::string newhost;
+ std::string action = tag->getString("action");
+ if (!strcasecmp(action.c_str(), "set"))
+ {
+ act = Host::HCA_SET;
+ newhost = tag->getString("value");
+ }
+ else if (!strcasecmp(action.c_str(), "suffix"))
+ act = Host::HCA_SUFFIX;
+ else if (!strcasecmp(action.c_str(), "addnick"))
+ act = Host::HCA_ADDNICK;
+ else
+ throw ModuleException("Invalid hostchange action: " + action);
+
+ hostchanges.push_back(std::make_pair(mask, Host(act, newhost, tag->getString("ports"))));
+ }