]> jfr.im git - irc/charybdis-ircd/charybdis.git/commitdiff
Keep forward channels in sync after a netjoin.
authorJilles Tjoelker <redacted>
Sat, 3 Mar 2012 22:45:52 +0000 (23:45 +0100)
committerJilles Tjoelker <redacted>
Sat, 3 Mar 2012 22:45:52 +0000 (23:45 +0100)
Arbitrarily prefer a forward channel to no forward channel and an
alphabetically higher forward channel to a lower one.

This is a simplistic implementation that generates one MODE message to
local clients for each ban removed (to be replaced).

For simplicity and to avoid amplification of incoming MODE messages,
regular modes may still desync the forward channel of a ban.

modules/core/m_mode.c

index 030985169ba8c30912448b360a3a43453560f7f7..87be36c93508a70c90c97d932abd6c27b93b430d 100644 (file)
@@ -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))