1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-02 19:13:13 +02:00
Files
unrealircd/src/modules/lusers.c
T
Bram Matthys 4ac8015f84 Remove 'cptr' from all commands, hooks, etc. It only confuses people and
'sptr' is sufficient and in most cases the only one you should care about.
Should you need it, you can access sptr->direction in cases where you
need the old information (usually only for some sendto_* functions
and some protoctl checks), so 'cptr' was redundant too.

[!] This change likely introduces some bugs. This was many hours of work.
I only cut some corners in 4 functions, which will be fixed at a later
stage..... yes, more major changes to come.

On the plus side, I likely fixed some bugs in the process. Situations
where cptr vs sptr usage was incorrect. Eg using cptr->name (near server)
when sptr->name should be used (the actual source server), etc....
2019-10-02 14:25:40 +02:00

96 lines
2.8 KiB
C

/*
* IRC - Internet Relay Chat, src/modules/lusers.c
* (C) 2005 The UnrealIRCd Team
*
* See file AUTHORS in IRC package for additional names of
* the programmers.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "unrealircd.h"
CMD_FUNC(cmd_lusers);
#define MSG_LUSERS "LUSERS"
ModuleHeader MOD_HEADER
= {
"lusers",
"5.0",
"command /lusers",
"UnrealIRCd Team",
"unrealircd-5",
};
MOD_INIT()
{
CommandAdd(modinfo->handle, MSG_LUSERS, cmd_lusers, MAXPARA, CMD_USER|CMD_SERVER);
MARK_AS_OFFICIAL_MODULE(modinfo);
return MOD_SUCCESS;
}
MOD_LOAD()
{
return MOD_SUCCESS;
}
MOD_UNLOAD()
{
return MOD_SUCCESS;
}
/*
* parv[1] = server to query
*/
CMD_FUNC(cmd_lusers)
{
char flatmap;
if (hunt_server(sptr, recv_mtags, ":%s LUSERS :%s", 1, parc, parv) != HUNTED_ISME)
return 0;
flatmap = (FLAT_MAP && !ValidatePermissionsForPath("server:info:lusers",sptr,NULL,NULL,NULL)) ? 1 : 0;
/* Just to correct results ---Stskeeps */
if (irccounts.clients > irccounts.global_max)
irccounts.global_max = irccounts.clients;
if (irccounts.me_clients > irccounts.me_max)
irccounts.me_max = irccounts.me_clients;
sendnumeric(sptr, RPL_LUSERCLIENT,
irccounts.clients - irccounts.invisible, irccounts.invisible,
irccounts.servers);
if (irccounts.operators)
sendnumeric(sptr, RPL_LUSEROP, irccounts.operators);
if (irccounts.unknown)
sendnumeric(sptr, RPL_LUSERUNKNOWN, irccounts.unknown);
if (irccounts.channels)
sendnumeric(sptr, RPL_LUSERCHANNELS, irccounts.channels);
sendnumeric(sptr, RPL_LUSERME, irccounts.me_clients, flatmap ? 0 : irccounts.me_servers);
sendnumeric(sptr, RPL_LOCALUSERS, irccounts.me_clients, irccounts.me_max, irccounts.me_clients, irccounts.me_max);
sendnumeric(sptr, RPL_GLOBALUSERS, irccounts.clients, irccounts.global_max, irccounts.clients, irccounts.global_max);
if ((irccounts.me_clients + irccounts.me_servers) > max_connection_count)
{
max_connection_count =
irccounts.me_clients + irccounts.me_servers;
if (max_connection_count % 10 == 0) /* only send on even tens */
sendto_ops("New record on this server: %d connections (%d clients)",
max_connection_count, irccounts.me_clients);
}
return 0;
}