mod_admin_socket: Return error on unhandled input to prevent apparent freeze

When mod_admin_socket is loaded without mod_admin_shell, attempt to use
`prosodyctl shell` will appear to freeze after any input, since no
response is returned.
This commit is contained in:
Kim Alvefur 2023-02-16 17:20:09 +01:00
parent bc1e51eb83
commit 67ea0ee50e
2 changed files with 7 additions and 1 deletions

View file

@ -198,6 +198,7 @@ module:hook("admin/repl-input", function (event)
if not ok then
event.origin.send(st.stanza("repl-result", { type = "error" }):text(err));
end
return true;
end);
-- Console commands --

View file

@ -19,6 +19,7 @@ end
local server = require "net.server";
local adminstream = require "util.adminstream";
local st = require "util.stanza";
local socket_path = module:get_option_path("admin_socket", "prosody.sock", "data");
@ -35,7 +36,11 @@ local function fire_admin_event(session, stanza)
event_name = "admin/"..stanza.name;
end
module:log("debug", "Firing %s", event_name);
return module:fire_event(event_name, event_data);
local ret = module:fire_event(event_name, event_data);
if ret == nil then
session.send(st.stanza("repl-result", { type = "error" }):text("No module handled this query. Is mod_admin_shell enabled?"));
end
return ret;
end
module:hook("server-stopping", function ()