- ConfigTag* tag = ServerInstance->Config->ConfValue("cloak");
- prefix = tag->getString("prefix");
- suffix = tag->getString("suffix", ".IP");
-
- std::string modestr = tag->getString("mode");
- if (modestr == "half")
- mode = MODE_HALF_CLOAK;
- else if (modestr == "full")
- mode = MODE_OPAQUE;
- else
- throw ModuleException("Bad value for <cloak:mode>; must be half or full");
+ ConfigTagList tags = ServerInstance->Config->ConfTags("cloak");
+ if (tags.first == tags.second)
+ throw ModuleException("You have loaded the cloaking module but not configured any <cloak> tags!");
+
+ std::vector<CloakInfo> newcloaks;
+ for (ConfigIter i = tags.first; i != tags.second; ++i)
+ {
+ ConfigTag* tag = i->second;
+
+ // Ensure that we have the <cloak:key> parameter.
+ const std::string key = tag->getString("key");
+ if (key.empty())
+ throw ModuleException("You have not defined a cloaking key. Define <cloak:key> as a " + ConvToStr(minkeylen) + "+ character network-wide secret, at " + tag->getTagLocation());
+
+ // If we are the first cloak method then mandate a strong key.
+ if (i == tags.first && key.length() < minkeylen)
+ throw ModuleException("Your cloaking key is not secure. It should be at least " + ConvToStr(minkeylen) + " characters long, at " + tag->getTagLocation());
+
+ const bool ignorecase = tag->getBool("ignorecase");
+ const std::string mode = tag->getString("mode");
+ const std::string prefix = tag->getString("prefix");
+ const std::string suffix = tag->getString("suffix", ".IP");
+ if (stdalgo::string::equalsci(mode, "half"))
+ {
+ unsigned int domainparts = tag->getUInt("domainparts", 3, 1, 10);
+ newcloaks.push_back(CloakInfo(MODE_HALF_CLOAK, key, prefix, suffix, ignorecase, domainparts));
+ }
+ else if (stdalgo::string::equalsci(mode, "full"))
+ newcloaks.push_back(CloakInfo(MODE_OPAQUE, key, prefix, suffix, ignorecase));
+ else
+ throw ModuleException(mode + " is an invalid value for <cloak:mode>; acceptable values are 'half' and 'full', at " + tag->getTagLocation());
+ }