From d9a74e419644cd8caa619cc7f544256ce1ca9008 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 16 Dec 2011 16:01:59 +0000 Subject: hostmanager: Add send() method to hosts --- core/hostmanager.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'core/hostmanager.lua') diff --git a/core/hostmanager.lua b/core/hostmanager.lua index 9e74cd6b..0dd1d426 100644 --- a/core/hostmanager.lua +++ b/core/hostmanager.lua @@ -53,6 +53,17 @@ end prosody_events.add_handler("server-starting", load_enabled_hosts); +local function host_send(stanza) + local name, type = stanza.name, stanza.attr.type; + if type == "error" or (name == "iq" and type == "result") then + local dest_host_name = select(2, jid_split(stanza.attr.to)); + local dest_host = hosts[dest_host_name] or { type = "unknown" }; + log("warn", "Unhandled response sent to %s host %s: %s", dest_host.type, dest_host_name, tostring(stanza)); + return; + end + core_route_stanza(nil, stanza); +end + function activate(host, host_config) if hosts[host] then return nil, "The host "..host.." is already activated"; end host_config = host_config or configmanager.getconfig()[host]; @@ -63,6 +74,7 @@ function activate(host, host_config) events = events_new(); dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen(); disallow_s2s = configmanager.get(host, "core", "disallow_s2s"); + send = host_send; }; if not host_config.core.component_module then -- host host_session.type = "local"; -- cgit v1.2.3 From 88637ab348548a4893b1bea2bb813c13d7c26f19 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 27 Apr 2012 22:31:53 +0100 Subject: hostmanager: Convert host-deactivating event parameters to a table --- core/hostmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/hostmanager.lua') diff --git a/core/hostmanager.lua b/core/hostmanager.lua index 330a0d03..91c6d4e1 100644 --- a/core/hostmanager.lua +++ b/core/hostmanager.lua @@ -102,7 +102,7 @@ function deactivate(host, reason) local host_session = hosts[host]; if not host_session then return nil, "The host "..tostring(host).." is not activated"; end log("info", "Deactivating host: %s", host); - prosody_events.fire_event("host-deactivating", host, host_session); + prosody_events.fire_event("host-deactivating", { host = host, host_session = host_session, reason = reason }); if type(reason) ~= "table" then reason = { condition = "host-gone", text = tostring(reason or "This server has stopped serving "..host) }; -- cgit v1.2.3 From 3547b00138ab3a8721b4872023f9f42944298815 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 27 Apr 2012 22:32:04 +0100 Subject: hostmanager: Add some TODO comments --- core/hostmanager.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'core/hostmanager.lua') diff --git a/core/hostmanager.lua b/core/hostmanager.lua index 91c6d4e1..39af5732 100644 --- a/core/hostmanager.lua +++ b/core/hostmanager.lua @@ -109,6 +109,7 @@ function deactivate(host, reason) end -- Disconnect local users, s2s connections + -- TODO: These should move to mod_c2s and mod_s2s (how do they know they're being unloaded and not reloaded?) if host_session.sessions then for username, user in pairs(host_session.sessions) do for resource, session in pairs(user.sessions) do @@ -133,6 +134,7 @@ function deactivate(host, reason) end end + -- TODO: This should be done in modulemanager if host_session.modules then for module in pairs(host_session.modules) do modulemanager.unload(host, module); -- cgit v1.2.3 From f427f1c7d5f397979d4fedf49e1ccec67efd8ff6 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 27 Apr 2012 22:33:38 +0100 Subject: hostmanager: Remove unused host_config parameter from host-activated event --- core/hostmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/hostmanager.lua') diff --git a/core/hostmanager.lua b/core/hostmanager.lua index 39af5732..4b9fa240 100644 --- a/core/hostmanager.lua +++ b/core/hostmanager.lua @@ -94,7 +94,7 @@ function activate(host, host_config) end log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host); - prosody_events.fire_event("host-activated", host, host_config); + prosody_events.fire_event("host-activated", host); return true; end -- cgit v1.2.3 From 3ba967c53a6cd3570047c6e9416be1935eeb174a Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 28 Apr 2012 02:25:54 +0100 Subject: hostmanager: Remove import of unused setmetatable --- core/hostmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/hostmanager.lua') diff --git a/core/hostmanager.lua b/core/hostmanager.lua index 4b9fa240..a9db1a92 100644 --- a/core/hostmanager.lua +++ b/core/hostmanager.lua @@ -24,7 +24,7 @@ if not _G.prosody.incoming_s2s then end local incoming_s2s = _G.prosody.incoming_s2s; -local pairs, setmetatable, select = pairs, setmetatable, select; +local pairs, select = pairs, select; local tostring, type = tostring, type; module "hostmanager" -- cgit v1.2.3