Rename Channel_Count() to Channel_CountVisible() and only count channels
that are visible to the requesting client, so the existence of secret
channels is no longer revealed by using LUSERS.
Reported by Cahata -- thanks!
} /* Channel_Quit */
+/**
+ * Get number of channels this server knows and that are "visible" to
+ * the given client. If no client is given, all channels will be counted.
+ *
+ * @param Client The client to check or NULL.
+ * @return Number of channels visible to the client.
+ */
GLOBAL unsigned long
-Channel_Count( void )
+Channel_CountVisible (CLIENT *Client)
{
CHANNEL *c;
unsigned long count = 0;
c = My_Channels;
- while( c )
- {
- count++;
+ while(c) {
+ if (Client) {
+ if (!strchr(Channel_Modes(c), 's')
+ || Channel_IsMemberOf(c, Client))
+ count++;
+ } else
+ count++;
c = c->next;
}
return count;
-} /* Channel_Count */
+}
GLOBAL unsigned long
GLOBAL void Channel_Kick PARAMS((CLIENT *Peer, CLIENT *Target, CLIENT *Origin,
const char *Name, const char *Reason));
-GLOBAL unsigned long Channel_Count PARAMS(( void ));
+GLOBAL unsigned long Channel_CountVisible PARAMS((CLIENT *Client));
GLOBAL unsigned long Channel_MemberCount PARAMS(( CHANNEL *Chan ));
GLOBAL int Channel_CountForUser PARAMS(( CLIENT *Client ));
/* Number of created channels */
if (!IRC_WriteStrClient(Client, RPL_LUSERCHANNELS_MSG,
- Client_ID(Client), Channel_Count()))
+ Client_ID(Client),
+ Channel_CountVisible(Client)))
return DISCONNECTED;
/* Number of local users, services and servers */