Mercurial > prosody-hg
comparison plugins/mod_admin_shell.lua @ 13978:d520cee2bbdb
mod_admin_shell: Add config:dump() command to display the in-memory configuration
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 07 Oct 2025 12:15:19 +0100 |
| parents | a2d4c71f5066 |
| children | 015c8c75f8cf |
comparison
equal
deleted
inserted
replaced
| 13977:3326c8a29a86 | 13978:d520cee2bbdb |
|---|---|
| 988 | 988 |
| 989 describe_command [[config:reload() - Reload the server configuration. Modules may need to be reloaded for changes to take effect.]] | 989 describe_command [[config:reload() - Reload the server configuration. Modules may need to be reloaded for changes to take effect.]] |
| 990 function def_env.config:reload() | 990 function def_env.config:reload() |
| 991 local ok, err = prosody.reload_config(); | 991 local ok, err = prosody.reload_config(); |
| 992 return ok, (ok and "Config reloaded (you may need to reload modules to take effect)") or tostring(err); | 992 return ok, (ok and "Config reloaded (you may need to reload modules to take effect)") or tostring(err); |
| 993 end | |
| 994 | |
| 995 describe_command [[config:dump() - Display the current server configuration from memory]] | |
| 996 function def_env.config:dump() | |
| 997 local config = require "prosody.core.configmanager".getconfig(); | |
| 998 local serialize = require "prosody.util.serialization".serialize; | |
| 999 | |
| 1000 local print = self.session.print; | |
| 1001 | |
| 1002 print("-- Configuration dumped from Prosody "..prosody.version); | |
| 1003 print("-- at "..os.date("%Y-%m-%d %R").."\n"); | |
| 1004 print("-- Global options\n") | |
| 1005 for opt, val in it.sorted_pairs(config["*"]) do | |
| 1006 print(opt.." = "..serialize(val, "pretty").."\n"); | |
| 1007 end | |
| 1008 | |
| 1009 print("-- Hosts and components\n"); | |
| 1010 | |
| 1011 local n_hosts = 0; | |
| 1012 for host in it.filter("*", it.sorted_pairs(config)) do | |
| 1013 n_hosts = n_hosts + 1; | |
| 1014 local host_config = config[host]; | |
| 1015 if host_config.type ~= "component" then | |
| 1016 print(("\nVirtualHost %q"):format(host)); | |
| 1017 else | |
| 1018 print(("\nComponent %q %q"):format(host, host_config.component_module)); | |
| 1019 end | |
| 1020 | |
| 1021 for opt, val in it.sorted_pairs(host_config) do | |
| 1022 if opt ~= "component_module" then | |
| 1023 print("\t"..opt.." = "..serialize(val, "pretty").."\n"); | |
| 1024 end | |
| 1025 end | |
| 1026 end | |
| 1027 | |
| 1028 print("\n-- End of configuration --"); | |
| 1029 | |
| 1030 return true, "Showing server configuration with "..n_hosts.." hosts"; | |
| 993 end | 1031 end |
| 994 | 1032 |
| 995 def_env.c2s = new_section("Commands to manage local client-to-server sessions"); | 1033 def_env.c2s = new_section("Commands to manage local client-to-server sessions"); |
| 996 | 1034 |
| 997 local function get_jid(session) | 1035 local function get_jid(session) |
