From 12c59fd50ce83f4c16184c9802d40626843cc48e Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 6 Apr 2009 23:43:48 +0100 Subject: core.s2smanager: Check for valid host and port before attempting connection --- core/s2smanager.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 4c758159..158536d8 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -177,6 +177,11 @@ function attempt_connection(host_session, err) return false; end + if not (connect_host and connect_port) then + -- Likely we couldn't resolve DNS + return false; + end + -- Ok, we're going to try to connect conn:settimeout(0); local success, err = conn:connect(connect_host, connect_port); -- cgit v1.2.3 From a015a200fd9ed84a0b5652d7e84406049755b341 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 8 Apr 2009 11:21:21 +0100 Subject: componentmanager: Reply with service-unavailable for unconnected components --- core/componentmanager.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/componentmanager.lua b/core/componentmanager.lua index 0b13c5c5..5efb1f51 100644 --- a/core/componentmanager.lua +++ b/core/componentmanager.lua @@ -34,12 +34,18 @@ end); module "componentmanager" +local function default_component_handler(origin, stanza) + origin.send(st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable")); +end + + function load_enabled_components(config) local defined_hosts = config or configmanager.getconfig(); for host, host_config in pairs(defined_hosts) do if host ~= "*" and ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then hosts[host] = { type = "component", host = host, connected = false, s2sout = {} }; + components[host] = default_component_handler; local ok, err = modulemanager.load(host, host_config.core.component_module); if not ok then log("error", "Error loading %s component %s: %s", tostring(host_config.core.component_module), tostring(host), tostring(err)); @@ -93,7 +99,13 @@ function deregister_component(host) if components[host] then modulemanager.unload(host, "dialback"); components[host] = nil; - hosts[host] = nil; + local host_config = defined_hosts[host]; + if ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then + -- Set default handler + else + -- Component not in config, or disabled, remove + hosts[host] = nil; + end -- remove from disco_items if not(host:find("@", 1, true) or host:find("/", 1, true)) and host:find(".", 1, true) then disco_items:remove(host:sub(host:find(".", 1, true)+1), host); @@ -105,4 +117,8 @@ function deregister_component(host) end end +function set_component_handler(host, handler) + components[host] = handler; +end + return _M; -- cgit v1.2.3 From 493839e2acc5b05bec6733c5a345ffff6ddd46d1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 8 Apr 2009 20:01:53 +0100 Subject: core.s2smanager: Look away... wait for it... now! Hopefully s2s should be back to normal. --- core/s2smanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 158536d8..0ef8e241 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -250,7 +250,7 @@ function streamopened(session, attr) end function streamclosed(session) - session.send(""); + session.sends2s(""); session.notopen = true; end -- cgit v1.2.3