From f650239b4f5223dc9876f2fe4bb348dacee56868 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Fri, 28 Jan 2022 08:45:20 +0100 Subject: [PATCH] Add "./unrealircd module-status" to show currently loaded modules, including version, description, author, flags. The output is pretty much identical to "MODULE -all" on IRC as IRCOp. Useful for the future if you want to verify a module has been upgraded from the command line. --- src/proc_io_server.c | 30 ++++++++++++++++++++++++++++++ src/unrealircdctl.c | 17 ++++++++++++++--- unrealircd.in | 2 ++ 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/proc_io_server.c b/src/proc_io_server.c index 04ca875c9..35e150621 100644 --- a/src/proc_io_server.c +++ b/src/proc_io_server.c @@ -27,6 +27,7 @@ #include CMD_FUNC(procio_status); +CMD_FUNC(procio_modules); CMD_FUNC(procio_rehash); CMD_FUNC(procio_exit); CMD_FUNC(procio_help); @@ -50,6 +51,7 @@ void add_proc_io_server(void) if (add_listener(listener) == -1) exit(-1); CommandAdd(NULL, "STATUS", procio_status, MAXPARA, CMD_CONTROL); + CommandAdd(NULL, "MODULES", procio_modules, MAXPARA, CMD_CONTROL); CommandAdd(NULL, "REHASH", procio_rehash, MAXPARA, CMD_CONTROL); CommandAdd(NULL, "EXIT", procio_exit, MAXPARA, CMD_CONTROL); CommandAdd(NULL, "HELP", procio_help, MAXPARA, CMD_CONTROL); @@ -83,6 +85,33 @@ CMD_FUNC(procio_status) sendto_one(client, NULL, "END 0"); } +extern MODVAR Module *Modules; +CMD_FUNC(procio_modules) +{ + char tmp[1024]; + Module *m; + + for (m = Modules; m; m = m->next) + { + tmp[0] = '\0'; + if (m->flags & MODFLAG_DELAYED) + strlcat(tmp, "[Unloading] ", sizeof(tmp)); + if (m->options & MOD_OPT_PERM_RELOADABLE) + strlcat(tmp, "[PERM-BUT-RELOADABLE] ", sizeof(tmp)); + if (m->options & MOD_OPT_PERM) + strlcat(tmp, "[PERM] ", sizeof(tmp)); + if (!(m->options & MOD_OPT_OFFICIAL)) + strlcat(tmp, "[3RD] ", sizeof(tmp)); + sendto_one(client, NULL, "REPLY %s %s - %s - by %s %s", + m->header->name, + m->header->version, + m->header->description, + m->header->author, + tmp); + } + sendto_one(client, NULL, "END 0"); +} + CMD_FUNC(procio_rehash) { if (loop.rehashing) @@ -121,6 +150,7 @@ CMD_FUNC(procio_help) sendto_one(client, NULL, "REPLY HELP"); sendto_one(client, NULL, "REPLY REHASH"); sendto_one(client, NULL, "REPLY STATUS"); + sendto_one(client, NULL, "REPLY MODULES"); sendto_one(client, NULL, "END 0"); } diff --git a/src/unrealircdctl.c b/src/unrealircdctl.c index fd2b83590..19b51939d 100644 --- a/src/unrealircdctl.c +++ b/src/unrealircdctl.c @@ -31,9 +31,10 @@ void unrealircdctl_usage(const char *program_name) { printf("Usage: %s