+ // 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 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, domainparts));
+ }
+ else if (stdalgo::string::equalsci(mode, "full"))
+ newcloaks.push_back(CloakInfo(MODE_OPAQUE, key, prefix, suffix));
+ else
+ throw ModuleException(mode + " is an invalid value for <cloak:mode>; acceptable values are 'half' and 'full', at " + tag->getTagLocation());
+ }
+
+ // The cloak configuration was valid so we can apply it.
+ cloaks.swap(newcloaks);