Keep forward channels in sync after a netjoin.

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.
This commit is contained in:
Jilles Tjoelker 2012-03-03 23:45:52 +01:00
parent 6929cd012b
commit d1316b193b

View 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))