- std::string channel = chan->GetModeParameter('L');
- user->WriteServ("470 %s :%s has become full, so you are automatically being transferred to the linked channel %s",user->nick,cname,channel.c_str());
- chanrec::JoinUser(ServerInstance, user, channel.c_str(), false);
- return 1;
+ const std::string& channel = *re.ext.get(chan);
+
+ /* sometimes broken ulines can make circular or chained +L, avoid this */
+ Channel* destchan = ServerInstance->FindChan(channel);
+ if (destchan && destchan->IsModeSet(re))
+ {
+ user->WriteNumeric(470, "%s * :You may not join this channel. A redirect is set, but you may not be redirected as it is a circular loop.", cname.c_str());
+ return MOD_RES_DENY;
+ }
+ /* We check the bool value here to make sure we have it enabled, if we don't then
+ usermode +L might be assigned to something else. */
+ if (UseUsermode && user->IsModeSet(re_u))
+ {
+ user->WriteNumeric(470, "%s %s :Force redirection stopped.", cname.c_str(), channel.c_str());
+ return MOD_RES_DENY;
+ }
+ else
+ {
+ user->WriteNumeric(470, "%s %s :You may not join this channel, so you are automatically being transferred to the redirect channel.", cname.c_str(), channel.c_str());
+ Channel::JoinUser(user, channel);
+ return MOD_RES_DENY;
+ }