X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=core%2Fhostmanager.lua;h=53c1cd4eeaa4cd72b54507952ad1401738f60553;hb=2a8a192c7c5ff4c13370adab7fbe1c926f45b01d;hp=d7329cd26160b413cc07ecbd5d256d37b8baddc3;hpb=774d985d6a690539af5086956f2c9fb89c41ad26;p=prosody.git diff --git a/core/hostmanager.lua b/core/hostmanager.lua index d7329cd2..53c1cd4e 100644 --- a/core/hostmanager.lua +++ b/core/hostmanager.lua @@ -26,11 +26,27 @@ local core_route_stanza = _G.prosody.core_route_stanza; 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() + if self.type == "component" then + local typ = configmanager.get(self.host, "component_module"); + if typ == "component" then + return ("Component %q"):format(self.host); + end + return ("Component %q %q"):format(self.host, typ); + elseif self.type == "local" then + return ("VirtualHost %q"):format(self.host); + end +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; @@ -76,6 +92,7 @@ function activate(host, host_config) send = host_send; modules = {}; }; + setmetatable(host_session, host_mt); if not host_config.component_module then -- host host_session.type = "local"; host_session.sessions = {}; @@ -149,8 +166,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; +}