1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-07 13:23:13 +02:00

Update HOOKTYPE_STATS: will now be called for unknown flags and for

all known flags as well. So you can now add stats via modules.
Only the stats help is currently missing if you do so.
=> Moved dccdeny stats to dccdeny
This commit is contained in:
Bram Matthys
2019-10-25 13:51:22 +02:00
parent 09854abade
commit 51b0a7a373
4 changed files with 35 additions and 8 deletions
+4 -1
View File
@@ -1472,9 +1472,12 @@ void memberflood_free(ModData *md)
int floodprot_stats(Client *client, char *flag)
{
if (*flag != 'S')
return 0;
sendtxtnumeric(client, "modef-default-unsettime: %hd", (unsigned short)MODEF_DEFAULT_UNSETTIME);
sendtxtnumeric(client, "modef-max-unsettime: %hd", (unsigned short)MODEF_MAX_UNSETTIME);
return 0;
return 1;
}
/** Admin unloading the floodprot module for good. Bad. */
+8 -6
View File
@@ -40,6 +40,7 @@ int dccdeny_configtest_deny_dcc(ConfigFile *cf, ConfigEntry *ce, int type, int *
int dccdeny_configtest_allow_dcc(ConfigFile *cf, ConfigEntry *ce, int type, int *errs);
int dccdeny_configrun_deny_dcc(ConfigFile *cf, ConfigEntry *ce, int type);
int dccdeny_configrun_allow_dcc(ConfigFile *cf, ConfigEntry *ce, int type);
int dccdeny_stats(Client *client, char *para);
CMD_FUNC(cmd_dccdeny);
CMD_FUNC(cmd_undccdeny);
CMD_FUNC(cmd_svsfline);
@@ -75,6 +76,7 @@ MOD_INIT()
CommandAdd(modinfo->handle, "DCCDENY", cmd_dccdeny, 2, CMD_USER);
CommandAdd(modinfo->handle, "UNDCCDENY", cmd_undccdeny, MAXPARA, CMD_USER);
CommandAdd(modinfo->handle, "SVSFLINE", cmd_svsfline, MAXPARA, CMD_SERVER);
HookAdd(modinfo->handle, HOOKTYPE_STATS, 0, dccdeny_stats);
HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_USER, 0, dccdeny_can_send_to_user);
HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_CHANNEL, 0, dccdeny_can_send_to_channel);
HookAdd(modinfo->handle, HOOKTYPE_SERVER_SYNC, 0, dccdeny_server_sync);
@@ -818,14 +820,17 @@ static void dcc_wipe_services(void)
}
// FIXME: hook into HOOKTYPE_STATS
int stats_denydcc(Client *client, char *para)
int dccdeny_stats(Client *client, char *para)
{
ConfigItem_deny_dcc *denytmp;
ConfigItem_allow_dcc *allowtmp;
char *filemask, *reason;
char a = 0;
/* '/STATS F' or '/STATS denydcc' is for us... */
if (strcmp(para, "F") && strcasecmp(para, "denydcc"))
return 0;
for (denytmp = conf_deny_dcc; denytmp; denytmp = denytmp->next)
{
filemask = BadPtr(denytmp->filename) ? "<NULL>" : denytmp->filename;
@@ -853,8 +858,5 @@ int stats_denydcc(Client *client, char *para)
sendtxtnumeric(client, "a %c %c %s", (allowtmp->flag.type == DCCDENY_SOFT) ? 's' : 'h',
a, filemask);
}
return 0;
return 1;
}
// { 'F', "denydcc", stats_denydcc, 0 },
+3
View File
@@ -330,7 +330,10 @@ static int cb_conf(ConfigFile *cf, ConfigEntry *ce, int type)
static int cb_stats(Client *client, char *flag)
{
if (*flag == 'S')
{
sendtxtnumeric(client, "staff-file: %s", STAFF_FILE);
return 1;
}
return 0;
}
+20 -1
View File
@@ -292,6 +292,7 @@ static inline char *allow_user_stats_long_to_short()
CMD_FUNC(cmd_stats)
{
struct statstab *stat;
char flags[2];
if (parc == 3 && parv[2][0] != '+' && parv[2][0] != '-')
{
@@ -334,11 +335,24 @@ CMD_FUNC(cmd_stats)
if (!stat)
{
stats_help(client);
/* Not found. Perhaps a module provides it? */
Hook *h;
int found = 0, n;
for (h = Hooks[HOOKTYPE_STATS]; h; h = h->next)
{
n = (*(h->func.intfunc))(client, parv[1]);
if (n == 1)
found = 1;
}
if (!found)
stats_help(client);
sendnumeric(client, RPL_ENDOFSTATS, '*');
return;
}
flags[0] = stat->flag;
flags[1] = '\0';
if (stat->options & FLAGS_AS_PARA)
{
if (parc > 2 && (parv[2][0] == '+' || parv[2][0] == '-'))
@@ -362,7 +376,12 @@ CMD_FUNC(cmd_stats)
}
else
stat->func(client, NULL);
/* Modules can append data: */
RunHook2(HOOKTYPE_STATS, client, flags);
sendnumeric(client, RPL_ENDOFSTATS, stat->flag);
if (!IsULine(client))
sendto_snomask(SNO_EYES, "Stats \'%c\' requested by %s (%s@%s)",
stat->flag, client->name, client->user->username, GetHost(client));