-- COPYING file in the source package for more information.
--
-local prosody = prosody;
+local prosody = _G.prosody;
local log = require "util.logger".init("componentmanager");
local configmanager = require "core.configmanager";
local modulemanager = require "core.modulemanager";
module "componentmanager"
local function default_component_handler(origin, stanza)
- log("warn", "Stanza being handled by default component, bouncing error");
+ log("warn", "Stanza being handled by default component; bouncing error for: %s", stanza:top_tag());
if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
origin.send(st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable"));
end
end
end
-prosody.events.add_handler("server-starting", load_enabled_components);
+if prosody and prosody.events then
+ prosody.events.add_handler("server-starting", load_enabled_components);
+end
function handle_stanza(origin, stanza)
local node, host = jid_split(stanza.attr.to);
component(origin, stanza, hosts[host]);
else
log("error", "Component manager recieved a stanza for a non-existing component: "..tostring(stanza));
+ default_component_handler(origin, stanza);
end
end
if not(host:find("@", 1, true) or host:find("/", 1, true)) and host:find(".", 1, true) then
disco_items:set(host:sub(host:find(".", 1, true)+1), host, true);
end
- -- FIXME only load for a.b.c if b.c has dialback, and/or check in config
modulemanager.load(host, "dialback");
+ modulemanager.load(host, "tls");
log("debug", "component added: "..host);
return session or hosts[host];
else
function deregister_component(host)
if components[host] then
+ modulemanager.unload(host, "tls");
modulemanager.unload(host, "dialback");
hosts[host].connected = nil;
local host_config = configmanager.getconfig()[host];
components[host] = default_component_handler;
else
-- Component not in config, or disabled, remove
- hosts[host] = nil;
+ hosts[host] = nil; -- FIXME do proper unload of all modules and other cleanup before removing
components[host] = nil;
end
-- remove from disco_items