+ /* check for redirect validity and loops/chains */
+ ConfigTagList tags = ServerInstance->Config->ConfTags("badchan");
+ for (ConfigIter i = tags.first; i != tags.second; ++i)
+ {
+ std::string name = i->second->getString("name");
+ std::string redirect = i->second->getString("redirect");
+
+ if (!redirect.empty())
+ {
+
+ if (!ServerInstance->IsChannel(redirect.c_str(), ServerInstance->Config->Limits.ChanMax))
+ {
+ if (user)
+ user->WriteServ("NOTICE %s :Invalid badchan redirect '%s'", user->nick.c_str(), redirect.c_str());
+ throw ModuleException("Invalid badchan redirect, not a channel");
+ }
+
+ for (ConfigIter j = tags.first; j != tags.second; ++j)
+ {
+ if (InspIRCd::Match(redirect, j->second->getString("name")))
+ {
+ bool goodchan = false;
+ ConfigTagList goodchans = ServerInstance->Config->ConfTags("badchan");
+ for (ConfigIter k = goodchans.first; k != goodchans.second; ++k)
+ {
+ if (InspIRCd::Match(redirect, k->second->getString("name")))
+ goodchan = true;
+ }
+
+ if (!goodchan)
+ {
+ /* <badchan:redirect> is a badchan */
+ if (user)
+ user->WriteServ("NOTICE %s :Badchan %s redirects to badchan %s", user->nick.c_str(), name.c_str(), redirect.c_str());
+ throw ModuleException("Badchan redirect loop");
+ }
+ }
+ }
+ }
+ }