aboutsummaryrefslogtreecommitdiffstats
path: root/core/hostmanager.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-05-18 20:50:50 +0200
committerKim Alvefur <zash@zash.se>2015-05-18 20:50:50 +0200
commitf6b0d630fc55870e910f8ff286e55bea6e451e38 (patch)
tree3dfda93d2bcb6a6631dbe9beaffeeb8cb2554d47 /core/hostmanager.lua
parent0ee5b781b852a955144f4c04f732ae0de19ed174 (diff)
downloadprosody-f6b0d630fc55870e910f8ff286e55bea6e451e38.tar.gz
prosody-f6b0d630fc55870e910f8ff286e55bea6e451e38.zip
hostmanager: Metatable with __tostring on hosts
Diffstat (limited to 'core/hostmanager.lua')
-rw-r--r--core/hostmanager.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/hostmanager.lua b/core/hostmanager.lua
index d7329cd2..046722b1 100644
--- a/core/hostmanager.lua
+++ b/core/hostmanager.lua
@@ -26,9 +26,23 @@ 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 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 function load_enabled_hosts(config)
@@ -76,6 +90,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 = {};