Merge 0.10->trunk
[prosody.git] / core / hostmanager.lua
index 046722b1a0ff3ca80c40f4a5225e06354ba6e566..c04e9e85b83f3074ed15f29550f9f843f3cab9fe 100644 (file)
@@ -28,7 +28,7 @@ local pairs, select, rawget = pairs, select, rawget;
 local tostring, type = tostring, type;
 local setmetatable = setmetatable;
 
-module "hostmanager"
+local _ENV = nil;
 
 local host_mt = { }
 function host_mt:__tostring()
@@ -45,6 +45,8 @@ end
 
 local hosts_loaded_once;
 
+local activate, deactivate;
+
 local function load_enabled_hosts(config)
        local defined_hosts = config or configmanager.getconfig();
        local activated_any_host;
@@ -69,13 +71,6 @@ end
 prosody_events.add_handler("server-starting", load_enabled_hosts);
 
 local function host_send(stanza)
-       local name, stanza_type = stanza.name, stanza.attr.type;
-       if stanza_type == "error" or (name == "iq" and stanza_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
 
@@ -164,8 +159,12 @@ function deactivate(host, reason)
        return true;
 end
 
-function get_children(host)
+local function get_children(host)
        return disco_items:get(host) or NULL;
 end
 
-return _M;
+return {
+       activate = activate;
+       deactivate = deactivate;
+       get_children = get_children;
+}