aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-08-03 02:14:15 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-08-03 02:14:15 +0200
commit884c434947f4e6a9077b8b65a90b3cef39a04ba4 (patch)
treeaa2c7e06165a973b3296d8c3da87775bef00e317
parent96f4b81182f15a8a209ffe3ad023f67583999e3c (diff)
downloadxK-884c434947f4e6a9077b8b65a90b3cef39a04ba4.tar.gz
xK-884c434947f4e6a9077b8b65a90b3cef39a04ba4.tar.xz
xK-884c434947f4e6a9077b8b65a90b3cef39a04ba4.zip
kike: don't disclose secret channels in LUSERS
-rw-r--r--src/kike.c18
1 files changed, 17 insertions, 1 deletions
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 */);