- 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(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, cname, '*', "You may not join this channel. A redirect is set, but you may not be redirected as it is a circular loop.");
+ return MOD_RES_DENY;
+ }
+
+ if (user->IsModeSet(antiredirectmode))
+ {
+ user->WriteNumeric(470, cname, channel, "Force redirection stopped.");
+ return MOD_RES_DENY;
+ }
+ else
+ {
+ user->WriteNumeric(470, cname, channel, "You may not join this channel, so you are automatically being transferred to the redirected channel.");
+ Channel::JoinUser(user, channel);
+ return MOD_RES_DENY;
+ }