From 884c434947f4e6a9077b8b65a90b3cef39a04ba4 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sun, 3 Aug 2014 02:14:15 +0200
Subject: kike: don't disclose secret channels in LUSERS
---
src/kike.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
(limited to 'src')
diff --git a/src/kike.c b/src/kike.c
index 2a1744e..e14a646 100644
--- a/src/kike.c
+++ b/src/kike.c
@@ -725,6 +725,15 @@ irc_send_motd (struct client *c)
irc_send_reply (c, IRC_RPL_ENDOFMOTD);
}
+static bool
+client_on_channel (struct client *c, const struct channel *chan)
+{
+ for (struct channel_user *iter = chan->users; iter; iter = iter->next)
+ if (!irc_strcmp (iter->nickname, c->nickname))
+ return true;
+ return false;
+}
+
static void
irc_send_lusers (struct client *c)
{
@@ -739,7 +748,14 @@ irc_send_lusers (struct client *c)
n_opers++;
}
- int n_channels = c->ctx->channels.len;
+ int n_channels = 0;
+ struct str_map_iter iter;
+ str_map_iter_init (&iter, &c->ctx->channels);
+ struct channel *chan;
+ while ((chan = str_map_iter_next (&iter)))
+ if (!(chan->modes & IRC_CHAN_MODE_SECRET)
+ || client_on_channel (c, chan))
+ n_channels++;
irc_send_reply (c, IRC_RPL_LUSERCLIENT,
n_users, n_services, 1 /* servers total */);
--
cgit v1.2.3-70-g09d2