diff --git a/modules/core/m_mode.c b/modules/core/m_mode.c index 030985169..87be36c93 100644 --- a/modules/core/m_mode.c +++ b/modules/core/m_mode.c @@ -240,6 +240,35 @@ ms_mlock(struct Client *client_p, struct Client *source_p, int parc, const char return 0; } +static void +possibly_remove_lower_forward(struct Client *fakesource_p, int mems, + struct Channel *chptr, rb_dlink_list *banlist, int mchar, + const char *mask, const char *forward) +{ + struct Ban *actualBan; + rb_dlink_node *ptr; + + RB_DLINK_FOREACH(ptr, banlist->head) + { + actualBan = ptr->data; + if(!irccmp(actualBan->banstr, mask) && + (actualBan->forward == NULL || + irccmp(actualBan->forward, forward) < 0)) + { + sendto_channel_local(mems, chptr, ":%s MODE %s -%c %s%s%s", + fakesource_p->name, + chptr->chname, + mchar, + actualBan->banstr, + actualBan->forward ? "$" : "", + actualBan->forward ? actualBan->forward : ""); + rb_dlinkDelete(&actualBan->node, banlist); + free_ban(actualBan); + return; + } + } +} + static int ms_bmask(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { @@ -347,6 +376,8 @@ ms_bmask(struct Client *client_p, struct Client *source_p, int parc, const char *forward++ = '\0'; if(*forward == '\0') tlen--, forward = NULL; + possibly_remove_lower_forward(fakesource_p, mems, + chptr, banlist, parv[3][0], s, forward); } if(add_id(fakesource_p, chptr, s, forward, banlist, mode_type))