mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-06-12 17:14:46 +02:00
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.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include <ares.h>
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
+14
-3
@@ -31,9 +31,10 @@ void unrealircdctl_usage(const char *program_name)
|
||||
{
|
||||
printf("Usage: %s <option>\n"
|
||||
"Where <option> is one of:\n"
|
||||
"rehash - Rehash the server (reread configuration files)\n"
|
||||
"reloadtls - Reload the SSL/TLS certificates\n"
|
||||
"status - Show current status of server\n"
|
||||
"rehash - Rehash the server (reread configuration files)\n"
|
||||
"reloadtls - Reload the SSL/TLS certificates\n"
|
||||
"status - Show current status of server\n"
|
||||
"module-status - Show currently loaded modules\n"
|
||||
"\n", program_name);
|
||||
exit(-1);
|
||||
}
|
||||
@@ -71,6 +72,14 @@ void unrealircdctl_status(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void unrealircdctl_module_status(void)
|
||||
{
|
||||
if (procio_client("MODULES", 2) == 0)
|
||||
exit(0);
|
||||
printf("Could not retrieve complete module list.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void unrealircdctl_mkpasswd(int argc, char *argv[])
|
||||
{
|
||||
AuthenticationType type;
|
||||
@@ -233,6 +242,8 @@ int main(int argc, char *argv[])
|
||||
unrealircdctl_reloadtls();
|
||||
else if (!strcmp(argv[1], "status"))
|
||||
unrealircdctl_status();
|
||||
else if (!strcmp(argv[1], "module-status"))
|
||||
unrealircdctl_module_status();
|
||||
else if (!strcmp(argv[1], "mkpasswd"))
|
||||
unrealircdctl_mkpasswd(argc, argv);
|
||||
else if (!strcmp(argv[1], "gencloak"))
|
||||
|
||||
@@ -91,6 +91,8 @@ elif [ "$1" = "rehash" ] ; then
|
||||
$UNREALIRCDCTL $*
|
||||
elif [ "$1" = "status" ] ; then
|
||||
$UNREALIRCDCTL $*
|
||||
elif [ "$1" = "module-status" ] ; then
|
||||
$UNREALIRCDCTL $*
|
||||
elif [ "$1" = "reloadtls" ] ; then
|
||||
$UNREALIRCDCTL $*
|
||||
elif [ "$1" = "restart" ] ; then
|
||||
|
||||
Reference in New Issue
Block a user