- delete i->second;
- }
- hostchanges.clear();
- for (int index = 0; index < Conf.Enumerate("hostchange"); index++)
- {
- std::string mask = Conf.ReadValue("hostchange", "mask", index);
- std::string ports = Conf.ReadValue("hosthange", "ports", index);
- std::string action = Conf.ReadValue("hostchange", "action", index);
- std::string newhost = Conf.ReadValue("hostchange", "value", index);
- Host* x = new Host;
- x->action = action;
- x->ports = ports;
- x->newhost = newhost;
- hostchanges[mask] = x;
+ 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"))));