# HG changeset patch # User Matthew Wild # Date 1759835719 -3600 # Node ID d520cee2bbdbefbcef284a8486b4aaae2b3c8370 # Parent 3326c8a29a867474606f8646a3307068962b7cb7 mod_admin_shell: Add config:dump() command to display the in-memory configuration diff -r 3326c8a29a86 -r d520cee2bbdb plugins/mod_admin_shell.lua --- a/plugins/mod_admin_shell.lua Mon Oct 06 00:30:14 2025 +0200 +++ b/plugins/mod_admin_shell.lua Tue Oct 07 12:15:19 2025 +0100 @@ -992,6 +992,44 @@ return ok, (ok and "Config reloaded (you may need to reload modules to take effect)") or tostring(err); end +describe_command [[config:dump() - Display the current server configuration from memory]] +function def_env.config:dump() + local config = require "prosody.core.configmanager".getconfig(); + local serialize = require "prosody.util.serialization".serialize; + + local print = self.session.print; + + print("-- Configuration dumped from Prosody "..prosody.version); + print("-- at "..os.date("%Y-%m-%d %R").."\n"); + print("-- Global options\n") + for opt, val in it.sorted_pairs(config["*"]) do + print(opt.." = "..serialize(val, "pretty").."\n"); + end + + print("-- Hosts and components\n"); + + local n_hosts = 0; + for host in it.filter("*", it.sorted_pairs(config)) do + n_hosts = n_hosts + 1; + local host_config = config[host]; + if host_config.type ~= "component" then + print(("\nVirtualHost %q"):format(host)); + else + print(("\nComponent %q %q"):format(host, host_config.component_module)); + end + + for opt, val in it.sorted_pairs(host_config) do + if opt ~= "component_module" then + print("\t"..opt.." = "..serialize(val, "pretty").."\n"); + end + end + end + + print("\n-- End of configuration --"); + + return true, "Showing server configuration with "..n_hosts.." hosts"; +end + def_env.c2s = new_section("Commands to manage local client-to-server sessions"); local function get_jid(session)