Send hidden mode changes to auspex:cmodes

This commit is contained in:
Ed Kellett 2020-06-07 17:36:31 +01:00
parent 076973363a
commit d3fd88a406
No known key found for this signature in database
GPG key ID: CB9986DEF342FABC
3 changed files with 69 additions and 37 deletions

View file

@ -59,6 +59,7 @@ extern void sendto_channel_opmod(struct Client *one, struct Client *source_p,
const char *text); const char *text);
extern void sendto_channel_local(struct Client *, int type, struct Channel *, const char *, ...) AFP(4, 5); extern void sendto_channel_local(struct Client *, int type, struct Channel *, const char *, ...) AFP(4, 5);
extern void sendto_channel_local_priv(struct Client *, int type, const char *priv, struct Channel *, const char *, ...) AFP(5, 6);
extern void sendto_channel_local_butone(struct Client *, int type, struct Channel *, const char *, ...) AFP(4, 5); extern void sendto_channel_local_butone(struct Client *, int type, struct Channel *, const char *, ...) AFP(4, 5);
extern void sendto_channel_local_with_capability(struct Client *, int type, int caps, int negcaps, struct Channel *, const char *, ...) AFP(6, 7); extern void sendto_channel_local_with_capability(struct Client *, int type, int caps, int negcaps, struct Channel *, const char *, ...) AFP(6, 7);

View file

@ -1742,7 +1742,13 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
for(j = 0; j < 3; j++) for(j = 0; j < 3; j++)
{ {
flags = flags_list[j]; int send_flags = flags = flags_list[j];
const char *priv = "";
if (flags == ONLY_OPERS)
{
send_flags = ALL_MEMBERS;
priv = "auspex:cmodes";
}
cur_len = mlen; cur_len = mlen;
mbuf = modebuf + mlen; mbuf = modebuf + mlen;
pbuf = parabuf; pbuf = parabuf;
@ -1775,8 +1781,8 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
*mbuf = '\0'; *mbuf = '\0';
if(cur_len > mlen) if(cur_len > mlen)
sendto_channel_local(IsServer(source_p) ? fakesource_p : source_p, sendto_channel_local_priv(IsServer(source_p) ? fakesource_p : source_p,
flags, chptr, "%s %s", modebuf, parabuf); send_flags, priv, chptr, "%s %s", modebuf, parabuf);
else else
continue; continue;
@ -1812,8 +1818,8 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
*mbuf = '\0'; *mbuf = '\0';
if(cur_len > mlen) if(cur_len > mlen)
sendto_channel_local(IsServer(source_p) ? fakesource_p : source_p, sendto_channel_local_priv(IsServer(source_p) ? fakesource_p : source_p,
flags, chptr, "%s %s", modebuf, parabuf); send_flags, priv, chptr, "%s %s", modebuf, parabuf);
} }
/* only propagate modes originating locally, or if we're hubbing */ /* only propagate modes originating locally, or if we're hubbing */

View file

@ -675,6 +675,62 @@ sendto_channel_opmod(struct Client *one, struct Client *source_p,
msgbuf_cache_free(&msgbuf_cache); msgbuf_cache_free(&msgbuf_cache);
} }
/* _sendto_channel_local
*
* inputs - source, flags to send to, privs to send to, channel to send to, va_args
* outputs - message to local channel members
* side effects -
*/
void
_sendto_channel_local(struct Client *source_p, int type, const char *priv, struct Channel *chptr, const char *pattern, va_list *args)
{
struct membership *msptr;
struct Client *target_p;
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
struct MsgBuf msgbuf;
struct MsgBuf_cache msgbuf_cache;
rb_strf_t strings = { .format = pattern, .format_args = args, .next = NULL };
build_msgbuf_tags(&msgbuf, source_p);
msgbuf_cache_init(&msgbuf_cache, &msgbuf, &strings);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
{
msptr = ptr->data;
target_p = msptr->client_p;
if (IsIOError(target_p))
continue;
if (type && ((msptr->flags & type) == 0))
continue;
if (priv != NULL && !HasPrivilege(target_p, priv))
continue;
_send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
msgbuf_cache_free(&msgbuf_cache);
}
/* sendto_channel_local_priv()
*
* inputs - source, flags to send to, privs to send to, channel to send to, va_args
* outputs - message to local channel members
* side effects -
*/
void
sendto_channel_local_priv(struct Client *source_p, int type, const char *priv, struct Channel *chptr, const char *pattern, ...)
{
va_list args;
va_start(args, pattern);
_sendto_channel_local(source_p, type, priv, chptr, pattern, &args);
va_end(args);
}
/* sendto_channel_local() /* sendto_channel_local()
* *
* inputs - source, flags to send to, channel to send to, va_args * inputs - source, flags to send to, channel to send to, va_args
@ -685,40 +741,9 @@ void
sendto_channel_local(struct Client *source_p, int type, struct Channel *chptr, const char *pattern, ...) sendto_channel_local(struct Client *source_p, int type, struct Channel *chptr, const char *pattern, ...)
{ {
va_list args; va_list args;
struct membership *msptr;
struct Client *target_p;
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
struct MsgBuf msgbuf;
struct MsgBuf_cache msgbuf_cache;
rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
build_msgbuf_tags(&msgbuf, source_p);
va_start(args, pattern); va_start(args, pattern);
msgbuf_cache_init(&msgbuf_cache, &msgbuf, &strings); _sendto_channel_local(source_p, type, NULL, chptr, pattern, &args);
va_end(args); va_end(args);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
{
msptr = ptr->data;
target_p = msptr->client_p;
if(IsIOError(target_p))
continue;
if(type == ONLY_OPERS)
{
if (!IsOper(target_p))
continue;
}
else if(type && ((msptr->flags & type) == 0))
continue;
_send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
msgbuf_cache_free(&msgbuf_cache);
} }
/* /*